Skip to content
Mercury13 edited this page Apr 5, 2015 · 44 revisions

Summary

ICurl is a wrapper for “easy” cURL interface.

Creation and destruction

To create ICurl, call CurlGet from Curl.Easy unit.

The object will be auto-destructed, when all links to it disappear.

Raw things

property Handle : TCurlHandle;

Returns cURL handle.

Set options

procedure SetOpt(aOption : TCurlOffOption; aData : TCurlOff);
procedure SetOpt(aOption : TCurlOption; aData : pointer);
procedure SetOpt(aOption : TCurlIntOption; aData : NativeUInt);
procedure SetOpt(aOption : TCurlIntOption; aData : boolean);
procedure SetOpt(aOption : TCurlStringOption; aData : PAnsiChar);
procedure SetOpt(aOption : TCurlStringOption; aData : RawByteString);
procedure SetOpt(aOption : TCurlStringOption; aData : UnicodeString);
procedure SetOpt(aOption : TCurlSlistOption; aData : PCurlSList);
          deprecated 'Use SetXXX instead: SetCustomHeaders, SetResolveList, etc.';
procedure SetOpt(aOption : TCurlPostOption; aData : PCurlHttpPost);
          deprecated 'Use SetForm or property Form instead.';

The rawmost version. Set an option.

Warning: Which options are copied and which are referenced, read cURL documentation. In 7.40.0 string options are copied, and you may freely reassign them. SList, HttpPost and other objects are referenced and thus they should not disappear until Perform ends.

procedure SetUrl(aData : PAnsiChar/RawByteString/UnicodeString);
procedure SetCaFile(aData : PAnsiChar/RawByteString/UnicodeString);

…and many-many more with string/bool/int parameters are equivalent to corresponding SetOpt.

procedure SetCustomHeaders(v : ICurlCustomSList);
procedure SetPostQuote(v : ICurlCustomSList);
procedure SetTelnetOptions(v : ICurlCustomSList);
procedure SetPreQuote(v : ICurlCustomSList);
procedure SetHttp200Aliases(v : ICurlCustomSList);
procedure SetMailRcpt(v : ICurlCustomSList);
procedure SetResolveList(v : ICurlCustomSList);
procedure SetProxyHeader(v : ICurlCustomSList);
procedure SetForm(v : ICurlCustomForm);

…and some more with ICurlCustomSList, ICurlCustomForm parameters copy reference to v. You are no longer allowed to change the object, but you can…

  • reassign the reference (ICurl keeps one reference inside, protecting them from destruction).
  • use the same object for another ICurl. The exception is ICurlCustomForm that involves streams; you should not assign it for two objects that operate simultaneously.
  • Warning: cURL is not Unicode-enabled. Thus, all file support is rewritten. It means: if the form involves the name of a disk file, it involves streams.
Clone this wiki locally