Sample code for 30+ languages & platforms
JavaScript

Inspect HTTP Request Header

Demonstrates the LastHeader property.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

var http = new CkHttp();

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 CkHttpResponse();
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