This class represents a request.
@example (see initialize)
@example Make a request with the shortcut.
response = Typhoeus.get("www.example.com")
@see (see initialize)
@return [ Boolean ]
@api private
Returns options, which includes default parameters.
@return [ Hash ]
Returns the original options provided.
@return [ Hash ]
@api private
Returns the provided url.
@return [ String ]
Create a new request.
@example Simplest request.
response = Typhoeus::Request.new("www.example.com").run
@example Request with url parameters.
response = Typhoeus::Request.new(
"www.example.com",
params: {a: 1}
).run
@example Request with a body.
response = Typhoeus::Request.new(
"www.example.com",
body: {b: 2}
).run
@example Request with parameters and body.
response = Typhoeus::Request.new(
"www.example.com",
params: {a: 1},
body: {b: 2}
).run
@example Create a request and allow follow redirections.
response = Typhoeus::Request.new( "www.example.com", followlocation: true ).run
@param [ String ] url The url to request. @param [ options ] options The options.
@option options [ Hash ] :params Translated
into url parameters.
@option options [ Hash ] :body Translated
into HTTP POST request body.
@return [ Typhoeus::Request ] The request.
@note See {rubydoc.info/github/typhoeus/ethon/Ethon/Easy#initialize-instance_method Ethon::Easy#initialize} for more options.
@see Typhoeus::Hydra @see Typhoeus::Response @see Typhoeus::Request::Actions
# File lib/typhoeus/request.rb, line 107 def initialize(url, options = {}) @url = url @original_options = options @options = options.dup set_defaults end
Returns wether other is equal to self.
@example Are request equal?
request.eql?(other_request)
@param [ Object ] other The object to check.
@return [ Boolean ] Returns true if equals, else false.
@api private
# File lib/typhoeus/request.rb, line 125 def eql?(other) self.class == other.class && self.url == other.url && fuzzy_hash_eql?(self.options, other.options) end
Overrides Object#hash.
@return [ Integer ] The integer representing the request.
@api private
# File lib/typhoeus/request.rb, line 136 def hash [ self.class, self.url, self.options ].hash end