-
Notifications
You must be signed in to change notification settings - Fork 23
1) How was curl4delphi created?
2) But there’s Indy in Delphi…
Curl4delphi was created for one private project that coped with a REST service. “Too clever” Indy “managed” to fail without apparent reason and (in older versions) hid 400/403 bodies without a chance to retrieve them (the service is rather verbose and leaves a clue what’s wrong in “bad request”). So curl.exe
became a temporary solution for failed requests (those which didn’t fail still used Indy). In a weekend I wrote a wrapper for libcurl that later evolved into curl4delphi.
Of course, I didn’t discard Indy just for political reasons, and HMAC authentication for that service still uses Indy.
Many of us use obsolete Delphi, as it makes smaller EXEs. That Indy does not even connect to some HTTPS sites.
Why does curl_formadd
work with PAnsiChar
, not with untyped pointers?
For easier passing of strings. See RawHttp\APlusB_Post
example.
1) Why no ICurlForm.AddNe
and so on?
2) Why don’t you localize ICurlForm
errors?
Because only one of them — not enough memory — is a programmer-independent runtime problem. The rest are programming overlooks.
In some languages (Java) there is a concept named checked exceptions. It divides exceptions into three types: programmer’s overlooks, fixable fails and unfixable fails, and only fixable fails are checked. Regarding overlooks: every line that contains division can divide by 0, every line that allocates something can run out of memory, every line that uses operator[]
can exceed the range. Such exceptions can not be checked by definition — and if they occur, the program is probably in a great trouble. All ICurlForm
errors belong to this type, and, in my opinion, there’s no point to localize them.
(Well, checked exceptions proved wrong, but why: 1) Callbacks may throw every possible exception, and the right place to handle them is outside calling function — so both function and callback throws Exception
, and empty try
even if no exceptions involved; 2) The same error, e.g. no file, can be fixable in desktop and unfixable in Web. These reasons have nothing to do with overlooks.)
Why does ICurl.Clone
keep input/output/header streams in such a state?
Because streams are one-per-object. You should anyway recreate and replace everything that contains streams. Warning: including ICurlForm
with file uploads — as cURL does not support Unicode, I’m forced to emulate it via TFileStream
.
But cacert.pem
can be at Unicode path…
A dependent library, OpenSSL, supports Unicode. cURL itself does not.