class M2R::Response
Simplest possible abstraction layer over HTTP
request
@api public
Constants
- CRLF
@private
- GETTER
- STATUS_CODES
@private
- VERSION
@private
Attributes
reason[R]
Public Class Methods
new()
click to toggle source
# File lib/m2r/response.rb, line 73 def initialize status(200) headers(Headers.new) body("") http_version(VERSION) end
Public Instance Methods
body(value = GETTER)
click to toggle source
@param [String, nil] value HTTP
body
# File lib/m2r/response.rb, line 113 def body(value = GETTER) if value == GETTER @body else @body = value self end end
header(header, value = GETTER)
click to toggle source
headers(value = GETTER)
click to toggle source
@param [Hash] value HTTP
headers
# File lib/m2r/response.rb, line 92 def headers(value = GETTER) if value == GETTER @headers else @headers = value self end end
http_version(value = GETTER)
click to toggle source
@param [String, nil] version HTTP
body
# File lib/m2r/response.rb, line 123 def http_version(value = GETTER) if value == GETTER @version else @version = value self end end
status(value = GETTER)
click to toggle source
@param [Fixnum, to_i] value HTTP
status code
# File lib/m2r/response.rb, line 81 def status(value = GETTER) if value == GETTER @status else @status = value.to_i @reason = STATUS_CODES[@status] self end end
to_s()
click to toggle source