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