Sample code for 30+ languages & platforms
C++

Inspect HTTP Request Header

Demonstrates the LastHeader property.

Chilkat C++ Downloads

C++
#include <CkHttp.h>
#include <CkHttpResponse.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkHttp http;

    const char *url = "https://chilkatsoft.com/echo_request_body.asp";
    const char *json = "{\"greeting\":\"Hello World\"}";

    //  Send a POST with the JSON in the HTTP request body.
    CkHttpResponse resp;
    success = http.HttpStr("POST",url,json,"utf-8","application/json",resp);
    if (success == false) {
        std::cout << http.lastErrorText() << "\r\n";
        return;
    }

    //  Examine the HTTP request header we just sent.
    std::cout << http.lastHeader() << "\r\n";

    //  Output:

    //  POST /echo_request_body.asp HTTP/1.1
    //  Host: chilkatsoft.com
    //  Accept: */*
    //  Accept-Encoding: gzip
    //  Content-Type: application/json
    //  Content-Length: 26
    }