Delphi DLL
Delphi DLL
Transition from Http.PutText to Http.HttpStr
Provides instructions for replacing deprecated PutText method calls with HttpStr.Chilkat Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, HttpResponse, Http;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
verb: PWideChar;
url: PWideChar;
textData: PWideChar;
charset: PWideChar;
contentType: PWideChar;
responseBody: PWideChar;
responseOut: HCkHttpResponse;
begin
success := False;
http := CkHttp_Create();
verb := 'PUT';
url := 'https://example.com/';
textData := 'This is the HTTP request body';
charset := 'utf-8';
contentType := 'text/plain';
// ------------------------------------------------------------------------
// The PutText method is deprecated:
responseBody := CkHttp__putText(http,url,textData,charset,contentType,False,False);
if (CkHttp_getLastMethodSuccess(http) = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
// ...
// ...
// ------------------------------------------------------------------------
// Do the equivalent using HttpStr.
// Your application creates a new, empty HttpResponse object which is passed
// in the last argument and filled upon success.
responseOut := CkHttpResponse_Create();
success := CkHttp_HttpStr(http,verb,url,textData,charset,contentType,responseOut);
if (success = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
responseBody := CkHttpResponse__bodyStr(responseOut);
CkHttp_Dispose(http);
CkHttpResponse_Dispose(responseOut);
end;