The response to configure and write to in an HTTP::Server
handler.
The response #status
and #headers
must be configured before writing the response body. Once response output is written, changing the #status
and #headers
properties has no effect.
The HTTP::Server::Response
is a write-only IO
, so all IO
methods are available in it.
A response can be upgraded with the #upgrade
method. Once invoked, headers are written and the connection IO
(a socket) is yielded to the given block. This is useful to implement protocol upgrades, such as websockets.
Closes this response, writing headers and body if not done yet.
Returns true
if this response has been closed.
Convenience method to set the Content-Length
header.
Convenience method to set the Content-Type
header.
Convenience method to set cookies, see HTTP::Cookies
.
Flushes the output.
The response headers (HTTP::Headers
).
The IO
to which output is written.
The IO
to which output is written.
Sends status and message as response.
Sends status and message as response.
The status code of this response, which must be set before writing the response body.
The status code of this response, which must be set before writing the response body.
Convenience method to retrieve the HTTP status code.
Convenience method to set the HTTP status code.
Upgrades this response, writing headers and yieling the connection IO
(a socket) to the given block.
The version of the HTTP::Request that created this response.
See IO#write(slice)
.
IO
IO
Reference
Reference
Object
Object
Closes this response, writing headers and body if not done yet. This method must be implemented if wrapping the response output.
Returns true
if this response has been closed.
Convenience method to set the Content-Length
header.
Convenience method to set cookies, see HTTP::Cookies
.
Flushes the output. This method must be implemented if wrapping the response output.
The response headers (HTTP::Headers
). These must be set before writing to the response.
The IO
to which output is written. This can be changed/wrapped to filter the response body (for example to compress the output).
The IO
to which output is written. This can be changed/wrapped to filter the response body (for example to compress the output).
Sends status and message as response.
This method calls #reset
to remove any previous settings and writes the given status and message to the response IO. Finally, it closes the response.
If message is nil
, the default message for status is used provided by HTTP::Status#description
.
Sends status and message as response.
This method calls #reset
to remove any previous settings and writes the given status and message to the response IO. Finally, it closes the response.
If message is nil
, the default message for status is used provided by HTTP::Status#description
.
The status code of this response, which must be set before writing the response body. If not set, the default value is 200 (OK).
The status code of this response, which must be set before writing the response body. If not set, the default value is 200 (OK).
Convenience method to retrieve the HTTP status code.
Upgrades this response, writing headers and yieling the connection IO
(a socket) to the given block. This is useful to implement protocol upgrades, such as websockets.
See IO#write(slice)
.
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/HTTP/Server/Response.html