An HTTP response. This is filled in by the service or do_* methods of a WEBrick HTTP Servlet.

Attributes

HTTP Response version

Read

Response status code (200)

Read

Response header

Read

Response cookies

Read & Write

Response reason phrase (“OK”)

Read & Write

Body may be:

  • a String;

  • an IO-like object that responds to #read and #readpartial;

  • a Proc-like object that responds to #call.

In the latter case, either chunked= should be set to true, or header['content-length'] explicitly provided. Example:

server.mount_proc '/' do |req, res|
  res.chunked = true
  # or
  # res.header['content-length'] = 10
  res.body = proc { |out| out.write(Time.now.to_s) }
end
Read & Write

Request method for this response

Read & Write

Request URI for this response

Read & Write

Request HTTP version for this response

Read & Write

Filename of the static file in this response. Only used by the FileHandler servlet.

Read & Write

Is this a keep-alive response?

Read

Configuration for this response

Read

Bytes sent in this response

Class Methods

Creates a new HTTP response object. WEBrick::Config::HTTP is the default configuration.

Instance Methods

Retrieves the response header field

Sets the response header field to value

No documentation available

Enables chunked transfer encoding.

Will this response body be returned using chunked transfer-encoding?

The content-length header

Sets the content-length header to len

The content-type header

Sets the content-type header to type

Iterates over each header in the response

Will this response’s connection be kept alive?

Creates an error page for exception ex with an optional backtrace

Redirects to url with a WEBrick::HTTPStatus::Redirect status.

Example:

res.set_redirect WEBrick::HTTPStatus::TemporaryRedirect

Sets the response’s status to the status code

The response’s HTTP status line