1 | <?php |
||
11 | class HeaderPlugin implements Plugin |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * @var array headers that have fixed value |
||
16 | */ |
||
17 | private $headers = []; |
||
18 | private $removedHeader = []; |
||
19 | |||
20 | /** |
||
21 | * Sets a header with the given value to every requests. |
||
22 | * @param string $name name of the header |
||
23 | * @param string $value value of the header |
||
24 | * @param bool $override By default if the header is already set on the request the value wont be replaced |
||
25 | * pass $override to true to make the header value the same for every request |
||
26 | */ |
||
27 | 3 | public function withHeader($name, $value, $override = false) |
|
31 | |||
32 | /** |
||
33 | * Automatically removes the given header from the request |
||
34 | * @param string $name name of the header to remove |
||
35 | */ |
||
36 | 2 | public function withoutHeader($name) |
|
40 | |||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | 5 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
59 | } |
||
60 |