Method: HTTP::Request#initialize

Defined in:
lib/http/request.rb

#initialize(method, uri, headers = {}, proxy = {}, body = nil, version = "1.1") ⇒ Request

:nodoc:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/http/request.rb', line 39

def initialize(method, uri, headers = {}, proxy = {}, body = nil, version = "1.1")
  @method = method.to_s.downcase.to_sym
  raise UnsupportedMethodError, "unknown method: #{method}" unless METHODS.include? @method

  @uri = uri.is_a?(URI) ? uri : URI(uri.to_s)

  @headers = {}
  headers.each do |name, value|
    name = name.to_s
    key = name[CANONICAL_HEADER]
    key ||= canonicalize_header(name)
    @headers[key] = value
  end
  @headers["Host"] ||= @uri.host

  @proxy, @body, @version = proxy, body, version
end