Object
A response sent to the client.
Close any resource used by the response
# File lib/thin/response.rb, line 74
74: def close
75: @body.close if @body.respond_to?(:close)
76: end
Yields each chunk of the response. To control the size of each chunk define your own each method on body.
# File lib/thin/response.rb, line 81
81: def each
82: yield head
83: if @body.is_a?(String)
84: yield @body
85: else
86: @body.each { |chunk| yield chunk }
87: end
88: end
Top header of the response, containing the status code and response headers.
# File lib/thin/response.rb, line 37
37: def head
38: "HTTP/1.1 #{@status} #{HTTP_STATUS_CODES[@status.to_i]}\r\n#{headers_output}\r\n"
39: end
Ruby 1.8 implementation. Respects Rack specs.
See rack.rubyforge.org/doc/files/SPEC.html
# File lib/thin/response.rb, line 47
47: def headers=(key_value_pairs)
48: key_value_pairs.each do |k, vs|
49: vs.each { |v| @headers[k] = v.chomp } if vs
50: end if key_value_pairs
51: end
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.
# File lib/thin/response.rb, line 60
60: def headers=(key_value_pairs)
61: key_value_pairs.each do |k, vs|
62: next unless vs
63: if vs.is_a?(String)
64: vs.each_line { |v| @headers[k] = v.chomp }
65: else
66: vs.each { |v| @headers[k] = v.chomp }
67: end
68: end if key_value_pairs
69: end
String representation of the headers to be sent in the response.
# File lib/thin/response.rb, line 27
27: def headers_output
28: # Set default headers
29: @headers[CONNECTION] = persistent? ? KEEP_ALIVE : CLOSE
30: @headers[SERVER] = Thin::SERVER
31:
32: @headers.to_s
33: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.