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
HttpRequest
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 request carried inside an ICAP REQMOD request
25 * (RFC 3507 §4.8). The {@see \Ndrstmr\Icap\RequestFormatter} renders its
26 * request-line + headers into the `req-hdr` section and streams the body
27 * into the `req-body` section. A stream passed in stays the caller's: it is
28 * read, never closed. When the headers announce a `Content-Length`, the
29 * stream has to deliver exactly that many bytes, or sending the request
30 * fails before the final chunk. A preview that carries only the start of
31 * the body is the exception: the field describes all of it.
32 */
33final readonly class HttpRequest
34{
35    /**
36     * @param string                  $method        HTTP method, e.g. "POST"
37     * @param string                  $requestTarget Request-target as per RFC 7230 §5.3 (path + optional query)
38     * @param array<string, string[]> $headers       HTTP header list
39     * @param resource|string|null    $body          HTTP body bytes, or a readable stream resource, or null for header-only
40     * @param string                  $httpVersion   HTTP version label, default HTTP/1.1
41     */
42    public function __construct(
43        public string $method,
44        public string $requestTarget = '/',
45        public array $headers = [],
46        public mixed $body = null,
47        public string $httpVersion = 'HTTP/1.1',
48    ) {
49    }
50}