-




REQUEST_METHOD. POST ( ). , . CONTENT_LENGTH. ( , , ). FIELD=VALUE '&'. : AUTHOR="Bob_Swart"&. , , AUTHOR :

var

Data: String;

function Value(Const Field: ShortString): ShortString;

var i: Integer;

begin

Result := '';

i := Pos(Field+'=',Data);

if i = 0 then

begin

Inc(i,Length(Field)+1);

while Data[i] <> '&' do

begin

Result := Result + Data[i];

Inc(i)

end

end

end {Value};

TBDosEnvironment, .

{$APPTYPE CONSOLE}

var

Data: String;

ContentLength,i,j: Integer;

begin

writeln('HTTP/1.0 200 OK');

writeln('SERVER: Dr.Bob''s Intranet WebServer 1.0');

writeln('CONTENT-TYPE: TEXT/HTML');

writeln;

writeln('<HTML>');

writeln('<BODY>');

writeln('<I>Generated by Dr.Bob''s CGI-Expert on </I>',DateTimeToStr(Now));

with TBDosEnvironment.Create(nil) do

begin

for i := 0 to Pred(DosEnvCount) do

begin

if Pos('REQUEST_METHOD',DosEnvList[i]) 0 then

begin

Data := DosEnvList[i];

Delete(Data,1,Pos('=',Data))

end

end;

if Data = 'POST' then

begin

ContentLength := StrToInt(GetDosEnvStr('CONTENT_LENGTH'));

SetLength(Data,ContentLength+1);

j := 0;

for i:=1 to ContentLength do

begin

Inc(j);

read(Data[j]);

end;

Data[j+1] := '&';

{ now call Value or ValueAsInteger to obtain individual values }

end;

, "writeln" , , , , TEXT/HTML.