views:

456

answers:

3

Here is a way to do an HTTP post using Indy, in one line, more or less:

Response := FIdHttp.Post(URL, StringStream);

Is there a function out there (function, not library) that allows the equivalent to be done using WinInet?

Preferably, a function that resembles this:

function PostUsingWinInet(const URL, Data :string; SSL :boolean) :string;

I do not want to reinvent the wheel and write my own wrapper function if one already exists.

Thanks!

A: 

TMS made one Wininet

Hugues Van Landeghem
A: 

Take a look at Synapse. Yes it is a library, but not a component one. It exposes classes and simple blocking functions that take the pain out of TCP/IP communication.

For instance, a small program which performs a post (ssl is supported btw):

uses
  httpsend;

var
  url : string;
  urldata : string;
  PostData : tMemoryStream;

begin
    :
  if HttpPostURL(URL, URLData, PostData) then
    Writeln('Sent');
end.
skamradt
+1  A: 

See this Stack Overflow question: How to send a HTTP POST Request in Delphi using WinInet api.

gabr
Thanks, but the function posted there is not self-contained; it relies on other functions the author wrote but did not post.
scrapdog
No, it is not. It uses only WinInet and Sysutils and maybe Windows (can't bother to check).
gabr