a-blog cms PHP API Reference

CurlHttpClient
in package
implements ClientInterface, PinnableClientInterface

DNS ピンニングに対応した cURL ベースの PSR-18 クライアント。

Why not: embed/embed 同梱の CurlClient を使わないのは、CURLOPT_RESOLVE を渡す口が無く、 SSRF ガードが検証した IP と実接続の IP を一致させられない(DNS リバインディングによる TOCTOU が残る)ため。リダイレクトの自動追従は常に無効で、追従はホップごとに検証する SsrfGuardedClient 側が担う。

Table of Contents

Interfaces

ClientInterface
PinnableClientInterface
接続先 IP アドレスを固定(DNS ピンニング)して送信できる HTTP クライアント。

Properties

$responseFactory  : ResponseFactoryInterface
$settings  : array{ssl_verify_peer?: bool, ssl_verify_host?: int, connect_timeout?: int, timeout?: int, cookies_path?: string}
リクエスト設定(embed/embed の CurlClient と同じキー名を使う)
$streamFactory  : StreamFactoryInterface

Methods

__construct()  : mixed
buildCurlOptions()  : array<int, mixed>
cURL に渡すオプションを組み立てる。
sendRequest()  : ResponseInterface
sendRequestPinned()  : ResponseInterface
接続先を指定の IP アドレスへ固定してリクエストを送信する。
send()  : ResponseInterface
リクエストを送信してレスポンスを組み立てる。

Properties

$responseFactory

private ResponseFactoryInterface $responseFactory

$settings

リクエスト設定(embed/embed の CurlClient と同じキー名を使う)

private array{ssl_verify_peer?: bool, ssl_verify_host?: int, connect_timeout?: int, timeout?: int, cookies_path?: string} $settings

Methods

__construct()

public __construct(ResponseFactoryInterface $responseFactory, StreamFactoryInterface $streamFactory[, array{ssl_verify_peer?: bool, ssl_verify_host?: int, connect_timeout?: int, timeout?: int, cookies_path?: string} $settings = [] ]) : mixed
Parameters
$responseFactory : ResponseFactoryInterface
$streamFactory : StreamFactoryInterface
$settings : array{ssl_verify_peer?: bool, ssl_verify_host?: int, connect_timeout?: int, timeout?: int, cookies_path?: string} = []

buildCurlOptions()

cURL に渡すオプションを組み立てる。

public buildCurlOptions(RequestInterface $request, array<string|int, string> $pinnedIpAddresses) : array<int, mixed>

送信本体から分離して、ピンニング(CURLOPT_RESOLVE)や追従無効の設定を ネットワーク接続なしで検証できるようにしている。

Parameters
$request : RequestInterface
$pinnedIpAddresses : array<string|int, string>

接続を固定する IP アドレス一覧(空なら固定しない)

Return values
array<int, mixed> —

curl_setopt_array() に渡すオプション

sendRequest()

public sendRequest(RequestInterface $request) : ResponseInterface
Parameters
$request : RequestInterface
Return values
ResponseInterface

sendRequestPinned()

接続先を指定の IP アドレスへ固定してリクエストを送信する。

public sendRequestPinned(RequestInterface $request, array<string|int, string> $ipAddresses) : ResponseInterface
Parameters
$request : RequestInterface
$ipAddresses : array<string|int, string>
Return values
ResponseInterface

send()

リクエストを送信してレスポンスを組み立てる。

private send(RequestInterface $request, array<string|int, string> $pinnedIpAddresses) : ResponseInterface
Parameters
$request : RequestInterface
$pinnedIpAddresses : array<string|int, string>
Tags
throws
HttpClientRequestException

送信に失敗した場合

Return values
ResponseInterface

        
On this page

Search results