Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v11.0.0+

Transition from Http.SynchronousRequest to Http.HttpSReq

Provides instructions for replacing deprecated SynchronousRequest method calls with HttpSReq.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
http: HCkHttp;
domain: PWideChar;
port: Integer;
tls: Integer;
req: HCkHttpRequest;
responseObj: HCkHttpResponse;
responseOut: HCkHttpResponse;

begin
success := False;

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) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

//  ...
//  ...

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) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

CkHttp_Dispose(http);
CkHttpRequest_Dispose(req);
CkHttpResponse_Dispose(responseOut);