Sample code for 30+ languages & platforms
Unicode C++

Transition from Http.PTextSb to Http.HttpSb

Provides instructions for replacing deprecated PTextSb method calls with HttpSb.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkHttpW.h>
#include <CkStringBuilderW.h>
#include <CkHttpResponseW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkHttpW http;

    const wchar_t *verb = L"PUT";
    const wchar_t *url = L"https://example.com/";
    CkStringBuilderW sbRequestBody;
    sbRequestBody.Append(L"This is the HTTP request body");
    const wchar_t *charset = L"utf-8";
    const wchar_t *contentType = L"text/plain";

    //  ------------------------------------------------------------------------
    //  The PTextSb method is deprecated:

    CkHttpResponseW *responseObj = http.PTextSb(verb,url,sbRequestBody,charset,contentType,false,false);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    //  ...
    //  ...

    delete responseObj;

    //  ------------------------------------------------------------------------
    //  Do the equivalent using HttpSb.
    //  Your application creates a new, empty HttpResponse object which is passed 
    //  in the last argument and filled upon success.

    CkHttpResponseW responseOut;
    success = http.HttpSb(verb,url,sbRequestBody,charset,contentType,responseOut);
    if (success == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }
    }