Skip to content

Commit 2b01ad2

Browse files
committed
Add Response::removeHeadersByNames method
1 parent 89f6c49 commit 2b01ad2

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/Response.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,19 @@ public function removeHeaders() : static
201201
return parent::removeHeaders();
202202
}
203203

204+
/**
205+
* @param array<string> $names
206+
*
207+
* @see Response::removeHeader()
208+
*
209+
* @return static
210+
*/
211+
#[Override]
212+
public function removeHeadersByNames(array $names) : static
213+
{
214+
return parent::removeHeadersByNames($names);
215+
}
216+
204217
/**
205218
* Set the Content-Security-Policy instance.
206219
*

tests/ResponseTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,21 @@ public function testHeader() : void
314314
self::assertSame([], $this->response->getHeaders());
315315
}
316316

317+
public function testRemoveHeadersByNames() : void
318+
{
319+
self::assertSame([], $this->response->getHeaders());
320+
$this->response->setHeader('content-type', 'text/html');
321+
$this->response->setHeader('foo', 'bar');
322+
self::assertSame([
323+
'content-type' => 'text/html',
324+
'foo' => 'bar',
325+
], $this->response->getHeaders());
326+
$this->response->removeHeadersByNames(['content-type']);
327+
self::assertSame([
328+
'foo' => 'bar',
329+
], $this->response->getHeaders());
330+
}
331+
317332
public function testHeadersAreAlreadySent() : void
318333
{
319334
$response = new class(new RequestMock(['domain.tld'])) extends Response {

0 commit comments

Comments
 (0)