0

I'm using the Synapse Library and today i want to know how i can send strings via post request to a webserver which uses ssl.

Here is my existing code:

procedure TForm1.syn;
var
  Position: Integer;
  URL, Params: string;
  Response: TMemoryStream;
  SynHttp: THTTPSend;
  Socket: TTCPBlockSocket;
begin
  Response := TMemoryStream.Create;
  Socket := TTCPBlockSocket.Create;
  SynHttp := THTTPSend.Create;
  URL := 'https://gitlab.com';

  try
       Position := Pos('https', URL);
       if Position <> 0 then begin //
         SynHttp.Sock.CreateWithSSL(TSSLOpenSSL);
         SynHttp.Sock.SSLDoConnect;
         // Here i wanna do a Postrequest to the ssl webserver
       end
       else
       // Here i wanna do a Postrequest to the non-ssl webserver
  finally
    Socket.Free;
    Response.Free;
    SynHttp.Free;
  end;
end;

I wanna connect to a ssl webserver and if i connected successfully i want to perform a POST to the webserver.

Hidden
  • 3,598
  • 4
  • 34
  • 57

1 Answers1

1

you can use the

SendString

routine, as from their example Using Tcp With Ssl On Tcp Client

LE: from the comments OP posts I believe a good start will be this question

How to establish a secure connection by using Synapse?

Community
  • 1
  • 1
RBA
  • 12,337
  • 16
  • 79
  • 126
  • Is it possible to send a string like this? Params := 'parameter1=' + EncodeURLElement('data1') + '&' + 'parameter2=' + EncodeURLElement('data2'); – Hidden Jul 25 '13 at 08:51
  • That depends on what you need to request from your server. I answered to your question. This is another question – RBA Jul 25 '13 at 08:53