Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
HttpResponse
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * SPDX-License-Identifier: EUPL-1.2
5 *
6 * This file is part of icap-flow.
7 *
8 * Licensed under the EUPL, Version 1.2 only (the "Licence");
9 * you may not use this work except in compliance with the Licence.
10 * You may obtain a copy of the Licence at:
11 *
12 *     https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the Licence is distributed on an "AS IS" basis,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 */
18
19declare(strict_types=1);
20
21namespace Ndrstmr\Icap\DTO;
22
23/**
24 * Encapsulated HTTP response carried inside an ICAP RESPMOD request
25 * (RFC 3507 §4.9) or returned in a 200 response with modifications.
26 *
27 * Body is either a string (treated as raw bytes) or a stream resource the
28 * {@see \Ndrstmr\Icap\RequestFormatter} reads chunk-by-chunk to avoid
29 * buffering the whole payload in memory.
30 */
31final readonly class HttpResponse
32{
33    /**
34     * @param int                     $statusCode  HTTP status code, e.g. 200
35     * @param string                  $reasonPhrase Reason phrase, e.g. "OK"
36     * @param array<string, string[]> $headers      HTTP header list
37     * @param resource|string|null    $body         HTTP body bytes, or a readable stream resource, or null for header-only
38     * @param string                  $httpVersion  HTTP version label, default HTTP/1.1
39     */
40    public function __construct(
41        public int $statusCode,
42        public string $reasonPhrase = 'OK',
43        public array $headers = [],
44        public mixed $body = null,
45        public string $httpVersion = 'HTTP/1.1',
46    ) {
47    }
48}