6use 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 );
51 return $this->statusCode;
55 return $this->reasonPhrase;
58 public function setStatus( $code, $reasonPhrase =
'' ) {
59 $this->statusCode = $code;
60 if ( $reasonPhrase ===
'' ) {
61 $reasonPhrase = HttpStatus::getMessage( $code ) ??
'';
63 $this->reasonPhrase = $reasonPhrase;
67 return $this->protocolVersion;
71 return $this->headerContainer->getHeaders();
75 return $this->headerContainer->hasHeader( $name );
79 return $this->headerContainer->getHeader( $name );
83 return $this->headerContainer->getHeaderLine( $name );
91 $this->protocolVersion = $version;
95 $this->headerContainer->setHeader( $name, $value );
99 $this->headerContainer->addHeader( $name, $value );
103 $this->headerContainer->removeHeader( $name );
106 public function setBody( StreamInterface $body ) {
111 return $this->headerContainer->getRawHeaderLines();
114 public function setCookie( $name, $value, $expire = 0, $options = [] ) {
119 'options' => $options
124 return $this->cookies;
if(!defined('MW_SETUP_CALLBACK'))