编辑:我需要在基于 delphi 的应用程序脚本引擎中使用 TTCPBlocksocket 建立 POST 连接。
如何告诉突触 Header 结束和 body(post 元素)开始?或者我应该用不同的数据包发送它们吗?谢谢!
begin
Head:= TStringList.Create;
Head.Add('GET / HTTP/1.1');
Head.Add('Accept: */*');
Head.Add('Accept-Encoding: gzip, deflate');
Head.Add('Host: www.google.ru');
Head.Add('Connection: Keep-Alive');
Head.Add(#10#13);
body:= TStringList.Create;
body.Add('username=adr');
body.Add('login=adr');
body.Add('password=adr');
body.Add('r_password=adr');
body.Add('submit=register');
Socket:= TTCPBlockSocket.Create;
Socket.connect('108.167.137.28', '80');
if (Socket.LastError <> 0) then Exit;
Socket.SendString(Head.Text);
最佳答案
由本主题解决 - How are parameters sent in an HTTP POST request?
The content is put after the HTTP headers. The format of an HTTP POST is to have the HTTP headers, followed by a blank line, followed by the request body. The POST variables are stored as key-value pairs in the body.
关于http - Delphi 突触 TTCPBlockSocket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39451779/