Module: M2R::Response::ToRequest

Included in:
M2R::Reply
Defined in:
lib/m2r/response/to_request.rb

Overview

Handles the logic of having response with proper http version and ‘Connection’ header in relation to given request

Instance Method Summary collapse

Instance Method Details

#to(request, identical = false) ⇒ self

params [Request] request Request that response handles params [true, false] identical Whether http version in response should be identical

to the received one.

Returns:

  • (self)

    Response object



15
16
17
18
19
20
21
# File 'lib/m2r/response/to_request.rb', line 15

def to(request, identical = false)
  # http://www.ietf.org/rfc/rfc2145.txt
  # 2.3 Which version number to send in a message
  http_version(request.http_version) if identical
  headers['Connection'] = 'close' if request.close?
  self
end