Skip to content

Commit

Permalink
feat(Res): 增加 getHeaders 方法
Browse files Browse the repository at this point in the history
  • Loading branch information
twinh committed May 31, 2023
1 parent e3d87a8 commit 160f161
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Res.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,16 @@ public function removeHeader($name)
return $this;
}

/**
* Return the response headers
*
* @return array
*/
public function getHeaders(): array
{
return $this->headers;
}

/**
* Send HTTP headers, including HTTP status, raw headers and cookies
*
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/ResTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
/**
* @internal
* @mixin \ResPropMixin
*/
final class ResTest extends TestCase
{
Expand Down Expand Up @@ -201,6 +202,12 @@ public function testWait()

$this->res->redirect('http://www.google.com', 302, ['redirectWait' => 5])->send();
}

public function testGetHeaders()
{
$this->res->setHeader('test', 'value');
$this->assertArrayContains(['test' => ['value']], $this->res->getHeaders());
}
}
}

Expand Down

0 comments on commit 160f161

Please sign in to comment.