//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.573
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
uses System.Net, System.IO, System.Text;
type
TArrayOfString = array of string;
ClientGET = class
strict private
class var
bShow: Boolean;
public
class procedure Main(args: TArrayOfString); virtual;static;
class procedure showusage; virtual;static;
class procedure getPage(
url: string); virtual;static;
end;
implementation
{$AUTOBOX ON}
{$HINTS OFF}
{$WARNINGS OFF}
class procedure ClientGET.Main(args: TArrayOfString);
begin
if (args.Length < 1) then
showusage
else
begin
if (args.Length = 2) then
bShow := False
else
bShow := True;
getPage(args[0]);
end;
Console.WriteLine;
Console.WriteLine('Drcken Sie die EINGABETASTE, um fortzufahren...');
Console.ReadLine;
end;
class procedure ClientGET.showusage;
begin
Console.WriteLine('Versucht, einen
URL abzurufen');
Console.WriteLine(''#13#10'Verwendung:');
Console.WriteLine('ClientGET
URL');
Console.WriteLine('Beispiele:');
Console.WriteLine('ClientGET http://www.microsoft.com/net/');
end;
class procedure ClientGET.getPage(
url: string);
type
TArrayOfArrayOfChar = array of array of Char;
TArrayOfChar = array of Char;
var
str: string;
count: Integer;
read: TArrayOfChar;
sr: StreamReader;
encode: Encoding;
ReceiveStream: Stream;
req: WebRequest;
_result: WebResponse;
begin
_result := nil;
try
try
req := WebRequest.Create(
url);
_result := req.GetResponse;
ReceiveStream := _result.GetResponseStream;
encode := System.Text.Encoding.GetEncoding('utf-8');
sr := StreamReader.Create(ReceiveStream, encode);
Console.WriteLine(''#13#10'Antwortstream erhalten');
if bShow then
begin
read := New(TArrayOfArrayOfChar, 256);
count := sr.Read(read, 0, 256);
Console.WriteLine('
HTML...'#13#10);
while (count > 0) do
begin
str := string.Create(read, 0, count);
Console.Write(str);
count := sr.Read(read, 0, 256);
end;
Console.WriteLine('');
end;
except
on
Exception do
Console.WriteLine(''#13#10'Der angeforderte
URI konnte nicht gefunden werden oder ist ungltig.');
end;
finally
if (_result <> nil) then
_result.Close;
end;
end;