diff --git a/restemplate.lpr b/restemplate.lpr index cdce096..eb584a1 100644 --- a/restemplate.lpr +++ b/restemplate.lpr @@ -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;