* Fixed POST handling

* Added status info
This commit is contained in:
Andreas Schneider 2015-09-17 15:30:19 +02:00
parent 5689b89d90
commit 61f16f0278
1 changed files with 16 additions and 8 deletions

View File

@ -90,7 +90,7 @@ procedure ProcessCall(AURL: String);
var
s: String;
{$ifdef use_fclweb}
stream: TStream;
request, response: TStream;
{$endif}
begin
parser.Content := AURL;
@ -121,12 +121,19 @@ begin
{$endif}
{$ifdef use_fclweb}
stream := TMemoryStream.Create;
response := TMemoryStream.Create;
request := nil;
if content.Count > 0 then
content.SaveToStream(stream);
begin
request := TMemoryStream.Create;
content.SaveToStream(request);
request.Position := 0;
http.RequestBody := request;
end;
try
http.HTTPMethod(method, parser.Content, stream, []);
http.HTTPMethod(method, parser.Content, response, []);
except
on E: Exception do
begin
@ -137,17 +144,18 @@ begin
end;
writeln;
writeln('Status: ', http.ResponseStatusCode);
writeln('Status: ', http.ResponseStatusCode, ' (', http.ResponseStatusText, ')');
writeln;
writeln('Headers:');
for s in http.ResponseHeaders do
writeln(' ', s);
writeln;
stream.Position := 0;
content.LoadFromStream(stream);
response.Position := 0;
content.LoadFromStream(response);
writeln(content.Text);
stream.Free;
response.Free;
request.Free;
{$endif}
end;