Class: Pronghorn::Response
- Inherits:
-
Object
- Object
- Pronghorn::Response
- Defined in:
- lib/pronghorn/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #close ⇒ Object
- #each {|head| ... } ⇒ Object
- #head ⇒ Object
-
#initialize(status = 200, headers = {"Content-Type" => "text/plain"}, body = [""]) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(status = 200, headers = {"Content-Type" => "text/plain"}, body = [""]) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 |
# File 'lib/pronghorn/response.rb', line 10 def initialize(status = 200, headers = {"Content-Type" => "text/plain"}, body = [""]) @status = status @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
6 7 8 |
# File 'lib/pronghorn/response.rb', line 6 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
4 5 6 |
# File 'lib/pronghorn/response.rb', line 4 def headers @headers end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/pronghorn/response.rb', line 8 def status @status end |
Instance Method Details
#close ⇒ Object
24 25 26 |
# File 'lib/pronghorn/response.rb', line 24 def close @body.close if @body.respond_to?(:close) end |
#each {|head| ... } ⇒ Object
28 29 30 31 |
# File 'lib/pronghorn/response.rb', line 28 def each yield head @body.each { |chunk| yield chunk } end |
#head ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pronghorn/response.rb', line 16 def head lines = [] lines << "HTTP/1.1 #{@status}\r\n" lines += generate_header_lines(@headers) lines << "\r\n" lines.join end |