Sample code for 30+ languages & platforms
Unicode C

Add Additional Headers to HTTP Requests

See more HTTP Examples

Shows how to add a additional HTTP headers to HTTP requests.

Also see: Chilkat Http Default and Auto-Filled Headers

Chilkat Unicode C Downloads

Unicode C
#include <C_CkHttpW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkHttpW http;
    const wchar_t *responseBody;

    success = FALSE;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http = CkHttpW_Create();

    // Add a few request headers to be sent with all requests.
    CkHttpW_SetRequestHeader(http,L"X-CSRF-Token",L"Fetch");
    CkHttpW_SetRequestHeader(http,L"X-Example",L"123ABC");

    // The following request will be sent:

    // GET /helloWorld.txt HTTP/1.1
    // Host: chilkatsoft.com
    // Accept: */*
    // Accept-Encoding: gzip
    // X-CSRF-Token: Fetch
    // X-Example: 123ABC

    // Send an HTTP GET request and return the response body.
    responseBody = CkHttpW_quickGetStr(http,L"https://chilkatsoft.com/helloWorld.txt");
    wprintf(L"%s\n",responseBody);


    CkHttpW_Dispose(http);

    }