Sample code for 30+ languages & platforms
Delphi DLL

Get Response Header for Method that does not Return HttpResponse Object

Demonstrates how to get the response header and individual response header fields for a method that does not return an HTTP response object. (If a method returns an HHTTP response object, then the response header information should be obtained from the response object.)

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, Mime, Http;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
strHtml: PWideChar;
mime: HCkMime;

begin
success := False;

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

http := CkHttp_Create();

strHtml := CkHttp__quickGetStr(http,'https://www.duckduckgo.com/');
if (CkHttp_getLastMethodSuccess(http) = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

Memo1.Lines.Add(CkHttp__lastResponseHeader(http));

// Here's a sample HTTP response header:

// Server: nginx
// Date: Wed, 30 Sep 2020 13:13:02 GMT
// Content-Type: text/html; charset=UTF-8
// Transfer-Encoding: chunked
// Connection: keep-alive
// Vary: Accept-Encoding
// ETag: W/"5f7371f4-1683"
// Strict-Transport-Security: max-age=31536000
// X-Frame-Options: SAMEORIGIN
// Content-Security-Policy: default-src https: blob: data: 'unsafe-inline' 'unsafe-eval'; frame-ancestors 'self'
// X-XSS-Protection: 1;mode=block
// X-Content-Type-Options: nosniff
// Referrer-Policy: origin
// Expect-CT: max-age=0
// Expires: Wed, 30 Sep 2020 13:13:01 GMT
// Cache-Control: no-cache
// Content-Encoding: gzip

// We can load it into a Chilkat MIME object to get header field values:
mime := CkMime_Create();

success := CkMime_LoadMime(mime,CkHttp__lastResponseHeader(http));
if (success = False) then
  begin
    Memo1.Lines.Add(CkMime__lastErrorText(mime));
    Exit;
  end;

// Get MIME header field values using Chilkat MIME...
Memo1.Lines.Add('----');
Memo1.Lines.Add('ETag: ' + CkMime__getHeaderField(mime,'ETag'));

CkHttp_Dispose(http);
CkMime_Dispose(mime);

end;