PDFium Delphi Component Docs

FPdfCryptoHttpCurl unit

Unit: FPdfCryptoHttpCurl
Free Pascal libcurl HTTP(S) transport backend carrying out the bounded GET and POST retrievals that TPdfCryptoFetchSession relies on away from Windows

Syntax

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;

Description

FPdfCryptoHttpCurl supplies the non-Windows half of the online retrieval transport in FPdfCryptoHttp. On Linux and macOS, each HTTP(S) fetch that TPdfCryptoFetchSession.Fetch and TPdfCryptoFetchSession.FetchPost make for AIA intermediates, CRL distribution points and OCSP requests travels through CryptoCurlGet or CryptoCurlPost; Windows targets instead take the WinHttp path inside FPdfCryptoHttp, where CryptoHttpAvailable simply hands over to CryptoCurlAvailable away from Windows

libcurl is bound by name at run time rather than linked in: libcurl.so.4 on Linux, libcurl.4.dylib on macOS, and libcurl.dll or libcurl-4.dll on FPC Windows targets — although there the fetch session prefers WinHttp and nothing calls into this unit. A module only counts when it reports both the CURL_VERSION_ASYNCHDNS and CURL_VERSION_THREADSAFE features, because transfers run with signals suppressed inside a millisecond-level budget and the global initialiser has to be safe alongside worker threads; any other libcurl is reported as missing rather than used

The timestamp transport is gated by the same availability check: TsaHttpAvailable in FPdfTsaFpc demands CryptoCurlAvailable on top of its own entry points, so a single feature-qualified libcurl module backs certificate retrieval and RFC 3161 requests alike

No failure path raises an exception: every one returns False, leaves Data nil and records in DownloadedBytes how many bytes arrived, so a caller such as the fetch session can charge that count against its shared byte budget. Under Delphi the interface compiles yet all three functions return False, because Delphi targets Windows, where the WinHttp path in FPdfCryptoHttp serves as the backend

Functions

FunctionDescription
CryptoCurlAvailableBinds libcurl once under a lock on the first call, returning True only when every entry point has resolved and the module reports asynchronous DNS and thread safety
CryptoCurlGetRuns a bounded HTTP or HTTPS GET that succeeds only with an exact status 200 and a non-empty body, keeps at most MaxBytes bytes and reports the complete received count via DownloadedBytes
CryptoCurlPostRuns a bounded HTTP or HTTPS POST for a non-empty Body using the caller's ContentType; the GET's status, size and byte-count rules apply here too

Remarks

See Also

FPdfCryptoSsl, FPdfTsaFpc, FPdfTsa, TPdf.ValidatePadesTrust