TPdfCryptoFetchSession on non-Windows targets
function CryptoCurlAvailable: Boolean;
function CryptoCurlGet(const Url: AnsiString; TimeoutMs: Cardinal;
MaxBytes: Integer; out Data: TBytes; out DownloadedBytes: Integer;
const ConnectTo: AnsiString = ''): Boolean;
function CryptoCurlPost(const Url: AnsiString; const Body: TBytes;
const ContentType: AnsiString; TimeoutMs: Cardinal; MaxBytes: Integer;
out Data: TBytes; out DownloadedBytes: Integer;
const ConnectTo: AnsiString = ''): Boolean;
FPdfCryptoHttpCurl is the non-Windows half of the online retrieval transport in FPdfCryptoHttp: every HTTP(S) fetch that TPdfCryptoFetchSession.Fetch and TPdfCryptoFetchSession.FetchPost perform for AIA intermediates, CRL distribution points and OCSP requests goes through CryptoCurlGet or CryptoCurlPost on Linux and macOS, while Windows targets use the WinHttp path inside FPdfCryptoHttp. CryptoHttpAvailable in FPdfCryptoHttp simply delegates to CryptoCurlAvailable away from Windows
The transport is libcurl, bound at run time rather than linked: libcurl.so.4 on Linux, libcurl.4.dylib on macOS and libcurl.dll or libcurl-4.dll on FPC Windows targets, where the fetch session prefers WinHttp and nothing calls into this unit. A module is accepted only when it reports both the CURL_VERSION_ASYNCHDNS and CURL_VERSION_THREADSAFE features, because transfers run with signals suppressed under a millisecond budget and the global initializer must be safe beside worker threads; any other libcurl is reported as absent instead of used
The same availability check gates the timestamp transport: TsaHttpAvailable in FPdfTsaFpc requires CryptoCurlAvailable in addition to its own entry points, so one feature-qualified libcurl module backs both certificate retrieval and RFC 3161 requests
Every failure path returns False rather than raising, leaving Data nil and DownloadedBytes holding the byte count received so far, so a caller such as the fetch session can charge that count against its shared byte budget. Under Delphi the interface compiles but all three functions return False, because Delphi targets Windows and the WinHttp path in FPdfCryptoHttp is the backend there
| Function | Description |
|---|---|
CryptoCurlAvailable | Loads libcurl once under a lock on first call and returns True only when every entry point resolved and the module reports asynchronous DNS and thread safety |
CryptoCurlGet | Performs a bounded HTTP or HTTPS GET; succeeds only on an exact status 200 with a non-empty body, stores at most MaxBytes bytes and reports the full received count through DownloadedBytes |
CryptoCurlPost | Performs a bounded HTTP or HTTPS POST of a non-empty Body with the caller's ContentType; the same status, size and byte-count rules as the GET apply |
http and https URLs of at most 8192 bytes are accepted, and a URL is rejected when it contains control characters, a backslash, a fragment or @ userinfo in the authority; redirects are never followed, the protocol set is fixed to HTTP and HTTPS, and proxying, HTTP authentication and proxy authentication are all disabledTimeoutMs is a whole-call budget measured from routine entry and split into connect and total libcurl timeouts, so first-call binding time counts against itMaxBytes is truncated to the limit and aborts the transfer; the caller still learns the true size through DownloadedBytesCryptoCurlAvailable call and the module stays mapped until process exit, because asynchronous resolver threads may outlive a global cleanupFPdfCryptoHttp and are described with TPdfCryptoFetchSession