Skip to content

Commit d219ad8

Browse files
committed
Add getTrailers and withTrailers methods for Response
1 parent e4e59a1 commit d219ad8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Server/Response.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ class Response extends \Hyperf\HttpMessage\Base\Response
2222
*/
2323
protected $cookies = [];
2424

25+
/**
26+
* @var array
27+
*/
28+
protected $trailers = [];
29+
2530
/**
2631
* Returns an instance with body content.
2732
*/
@@ -49,4 +54,16 @@ public function getCookies(): array
4954
{
5055
return $this->cookies;
5156
}
57+
58+
public function withTrailer(string $key, $value): self
59+
{
60+
$new = clone $this;
61+
$new->trailers[$key] = $value;
62+
return $new;
63+
}
64+
65+
public function getTrailers(): array
66+
{
67+
return $this->trailers;
68+
}
5269
}

0 commit comments

Comments
 (0)