Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| RawResponse | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\ResourceLoader\Transport; |
| 6 | |
| 7 | /** |
| 8 | * The transport layer's return value — one HTTP response with no |
| 9 | * orchestration applied. The {@see \Phpdftk\ResourceLoader\HttpFetcher} |
| 10 | * walks a chain of these (one per redirect hop), applies the |
| 11 | * content-length cap, strips Authorization across host changes, and |
| 12 | * sniffs the final body's MIME type. |
| 13 | * |
| 14 | * `headers` is normalised: keys are lowercased; values are kept as- |
| 15 | * is so callers can re-emit the exact server bytes if needed. |
| 16 | */ |
| 17 | final readonly class RawResponse |
| 18 | { |
| 19 | /** |
| 20 | * @param int $statusCode HTTP status (200, 301, 404, …). |
| 21 | * @param array<string, string> $headers Lowercase header name → first value. |
| 22 | * @param string $body Response body bytes. Empty for HEAD |
| 23 | * responses or for redirect hops where |
| 24 | * the transport elected not to read |
| 25 | * the body. |
| 26 | * @param string $finalUrl The URL the response came from after |
| 27 | * any transport-level redirect |
| 28 | * following. The fetcher handles |
| 29 | * redirects itself for SSRF re-check, |
| 30 | * so transports SHOULD set this equal |
| 31 | * to the requested URL and let the |
| 32 | * fetcher follow. |
| 33 | */ |
| 34 | public function __construct( |
| 35 | public int $statusCode, |
| 36 | public array $headers, |
| 37 | public string $body, |
| 38 | public string $finalUrl, |
| 39 | ) {} |
| 40 | } |