![]() |
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.PostUrlEncoded to Http.HttpReqProvides instructions for replacing deprecated PostUrlEncoded method calls with HttpReq. Sends the following raw HTTP request: POST /echoPost.asp HTTP/1.1 Host: www.chilkatsoft.com Content-Type: application/x-www-form-urlencoded Content-Length: 50 company=example&ip=111.111.111.111&url=example.com 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) { BOOL success; HCkHttp http; const char *url; HCkHttpRequest req; HCkHttpResponse responseObj; HCkHttpRequest req2; HCkHttpResponse resp; success = FALSE; http = CkHttp_Create(); url = "https://www.chilkatsoft.com/echoPost.asp"; req = CkHttpRequest_Create(); CkHttpRequest_AddParam(req,"company","example"); CkHttpRequest_AddParam(req,"ip","111.111.111.111"); CkHttpRequest_AddParam(req,"url","example.com"); // ------------------------------------------------------------------------ // The PostUrlEncoded method is deprecated: responseObj = CkHttp_PostUrlEncoded(http,url,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 HttpReq. // Your application creates a new, empty HttpResponse object which is passed // in the last argument and filled upon success. req2 = CkHttpRequest_Create(); CkHttpRequest_AddParam(req2,"company","example"); CkHttpRequest_AddParam(req2,"ip","111.111.111.111"); CkHttpRequest_AddParam(req2,"url","example.com"); CkHttpRequest_putHttpVerb(req2,"POST"); CkHttpRequest_putContentType(req2,"application/x-www-form-urlencoded"); resp = CkHttpResponse_Create(); success = CkHttp_HttpReq(http,url,req2,resp); if (success == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkHttpRequest_Dispose(req); CkHttpRequest_Dispose(req2); CkHttpResponse_Dispose(resp); return; } // Results are contained in the HTTP response object... CkHttp_Dispose(http); CkHttpRequest_Dispose(req); CkHttpRequest_Dispose(req2); CkHttpResponse_Dispose(resp); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.