MediaWiki master
ResponseInterface.php
Go to the documentation of this file.
1<?php
2
31namespace MediaWiki\Rest;
32
33use Psr\Http\Message\StreamInterface;
34
42 // ResponseInterface
43
52 public function getStatusCode(): int;
53
67 public function getReasonPhrase(): string;
68
69 // ResponseInterface mutation
70
86 public function setStatus( $code, $reasonPhrase = '' );
87
88 // MessageInterface
89
97 public function getProtocolVersion(): string;
98
124 public function getHeaders(): array;
125
134 public function hasHeader( string $name ): bool;
135
150 public function getHeader( string $name ): array;
151
171 public function getHeaderLine( string $name ): string;
172
178 public function getBody();
179
180 // MessageInterface mutation
181
190 public function setProtocolVersion( $version );
191
202 public function setHeader( $name, $value );
203
216 public function addHeader( $name, $value );
217
225 public function removeHeader( $name );
226
235 public function setBody( StreamInterface $body );
236
237 // MediaWiki extensions to PSR-7
238
245 public function getRawHeaderLines();
246
265 public function setCookie( $name, $value, $expire = 0, $options = [] );
266
279 public function getCookies();
280}
An interface similar to PSR-7's ResponseInterface, the primary difference being that it is mutable.
setHeader( $name, $value)
Set or replace the specified header.
setProtocolVersion( $version)
Set the HTTP protocol version.
addHeader( $name, $value)
Append the given value to the specified header.
setBody(StreamInterface $body)
Set the message body.
getReasonPhrase()
Gets the response reason phrase associated with the status code.
getHeader(string $name)
Retrieves a message header value by the given case-insensitive name.
getRawHeaderLines()
Get the full header lines including colon-separated name and value, for passing directly to header().
getHeaders()
Retrieves all message header values.
getBody()
Gets the body of the message.
getProtocolVersion()
Retrieves the HTTP protocol version as a string.
getHeaderLine(string $name)
Retrieves a comma-separated string of the values for a single header.
setStatus( $code, $reasonPhrase='')
Set the status code and, optionally, reason phrase.
setCookie( $name, $value, $expire=0, $options=[])
Set a cookie.
getStatusCode()
Gets the response status code.
removeHeader( $name)
Remove the specified header.
hasHeader(string $name)
Checks if a header exists by the given case-insensitive name.
getCookies()
Get all previously set cookies as a list of associative arrays with the following keys: