Class: RightSpeed::Handler::Response
- Inherits:
-
Object
- Object
- RightSpeed::Handler::Response
- Defined in:
- lib/right_speed/handler.rb
Constant Summary collapse
- STATUS_MESSAGE_MAP =
{ 200 => "OK", }.freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(http_version:, status_code:, headers:, body:) ⇒ Response
constructor
A new instance of Response.
- #status ⇒ Object
Constructor Details
#initialize(http_version:, status_code:, headers:, body:) ⇒ Response
Returns a new instance of Response.
114 115 116 117 118 119 120 |
# File 'lib/right_speed/handler.rb', line 114 def initialize(http_version:, status_code:, headers:, body:) @http_version = http_version @status_code = status_code @status_message = STATUS_MESSAGE_MAP.fetch(status_code, "Unknown") @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
112 113 114 |
# File 'lib/right_speed/handler.rb', line 112 def body @body end |
Instance Method Details
#headers ⇒ Object
126 127 128 |
# File 'lib/right_speed/handler.rb', line 126 def headers @headers.map{|key, value| "#{key}: #{value}\r\n" }.join + "\r\n" end |
#status ⇒ Object
122 123 124 |
# File 'lib/right_speed/handler.rb', line 122 def status "#{@http_version} #{@status_code} #{@status_message}\r\n" end |