Client::__construct
タイムアウトを指定してクライアントを作成します
説明
public Client::__construct( [ float $timeout = 10 [, float $connectTimeout = 3 [, ?string $transport = null ] ] ] )
タイムアウトは、このクライアントで送るすべてのリクエストに適用されます。
引数
| 名前 | データ型 | デフォルト | 備考 |
|---|---|---|---|
| $timeout | float | 10 | リクエスト全体の秒数 |
| $connectTimeout | float | 3 | 接続の秒数(cURLのみ。ストリームラッパーでは$timeout全体が使えます) |
| $transport | string|null | null | 'curl'または'stream'。nullなら、cURL拡張がインストールされていればcURL、なければストリームラッパーを使います。指定するのはテストのときだけです |
例
Controller
use Fegg\Http\Client;
$client = new Client(); // 10 seconds, 3 to connect
$quick = new Client(3, 1); // while a visitor waits for the page