![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) Transition from Http.SynchronousRequest to Http.HttpSReqProvides instructions for replacing deprecated SynchronousRequest method calls with HttpSReq. Note: This example requires Chilkat v11.0.0 or greater.
#include <C_CkHttpW.h> #include <C_CkHttpRequestW.h> #include <C_CkHttpResponseW.h> void ChilkatSample(void) { HCkHttpW http; const wchar_t *domain; int port; int tls; HCkHttpRequestW req; HCkHttpResponseW responseObj; HCkHttpResponseW responseOut; BOOL success; http = CkHttpW_Create(); domain = L"example.com"; port = 443; tls = TRUE; req = CkHttpRequestW_Create(); CkHttpRequestW_putHttpVerb(req,L"POST"); CkHttpRequestW_putPath(req,L"/some/path"); CkHttpRequestW_putContentType(req,L"application/x-www-form-urlencoded"); CkHttpRequestW_AddParam(req,L"firstName",L"Matt"); CkHttpRequestW_AddParam(req,L"lastName",L"Smith"); // ------------------------------------------------------------------------ // The SynchronousRequest method is deprecated: responseObj = CkHttpW_SynchronousRequest(http,domain,port,tls,req); if (CkHttpW_getLastMethodSuccess(http) == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkHttpRequestW_Dispose(req); return; } // ... // ... CkHttpResponseW_Dispose(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. responseOut = CkHttpResponseW_Create(); success = CkHttpW_HttpSReq(http,domain,port,tls,req,responseOut); if (success == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkHttpRequestW_Dispose(req); CkHttpResponseW_Dispose(responseOut); return; } CkHttpW_Dispose(http); CkHttpRequestW_Dispose(req); CkHttpResponseW_Dispose(responseOut); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.