Delphi DLL Requires Chilkat v11.0.0+
Delphi DLL
Transition from Http.PTextSb to Http.HttpSb
Provides instructions for replacing deprecated PTextSb method calls with HttpSb.Chilkat Delphi DLL Downloads
var
success: Boolean;
http: HCkHttp;
verb: PWideChar;
url: PWideChar;
sbRequestBody: HCkStringBuilder;
charset: PWideChar;
contentType: PWideChar;
responseObj: HCkHttpResponse;
responseOut: HCkHttpResponse;
begin
success := False;
http := CkHttp_Create();
verb := 'PUT';
url := 'https://example.com/';
sbRequestBody := CkStringBuilder_Create();
CkStringBuilder_Append(sbRequestBody,'This is the HTTP request body');
charset := 'utf-8';
contentType := 'text/plain';
// ------------------------------------------------------------------------
// The PTextSb method is deprecated:
responseObj := CkHttp_PTextSb(http,verb,url,sbRequestBody,charset,contentType,False,False);
if (CkHttp_getLastMethodSuccess(http) = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
// ...
// ...
CkHttpResponse_Dispose(responseObj);
// ------------------------------------------------------------------------
// Do the equivalent using HttpSb.
// Your application creates a new, empty HttpResponse object which is passed
// in the last argument and filled upon success.
responseOut := CkHttpResponse_Create();
success := CkHttp_HttpSb(http,verb,url,sbRequestBody,charset,contentType,responseOut);
if (success = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbRequestBody);
CkHttpResponse_Dispose(responseOut);