Unicode C++
Unicode C++
Transition from Http.SynchronousRequest to Http.HttpSReq
Provides instructions for replacing deprecated SynchronousRequest method calls with HttpSReq.Chilkat Unicode C++ Downloads
#include <CkHttpW.h>
#include <CkHttpRequestW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
bool success = false;
CkHttpW http;
const wchar_t *domain = L"example.com";
int port = 443;
int tls = true;
CkHttpRequestW req;
req.put_HttpVerb(L"POST");
req.put_Path(L"/some/path");
req.put_ContentType(L"application/x-www-form-urlencoded");
req.AddParam(L"firstName",L"Matt");
req.AddParam(L"lastName",L"Smith");
// ------------------------------------------------------------------------
// The SynchronousRequest method is deprecated:
CkHttpResponseW *responseObj = http.SynchronousRequest(domain,port,tls,req);
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
// ...
// ...
delete responseObj;
// ------------------------------------------------------------------------
// Do the equivalent using HttpSReq.
// Your application creates a new, empty HttpResponse object which is passed
// in the last argument and filled upon success.
CkHttpResponseW responseOut;
success = http.HttpSReq(domain,port,tls,req,responseOut);
if (success == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
}