| 1 | <?php |
||
| 10 | class HeaderPlugin implements Plugin |
||
| 11 | { |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var array headers that have fixed value |
||
| 15 | */ |
||
| 16 | private $headers = []; |
||
| 17 | private $removedHeader = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Sets a header with the given value to every requests. |
||
| 21 | * |
||
| 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 | * |
||
| 35 | * @param string $name name of the header to remove |
||
| 36 | */ |
||
| 37 | 2 | public function withoutHeader($name) |
|
| 41 | |||
| 42 | /** |
||
| 43 | * {@inheritdoc} |
||
| 44 | */ |
||
| 45 | 5 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
| 60 | } |
||
| 61 |