Class Thin::Response
In: lib/thin/response.rb
Parent: Object

A response sent to the client.

Methods

Constants

CONNECTION = 'Connection'.freeze
CLOSE = 'close'.freeze
KEEP_ALIVE = 'keep-alive'.freeze
SERVER = 'Server'.freeze
CONTENT_LENGTH = 'Content-Length'.freeze
PERSISTENT_STATUSES = [100, 101].freeze
ERROR = [500, {'Content-Type' => 'text/plain'}, ['Internal server error']].freeze   Error Responses
PERSISTENT_ERROR = [500, {'Content-Type' => 'text/plain', 'Connection' => 'keep-alive', 'Content-Length' => "21"}, ['Internal server error']].freeze
BAD_REQUEST = [400, {'Content-Type' => 'text/plain'}, ['Bad Request']].freeze

Attributes

body  [RW]  Response body, must respond to each.
headers  [R]  Headers key-value hash
status  [RW]  Status code

Public Class methods

Public Instance methods

Close any resource used by the response

Yields each chunk of the response. To control the size of each chunk define your own each method on body.

Top header of the response, containing the status code and response headers.

Ruby 1.9 doesn‘t have a String#each anymore. Rack spec doesn‘t take care of that yet, for now we just use each but fallback to each_line on strings. I wish we could remove that condition. To be reviewed when a new Rack spec comes out.

Ruby 1.8 implementation. Respects Rack specs.

See rack.rubyforge.org/doc/files/SPEC.html

String representation of the headers to be sent in the response.

Tell the client the connection should stay open

Persistent connection must be requested as keep-alive from the server and have a Content-Length, or the response status must require that the connection remain open.

[Validate]