Sample code for 30+ languages & platforms
Delphi DLL

Example: Http.ExtractMetaRefreshUrl method

Demonstrates the ExtractMetaRefreshUrl method.

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

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
sb: HCkStringBuilder;
bCrlf: Boolean;
url: PWideChar;

begin
success := False;

http := CkHttp_Create();

// Sample HTML with a META refresh.

// <!DOCTYPE html>
// <html lang="en">
// <head>
//   <meta charset="utf-8" />
//   <meta http-equiv="refresh" content="5; url=https://example.com" />
//   <title>Meta Refresh Redirect</title>
// </head>
// <body>
//   <p>Redirecting to example.com in 5 seconds�</p>
// </body>
// </html>

sb := CkStringBuilder_Create();
bCrlf := True;
CkStringBuilder_AppendLine(sb,'<!DOCTYPE html>',bCrlf);
CkStringBuilder_AppendLine(sb,'<html lang="en">',bCrlf);
CkStringBuilder_AppendLine(sb,'<head>',bCrlf);
CkStringBuilder_AppendLine(sb,'  <meta charset="utf-8" />',bCrlf);
CkStringBuilder_AppendLine(sb,'  <meta http-equiv="refresh" content="5; url=https://example.com" />',bCrlf);
CkStringBuilder_AppendLine(sb,'  <title>Meta Refresh Redirect</title>',bCrlf);
CkStringBuilder_AppendLine(sb,'</head>',bCrlf);
CkStringBuilder_AppendLine(sb,'<body>',bCrlf);
CkStringBuilder_AppendLine(sb,'  <p>Redirecting to example.com in 5 seconds�</p>',bCrlf);
CkStringBuilder_AppendLine(sb,'</body>',bCrlf);
CkStringBuilder_AppendLine(sb,'</html>',bCrlf);

url := CkHttp__extractMetaRefreshUrl(http,CkStringBuilder__getAsString(sb));
if (CkHttp_getLastMethodSuccess(http) = False) then
  begin
    Memo1.Lines.Add('The HTML has no META refresh tag.');
  end
else
  begin
    Memo1.Lines.Add('META refresh URL: ' + url);
  end;

CkHttp_Dispose(http);
CkStringBuilder_Dispose(sb);

end;