5use Psr\Http\Message\StreamInterface;
10 private int $statusCode = 200;
11 private string $reasonPhrase =
'OK';
12 private string $protocolVersion =
'1.1';
13 private StreamInterface $body;
15 private array $cookies = [];
23 if ( is_string( $body ) ) {
43 foreach ( $iResponse->getHeaders() as $name => $values ) {
44 $resp->setHeader( $name, $values );
52 return $this->statusCode;
57 return $this->reasonPhrase;
61 public function setStatus( $code, $reasonPhrase =
'' ) {
62 $this->statusCode = $code;
63 if ( $reasonPhrase ===
'' ) {
64 $reasonPhrase = HttpStatus::getMessage( $code ) ??
'';
66 $this->reasonPhrase = $reasonPhrase;
71 return $this->protocolVersion;
76 return $this->headerContainer->getHeaders();
81 return $this->headerContainer->hasHeader( $name );
86 return $this->headerContainer->getHeader( $name );
91 return $this->headerContainer->getHeaderLine( $name );
101 $this->protocolVersion = $version;
106 $this->headerContainer->setHeader( $name, $value );
111 $this->headerContainer->addHeader( $name, $value );
116 $this->headerContainer->removeHeader( $name );
120 public function setBody( StreamInterface $body ) {
126 return $this->headerContainer->getRawHeaderLines();
130 public function setCookie( $name, $value, $expire = 0, $options = [] ) {
135 'options' => $options
141 return $this->cookies;
if(!defined('MW_SETUP_CALLBACK'))