class HTTP::Request

def initialize(opts)

Options Hash: (**opts)
  • :body (String, Enumerable, IO, nil) --
  • :proxy (Hash) --
  • :headers (Hash) --
  • :uri (HTTP::URI, #to_s) --
  • :uri_normalizer (#call) --
  • :verb (#to_s) -- HTTP request method
  • :version (String) --
def initialize(opts)
  @verb           = opts.fetch(:verb).to_s.downcase.to_sym
  @uri_normalizer = opts[:uri_normalizer] || HTTP::URI::NORMALIZER
  @uri    = @uri_normalizer.call(opts.fetch(:uri))
  @scheme = @uri.scheme.to_s.downcase.to_sym if @uri.scheme
  raise(UnsupportedMethodError, "unknown method: #{verb}") unless METHODS.include?(@verb)
  raise(UnsupportedSchemeError, "unknown scheme: #{scheme}") unless SCHEMES.include?(@scheme)
  @proxy   = opts[:proxy] || {}
  @version = opts[:version] || "1.1"
  @headers = prepare_headers(opts[:headers])
  @body    = prepare_body(opts[:body])
end