Unicode C
Unicode C
Inspect HTTP Request Header
Demonstrates theLastHeader property.
Chilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
const wchar_t *url;
const wchar_t *json;
HCkHttpResponseW resp;
success = FALSE;
http = CkHttpW_Create();
url = L"https://chilkatsoft.com/echo_request_body.asp";
json = L"{\"greeting\":\"Hello World\"}";
// Send a POST with the JSON in the HTTP request body.
resp = CkHttpResponseW_Create();
success = CkHttpW_HttpStr(http,L"POST",url,json,L"utf-8",L"application/json",resp);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkHttpResponseW_Dispose(resp);
return;
}
// Examine the HTTP request header we just sent.
wprintf(L"%s\n",CkHttpW_lastHeader(http));
// Output:
// POST /echo_request_body.asp HTTP/1.1
// Host: chilkatsoft.com
// Accept: */*
// Accept-Encoding: gzip
// Content-Type: application/json
// Content-Length: 26
CkHttpW_Dispose(http);
CkHttpResponseW_Dispose(resp);
}