Sample code for 30+ languages & platforms
Delphi DLL

Transition from Http.PostUrlEncoded to Http.HttpReq

Provides 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

Chilkat Delphi DLL Downloads

Delphi DLL
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, HttpRequest, HttpResponse;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
url: PWideChar;
req: HCkHttpRequest;
responseObj: HCkHttpResponse;
req2: HCkHttpRequest;
resp: HCkHttpResponse;

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

// ...
// ...

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

// Results are contained in the HTTP response object...

CkHttp_Dispose(http);
CkHttpRequest_Dispose(req);
CkHttpRequest_Dispose(req2);
CkHttpResponse_Dispose(resp);

end;