Method: HTTP::Response#initialize
- Defined in:
- lib/http/response.rb
#initialize(opts) ⇒ Response
Inits a new instance
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/http/response.rb', line 46 def initialize(opts) @version = opts.fetch(:version) @request = init_request(opts) @status = HTTP::Response::Status.new(opts.fetch(:status)) @headers = HTTP::Headers.coerce(opts[:headers] || {}) @proxy_headers = HTTP::Headers.coerce(opts[:proxy_headers] || {}) if opts.include?(:body) @body = opts.fetch(:body) else connection = opts.fetch(:connection) encoding = opts[:encoding] || charset || default_encoding @body = Response::Body.new(connection, encoding: encoding) end end |