You are not logged in.
Pages: 1
I'm using 'SynCrtSock' unit and trying to simulate the data submit action occured on "Submit" button click.
This code uses the HTTP POST method to send a data to web server specified, but unfortunately, I couldn't
get the response body. Any idea?
var
fClient: TWinHTTP;
URI: TURI;
URL: RawUTf8;
FHeader, FData: SockString;
response: TMemoryStream;
begin
URL := 'http://www.clevercomponents.com/products/inetsuite/demos/serverformpost.asp';
URI.From(URL);
response := TMemoryStream.Create();
try
fClient := TWinHTTP.Create(URI.Server, URI.Port, false);
if fClient.Request('/products/inetsuite/demos/serverformpost.asp?insite=1', 'POST', 0, '',
'Name=Mr.AB&Birthdate=May+5%2C+1985&Account=12345',
'Content-Type: application/x-www-form-urlencoded', FHeader, FData) = 200 then begin
response.Write(fHeader[1], length(fHeader));
response.Position := 0;
Memo1.Lines.LoadFromStream(response);
end;
finally
response.Free;
fClient.Free;
end;
The expect result would be:
(*
Sent data:
Name = Mr.AB
Birthdate = May 5, 1985
Account = 12345
*)
How to get the response body?
Offline
No, the same response using stream.
I get the content (the source code) of the of the page.
view-source:http://www.clevercomponents.com/products/inetsuite/demos/serverformpost.asp
I would like to get this response:
Sent data:
Name = Mr.AB
Birthdate = May 5, 1985
Account = 12345
Offline
I've got the following response: http://pastebin.com/raw/wpzPZdfx (see the page is renderized)
The response using https://www.hurl.it/ is:
See the response picture See this image before page render
Offline
I have to use the inherited method Post instead of the Request... and it worked as expected! Thanks a lot.
Offline
Pages: 1