Sample code for 30+ languages & platforms
PureBasic

Inspect HTTP Request Header

Demonstrates the LastHeader property.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttp.pb"

Procedure ChilkatExample()

    success.i = 0

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    url.s = "https://chilkatsoft.com/echo_request_body.asp"
    json.s = "{" + Chr(34) + "greeting" + Chr(34) + ":" + Chr(34) + "Hello World" + Chr(34) + "}"

    ; Send a POST with the JSON in the HTTP request body.
    resp.i = CkHttpResponse::ckCreate()
    If resp.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkHttp::ckHttpStr(http,"POST",url,json,"utf-8","application/json",resp)
    If success = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkHttpResponse::ckDispose(resp)
        ProcedureReturn
    EndIf

    ; Examine the HTTP request header we just sent.
    Debug CkHttp::ckLastHeader(http)

    ; Output:

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


    CkHttp::ckDispose(http)
    CkHttpResponse::ckDispose(resp)


    ProcedureReturn
EndProcedure