![]() |
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
(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_CkHttp.h> #include <C_CkHttpRequest.h> #include <C_CkHttpResponse.h> void ChilkatSample(void) { HCkHttp http; const char *domain; int port; int tls; HCkHttpRequest req; HCkHttpResponse responseObj; HCkHttpResponse responseOut; BOOL success; http = CkHttp_Create(); domain = "example.com"; port = 443; tls = TRUE; req = CkHttpRequest_Create(); CkHttpRequest_putHttpVerb(req,"POST"); CkHttpRequest_putPath(req,"/some/path"); CkHttpRequest_putContentType(req,"application/x-www-form-urlencoded"); CkHttpRequest_AddParam(req,"firstName","Matt"); CkHttpRequest_AddParam(req,"lastName","Smith"); // ------------------------------------------------------------------------ // The SynchronousRequest method is deprecated: responseObj = CkHttp_SynchronousRequest(http,domain,port,tls,req); if (CkHttp_getLastMethodSuccess(http) == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkHttpRequest_Dispose(req); return; } // ... // ... CkHttpResponse_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 = CkHttpResponse_Create(); success = CkHttp_HttpSReq(http,domain,port,tls,req,responseOut); if (success == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkHttpRequest_Dispose(req); CkHttpResponse_Dispose(responseOut); return; } CkHttp_Dispose(http); CkHttpRequest_Dispose(req); CkHttpResponse_Dispose(responseOut); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.