Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/HTTP/Pascal/http-1.pas
Normal file
16
Task/HTTP/Pascal/http-1.pas
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{$mode objfpc}{$H+}
|
||||
uses fphttpclient;
|
||||
|
||||
var
|
||||
s: string;
|
||||
hc: tfphttpclient;
|
||||
|
||||
begin
|
||||
hc := tfphttpclient.create(nil);
|
||||
try
|
||||
s := hc.get('http://www.example.com')
|
||||
finally
|
||||
hc.free
|
||||
end;
|
||||
writeln(s)
|
||||
end.
|
||||
47
Task/HTTP/Pascal/http-2.pas
Normal file
47
Task/HTTP/Pascal/http-2.pas
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
program http;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
{$DEFINE DEBUG}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Classes, httpsend; // Synapse httpsend class
|
||||
{$R *.res}
|
||||
|
||||
var
|
||||
Response: TStrings;
|
||||
HTTPObj: THTTPSend;
|
||||
|
||||
begin
|
||||
HTTPObj := THTTPSend.Create;
|
||||
try
|
||||
{ Stringlist object to capture HTML returned
|
||||
from URL }
|
||||
Response := TStringList.Create;
|
||||
try
|
||||
if HTTPObj.HTTPMethod('GET','http://wiki.lazarus.freepascal.org/Synapse') then
|
||||
begin
|
||||
{ Load HTTP Document into Stringlist }
|
||||
Response.LoadFromStream(HTTPObj.Document);
|
||||
{ Write the response to the console window }
|
||||
Writeln(Response.Text);
|
||||
end
|
||||
else
|
||||
Writeln('Error retrieving data');
|
||||
|
||||
finally
|
||||
Response.Free;
|
||||
end;
|
||||
|
||||
finally
|
||||
HTTPObj.Free;
|
||||
end;
|
||||
|
||||
// Keep console window open
|
||||
Readln;
|
||||
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue