Class: Typhoeus::Request
- Inherits:
-
Object
- Object
- Typhoeus::Request
- Extended by:
- Actions
- Includes:
- Before, BlockConnection, Cacheable, Callbacks, Callbacks::Types, Marshal, Memoizable, Operations, Responseable, Streamable, Stubbable
- Defined in:
- lib/typhoeus/request.rb,
lib/typhoeus/request/before.rb,
lib/typhoeus/request/actions.rb,
lib/typhoeus/request/marshal.rb,
lib/typhoeus/request/cacheable.rb,
lib/typhoeus/request/callbacks.rb,
lib/typhoeus/request/stubbable.rb,
lib/typhoeus/request/memoizable.rb,
lib/typhoeus/request/operations.rb,
lib/typhoeus/request/streamable.rb,
lib/typhoeus/request/responseable.rb,
lib/typhoeus/request/block_connection.rb
Overview
This class represents a request.
Defined Under Namespace
Modules: Actions, Before, BlockConnection, Cacheable, Callbacks, Marshal, Memoizable, Operations, Responseable, Streamable, Stubbable
Instance Attribute Summary collapse
-
#base_url ⇒ String
Returns the provided base url.
- #block_connection ⇒ Boolean private
-
#hydra ⇒ Typhoeus::Hydra
private
Returns the hydra in which the request ran, if any.
-
#options ⇒ Hash
Returns options, which includes default parameters.
-
#original_options ⇒ Hash
private
Returns the original options provided.
Instance Method Summary collapse
-
#cache_key ⇒ String
Returns a cache key for use with caching methods that required a string for a key.
-
#encoded_body ⇒ String
private
Mimics libcurls POST body generation.
-
#eql?(other) ⇒ Boolean
private
Returns whether other is equal to self.
-
#hash ⇒ Integer
private
Overrides Object#hash.
-
#initialize(base_url, options = {}) ⇒ Typhoeus::Request
constructor
Creates a new request.
-
#url ⇒ Object
Return the url.
Methods included from Actions
delete, get, head, patch, post, put
Methods included from Before
Methods included from Stubbable
Methods included from BlockConnection
Methods included from Cacheable
#cache_ttl, #cacheable?, #response=, #run
Methods included from Memoizable
Methods included from Responseable
Methods included from Operations
Methods included from Marshal
Methods included from Streamable
Methods included from Callbacks
#execute_callbacks, #execute_headers_callbacks
Methods included from Callbacks::Types
#on_complete, #on_failure, #on_headers, #on_success
Constructor Details
#initialize(base_url, options = {}) ⇒ Typhoeus::Request
See Ethon::Easy::Options for more options.
Creates a new request.
112 113 114 115 116 117 118 |
# File 'lib/typhoeus/request.rb', line 112 def initialize(base_url, = {}) @base_url = base_url @original_options = @options = .dup set_defaults end |
Instance Attribute Details
#base_url ⇒ String
Returns the provided base url.
41 42 43 |
# File 'lib/typhoeus/request.rb', line 41 def base_url @base_url end |
#block_connection ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 |
# File 'lib/typhoeus/request.rb', line 65 def block_connection @block_connection end |
#hydra ⇒ Typhoeus::Hydra
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the hydra in which the request ran, if any.
53 54 55 |
# File 'lib/typhoeus/request.rb', line 53 def hydra @hydra end |
#options ⇒ Hash
Returns options, which includes default parameters.
46 47 48 |
# File 'lib/typhoeus/request.rb', line 46 def @options end |
#original_options ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the original options provided.
60 61 62 |
# File 'lib/typhoeus/request.rb', line 60 def @original_options end |
Instance Method Details
#cache_key ⇒ String
Returns a cache key for use with caching methods that required a string for a key. Will get used by ActiveSupport::Cache stores automatically.
164 165 166 |
# File 'lib/typhoeus/request.rb', line 164 def cache_key "#{self.class.name}#{base_url}#{hashable_string_for()}" end |
#encoded_body ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Mimics libcurls POST body generation. This is not accurate, but good enough for VCR.
175 176 177 |
# File 'lib/typhoeus/request.rb', line 175 def encoded_body Ethon::Easy::Form.new(nil, [:body]).to_s end |
#eql?(other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether other is equal to self.
145 146 147 148 149 |
# File 'lib/typhoeus/request.rb', line 145 def eql?(other) self.class == other.class && self.base_url == other.base_url && fuzzy_hash_eql?(self., other.) end |
#hash ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Overrides Object#hash.
156 157 158 |
# File 'lib/typhoeus/request.rb', line 156 def hash Zlib.crc32 cache_key end |
#url ⇒ Object
Return the url. In contrast to base_url which returns the value you specified, url returns the full url including the parameters.
128 129 130 131 132 133 |
# File 'lib/typhoeus/request.rb', line 128 def url easy = EasyFactory.new(self).get url = easy.url Typhoeus::Pool.release(easy) url end |