Delphi synapse TTCPBlockSocket

1.1k Views Asked by At

EDIT: I need to make a POST connection with TTCPBlocksocket inside a delphi based applications script engine.

How to tell synapse where Header ends and body (post elements) starts? Or should i send them in different packets? Thank you !

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);    
1

There are 1 best solutions below

0
Tomas Randomas On

Solved by this topic - 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.