PDFium Delphi Component Docs

FPdfCryptoHttpCurl 單元

單元: FPdfCryptoHttpCurl
Free Pascal libcurl HTTP(S) 傳輸後端,在非 Windows 目標上為 TPdfCryptoFetchSession 執行有界的 GET 與 POST 擷取

語法

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 是 FPdfCryptoHttp 線上擷取傳輸的非 Windows 半邊:TPdfCryptoFetchSession.Fetch 與 TPdfCryptoFetchSession.FetchPost 為 AIA 中繼憑證、CRL 發佈點與 OCSP 請求執行的每一次 HTTP(S) 擷取,在 Linux 與 macOS 上都經由 CryptoCurlGet 或 CryptoCurlPost;Windows 目標則走 FPdfCryptoHttp 內的 WinHttp 路徑。離開 Windows 時,FPdfCryptoHttp 的 CryptoHttpAvailable 就直接委派給 CryptoCurlAvailable

傳輸層是 libcurl,於執行階段綁定而非連結:Linux 上為 libcurl.so.4,macOS 上為 libcurl.4.dylib,FPC Windows 目標上為 libcurl.dll 或 libcurl-4.dll(此時擷取工作階段優先使用 WinHttp,不會有任何呼叫進到本單元)。模組必須同時回報 CURL_VERSION_ASYNCHDNS 與 CURL_VERSION_THREADSAFE 特性才會被接受,因為傳輸在毫秒級預算下抑制訊號執行,全域初始化器必須能與 worker 執行緒並存;其他 libcurl 一律回報為不存在,而不是勉強採用

同一個可用性檢查也把關時間戳記傳輸:FPdfTsaFpc 的 TsaHttpAvailable 除了自身進入點外還要求 CryptoCurlAvailable,因此一個通過特性檢查的 libcurl 模組同時支撐憑證擷取與 RFC 3161 請求

每條失敗路徑都回傳 False 而不擲出例外,Data 保持 nil,DownloadedBytes 記錄到目前為止收到的位元組數,讓擷取工作階段這類呼叫端可以把該數量計入共用的位元組預算。在 Delphi 下介面可以編譯,但三個函式都回傳 False,因為 Delphi 以 Windows 為目標,當地的後端是 FPdfCryptoHttp 的 WinHttp 路徑

函式

函式說明
CryptoCurlAvailable首次呼叫時在鎖的保護下一次載入 libcurl,唯有每個進入點都解析成功且模組回報非同步 DNS 與執行緒安全時才回傳 True
CryptoCurlGet執行有界的 HTTP 或 HTTPS GET;只在狀態確切為 200 且回應主體非空時成功,最多儲存 MaxBytes 位元組,並透過 DownloadedBytes 回報完整收到的數量
CryptoCurlPost以呼叫端的 ContentType 對非空 Body 執行有界的 HTTP 或 HTTPS POST;狀態、大小與位元組數規則與 GET 相同

備註

另請參閱

FPdfCryptoSsl, FPdfTsaFpc, FPdfTsa, TPdf.ValidatePadesTrust