Node.js
Node.js
Inspect HTTP Request Header
Demonstrates theLastHeader property.
Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
var http = new chilkat.Http();
var url = "https://chilkatsoft.com/echo_request_body.asp";
var json = "{\"greeting\":\"Hello World\"}";
// Send a POST with the JSON in the HTTP request body.
var resp = new chilkat.HttpResponse();
success = http.HttpStr("POST",url,json,"utf-8","application/json",resp);
if (success == false) {
console.log(http.LastErrorText);
return;
}
// Examine the HTTP request header we just sent.
console.log(http.LastHeader);
// Output:
// POST /echo_request_body.asp HTTP/1.1
// Host: chilkatsoft.com
// Accept: */*
// Accept-Encoding: gzip
// Content-Type: application/json
// Content-Length: 26
}
chilkatExample();