开发者

Simple wrapper function for WinInet post (in Delphi)

开发者 https://www.devze.com 2022-12-14 15:02 出处:网络
Here is a way to do an HTTP post using Indy, in one line, more or less: Response := FIdHttp.Post(URL, StringStream);

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!


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


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.
0

精彩评论

暂无评论...
验证码 换一张
取 消