Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Parse a URL into its Component Parts
See more HTTP Examples
Demonstrates how to parse a URL into it's component parts.Chilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Url;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
url: TUrl;
urlStr: string;
begin
success := False;
url := TUrl.Create;
urlStr := 'https://www.amazon.com/Anarchy-State-Utopia-Robert-Nozick/dp/0465051006/ref=sr_1_1?s=books&ie=UTF8&qid=1430344305&sr=1-1&keywords=nozick#frag123';
success := url.ParseUrl(urlStr);
// Assume success..
WriteLn('URL: ' + urlStr);
WriteLn('Host: ' + url.Host);
WriteLn('Port: ' + url.Port);
WriteLn('HostType: ' + url.HostType);
WriteLn('Ssl: ' + url.Ssl);
WriteLn('Path: ' + url.Path);
WriteLn('Query: ' + url.Query);
WriteLn('Frag: ' + url.Frag);
WriteLn('----');
urlStr := 'http://matt:secret@www.chilkatsoft.com:8080/somepath.asp?test=123&size=2';
success := url.ParseUrl(urlStr);
// Assume success..
WriteLn('URL: ' + urlStr);
WriteLn('Host: ' + url.Host);
WriteLn('Port: ' + url.Port);
WriteLn('HostType: ' + url.HostType);
WriteLn('Ssl: ' + url.Ssl);
WriteLn('Login: ' + url.Login);
WriteLn('Password: ' + url.Password);
WriteLn('Path: ' + url.Path);
WriteLn('Query: ' + url.Query);
WriteLn('Frag: ' + url.Frag);
url.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.