class Typhoeus::Request
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/typhoeus/request.rbs class Typhoeus::Request def initialize: (String base_url, ?Hash options) -> void def set_defaults: () -> nil end
@see (see #initialize)
response = Typhoeus.get(“www.example.com”)
@example Make a request with the shortcut.
@example (see #initialize)
This class represents a request.
def cache_key
-
(String)
- The cache key.
def cache_key Digest::SHA1.hexdigest "#{self.class.name}#{base_url}#{hashable_string_for(options)}" end
def encoded_body
- Api: - private
Returns:
-
(String)
- The encoded body.
def encoded_body Ethon::Easy::Form.new(nil, options[:body]).to_s end
def eql?(other)
- Api: - private
Returns:
-
(Boolean)
- Returns true if equal, else false.
Parameters:
-
other
(Object
) -- The object to check.
Other tags:
- Example: Are request equal? -
def eql?(other) self.class == other.class && self.base_url == other.base_url && fuzzy_hash_eql?(self.options, other.options) end
def fuzzy_hash_eql?(left, right)
-
(Boolean)
- Returns true if hashes have
Parameters:
-
right
(Hash
) -- hash to check for equality -
left
(Hash
) --
def fuzzy_hash_eql?(left, right) return true if (left == right) (left.count == right.count) && left.inject(true) do |res, kvp| res && (kvp[1] == right[kvp[0]]) end end
def hash
- Api: - private
Returns:
-
(Integer)
- The integer representing the request.
def hash Zlib.crc32 cache_key end
def hashable_string_for(obj)
def hashable_string_for(obj) case obj when Hash hashable_string_for(obj.sort_by {|sub_obj| sub_obj.first.to_s}) when Array obj.map {|sub_obj| hashable_string_for(sub_obj)}.to_s else obj.to_s end end
def initialize(base_url, options = {})
Experimental RBS support (using type sampling data from the type_fusion
project).
def initialize: (String base_url, ?body | String | method | Symbol | headers | Content-Type | String | Accept | String | Accept-Charset | String options) -> void
This signature was generated using 38 samples from 3 applications.
- See: Typhoeus::Request::Actions -
See: Typhoeus::Response -
See: Typhoeus::Hydra -
Other tags:
- Note: - See {http://rubydoc.info/github/typhoeus/ethon/Ethon/Easy/Options Ethon::Easy::Options} for more options.
Returns:
-
(Typhoeus::Request)
- The request.
Options Hash:
(**options)
-
:body
(Hash
) -- Translated -
:params
(Hash
) -- Translated
Parameters:
-
options
(options
) -- The options. -
base_url
(String
) -- The url to request.
Other tags:
- Example: Create a request and allow follow redirections. -
Example: Request with parameters and body. -
Example: Request with a body. -
Example: Request with url parameters. -
Example: Simplest request. -
def initialize(base_url, options = {}) @base_url = base_url @original_options = options @options = options.dup set_defaults end
def set_defaults
Experimental RBS support (using type sampling data from the type_fusion
project).
def set_defaults: () -> nil
This signature was generated using 40 samples from 4 applications.
def set_defaults default_user_agent = Config.user_agent || Typhoeus::USER_AGENT options[:headers] = {'User-Agent' => default_user_agent}.merge(options[:headers] || {}) options[:headers]['Expect'] ||= '' options[:verbose] = Typhoeus::Config.verbose if options[:verbose].nil? && !Typhoeus::Config.verbose.nil? options[:maxredirs] ||= 50 options[:proxy] = Typhoeus::Config.proxy unless options.has_key?(:proxy) || Typhoeus::Config.proxy.nil? end
def url
- Since: - 0.5.5
Other tags:
- Example: Get the url. -
def url easy = EasyFactory.new(self).get url = easy.url Typhoeus::Pool.release(easy) url end