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

Transition from Http.PutText to Http.HttpStr

Provides instructions for replacing deprecated PutText method calls with HttpStr.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkHttpW.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/";
    const wchar_t *textData = L"This is the HTTP request body";
    const wchar_t *charset = L"utf-8";
    const wchar_t *contentType = L"text/plain";

    //  ------------------------------------------------------------------------
    //  The PutText method is deprecated:

    const wchar_t *responseBody = http.putText(url,textData,charset,contentType,false,false);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    //  ...
    //  ...

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

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

    responseBody = responseOut.bodyStr();
    }