class VCR::Request
@attr [Hash{String => Array<String>}] headers the request headers
@attr [String, nil] body the request body
@attr [String] uri the request URI
@attr [Symbol] method the HTTP method (i.e. :head, :options, :get, :post, :put, :patch or :delete)
The request of an {HTTPInteraction}.
def self.from_hash(hash)
-
(Request)
- the request
Parameters:
-
hash
(Hash
) -- the hash to use to construct the instance.
def self.from_hash(hash) method = hash['method'] method &&= method.to_sym new method, hash['uri'], body_from(hash['body']), hash['headers'], :skip_port_stripping end
def initialize(*args)
def initialize(*args) skip_port_stripping = false if args.last == :skip_port_stripping skip_port_stripping = true args.pop end super(*args) self.method = self.method.to_s.downcase.to_sym if self.method self.uri = without_standard_port(self.uri) unless skip_port_stripping end
def method(*args)
def method(*args) return super if args.empty? @@object_method.bind(self).call(*args) end
def parsed_uri
-
(#schema, #host, #port, #path, #query)
- A parsed URI object.
def parsed_uri VCR.configuration.uri_parser.parse(uri) end
def to_hash
- See: Request.from_hash -
Returns:
-
(Hash)
- hash that represents this request and can be easily
def to_hash { 'method' => method.to_s, 'uri' => uri, 'body' => serializable_body, 'headers' => headers } end
def without_standard_port(uri)
def without_standard_port(uri) return uri if uri.nil? u = parsed_uri return uri unless [['http', 80], ['https', 443]].include?([u.scheme, u.port]) u.port = nil u.to_s end