PDFium Delphi Component Docs

FPdfCryptoHttpCurl unit

Unit: FPdfCryptoHttpCurl
Free Pascal libcurl HTTP(S) transport backend that performs the bounded GET and POST retrievals behind TPdfCryptoFetchSession on non-Windows targets

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

Functions

FunctionDescription
CryptoCurlAvailableLoads 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
CryptoCurlGetPerforms 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
CryptoCurlPostPerforms 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

Remarks

See Also

FPdfCryptoSsl, FPdfTsaFpc, FPdfTsa, TPdf.ValidatePadesTrust