200 $clone = clone $this;
201 $clone->status =
$code;
249 if ($this->reasonPhrase) {
275 $clone = clone $this;
276 $clone->headers->set(
$name, $value);
325 $responseWithRedirect = $this->
withHeader(
'Location', (
string)
$url);
332 return $responseWithRedirect->withStatus(
$status);
335 return $responseWithRedirect;
355 $response->body->write($json = json_encode(
$data, $encodingOptions));
358 if ($json ===
false) {
359 throw new \RuntimeException(json_last_error_msg(), json_last_error());
362 $responseWithJson =
$response->withHeader(
'Content-Type',
'application/json;charset=utf-8');
364 return $responseWithJson->withStatus(
$status);
366 return $responseWithJson;
getHeaders()
Retrieves all message header values.
const HTTP_PROXY_AUTHENTICATION_REQUIRED
withRedirect($url, $status=null)
Redirect.
const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE
getBody()
Gets the body of the message.
const HTTP_SWITCHING_PROTOCOLS
isForbidden()
Is this response forbidden?
getHeaderLine($name)
Retrieves a comma-separated string of the values for a single header.
Abstract message (base class for Request and Response)
withHeader($name, $value)
Return an instance with the provided value replacing the specified header.
const HTTP_PAYMENT_REQUIRED
const HTTP_MOVED_PERMANENTLY
__clone()
This method is applied to the cloned object after PHP performs an initial shallow-copy.
const HTTP_FAILED_DEPENDENCY
const HTTP_PERMANENT_REDIRECT
const HTTP_MULTIPLE_CHOICES
isServerError()
Is this response a server error?
isInformational()
Is this response informational?
const HTTP_CONNECTION_CLOSED_WITHOUT_RESPONSE
__construct( $status=StatusCode::HTTP_OK, HeadersInterface $headers=null, StreamInterface $body=null)
Create new HTTP response.
const HTTP_REQUEST_URI_TOO_LONG
const HTTP_TOO_MANY_REQUESTS
isRedirection()
Is this response a redirection?
const HTTP_VERSION_NOT_SUPPORTED
const HTTP_REQUEST_ENTITY_TOO_LARGE
isRedirect()
Is this response a redirect?
getProtocolVersion()
Retrieves the HTTP protocol version as a string.
const HTTP_GATEWAY_TIMEOUT
const HTTP_NONAUTHORITATIVE_INFORMATION
const HTTP_NETWORK_AUTHENTICATION_REQUIRED
const HTTP_SERVICE_UNAVAILABLE
getReasonPhrase()
Gets the response reason phrase associated with the status code.
const HTTP_UNSUPPORTED_MEDIA_TYPE
withStatus($code, $reasonPhrase='')
Return an instance with the specified status code and, optionally, reason phrase. ...
const HTTP_VARIANT_ALSO_NEGOTIATES
const HTTP_EXPECTATION_FAILED
isNotFound()
Is this response not Found?
const HTTP_ALREADY_REPORTED
const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE
const HTTP_INTERNAL_SERVER_ERROR
const HTTP_INSUFFICIENT_STORAGE
Slim Framework (https://slimframework.com)
Representation of an outgoing, server-side response.
isSuccessful()
Is this response successful?
isOk()
Is this response OK?
const HTTP_REQUEST_TIMEOUT
const HTTP_TEMPORARY_REDIRECT
const HTTP_CLIENT_CLOSED_REQUEST
isClientError()
Is this response a client error?
withBody(StreamInterface $body)
Return an instance with the specified message body.
__toString()
Convert response to string.
filterStatus($status)
Filter HTTP status code.
const HTTP_UNPROCESSABLE_ENTITY
const HTTP_NETWORK_CONNECTION_TIMEOUT_ERROR
const HTTP_NOT_ACCEPTABLE
write($data)
Write data to the response body.
isEmpty()
Is this response empty?
withJson($data, $status=null, $encodingOptions=0)
Json.
const HTTP_MISDIRECTED_REQUEST
const HTTP_UNAVAILABLE_FOR_LEGAL_REASONS
const HTTP_PRECONDITION_FAILED
const HTTP_UPGRADE_REQUIRED
const HTTP_PARTIAL_CONTENT
const HTTP_PRECONDITION_REQUIRED
getStatusCode()
Gets the response status code.
const HTTP_LENGTH_REQUIRED
const HTTP_METHOD_NOT_ALLOWED
const HTTP_NOT_IMPLEMENTED