Module: Typhoeus
- Extended by:
- Typhoeus, Hydra::EasyPool, Request::Actions, Request::Callbacks::Types
- Included in:
- Typhoeus
- Defined in:
- lib/typhoeus.rb,
lib/typhoeus/hydra.rb,
lib/typhoeus/config.rb,
lib/typhoeus/errors.rb,
lib/typhoeus/request.rb,
lib/typhoeus/version.rb,
lib/typhoeus/response.rb,
lib/typhoeus/expectation.rb,
lib/typhoeus/hydra/before.rb,
lib/typhoeus/hydra/addable.rb,
lib/typhoeus/errors/no_stub.rb,
lib/typhoeus/hydra/runnable.rb,
lib/typhoeus/request/before.rb,
lib/typhoeus/hydra/easy_pool.rb,
lib/typhoeus/hydra/queueable.rb,
lib/typhoeus/hydra/stubbable.rb,
lib/typhoeus/request/actions.rb,
lib/typhoeus/request/marshal.rb,
lib/typhoeus/response/header.rb,
lib/typhoeus/response/status.rb,
lib/typhoeus/hydra/memoizable.rb,
lib/typhoeus/request/callbacks.rb,
lib/typhoeus/request/stubbable.rb,
lib/typhoeus/hydra/easy_factory.rb,
lib/typhoeus/request/memoizable.rb,
lib/typhoeus/request/operations.rb,
lib/typhoeus/request/responseable.rb,
lib/typhoeus/errors/typhoeus_error.rb,
lib/typhoeus/response/informations.rb,
lib/typhoeus/hydra/block_connection.rb,
lib/typhoeus/request/block_connection.rb
Overview
Typhoeus is a http client library based on Ethon which wraps libcurl. Sitting on top of libcurl make Typhoeus very reliable and fast.
There are some gems using Typhoeus like VCR, Webmock or Faraday. VCR and Webmock are providing their own adapter whereas Faraday relies on Faraday::Adapter::Typhoeus since Typhoeus version 0.5.
Defined Under Namespace
Modules: Config, Errors Classes: Expectation, Hydra, Request, Response
Constant Summary collapse
- USER_AGENT =
The default typhoeus user agent.
"Typhoeus - https://github.com/typhoeus/typhoeus"
- VERSION =
The current Typhoeus version.
'0.5.2'
Instance Method Summary collapse
-
#before(&block) {|Typhoeus::Request| ... } ⇒ Array<Block>
Add before callbacks.
-
#configure {|Typhoeus::Config| ... } ⇒ Typhoeus::Config
Set the Typhoeus configuration options by passing a block.
-
#stub(url, options = {}) ⇒ Typhoeus::Expectation
Stub out specific request.
-
#with_connection ⇒ Object
Execute given block as if block connection is turned off.
Methods included from Hydra::EasyPool
easy_pool, get_easy, release_easy
Methods included from Request::Actions
delete, get, head, options, patch, post, put
Methods included from Request::Callbacks::Types
on_complete, on_failure, on_success
Instance Method Details
#before(&block) {|Typhoeus::Request| ... } ⇒ Array<Block>
Add before callbacks.
83 84 85 86 87 |
# File 'lib/typhoeus.rb', line 83 def before(&block) @before ||= [] @before << block if block_given? @before end |
#configure {|Typhoeus::Config| ... } ⇒ Typhoeus::Config
Set the Typhoeus configuration options by passing a block.
50 51 52 |
# File 'lib/typhoeus.rb', line 50 def configure yield Config end |
#stub(url, options = {}) ⇒ Typhoeus::Expectation
Stub out specific request.
64 65 66 67 68 69 70 71 |
# File 'lib/typhoeus.rb', line 64 def stub(url, = {}) expectation = Expectation.all.find{ |e| e.url == url && e. == } return expectation if expectation Expectation.new(url, ).tap do |new_expectation| Expectation.all << new_expectation end end |
#with_connection ⇒ Object
Execute given block as if block connection is turned off. The old block connection state is restored afterwards.
107 108 109 110 111 112 113 |
# File 'lib/typhoeus.rb', line 107 def with_connection old = Config.block_connection Config.block_connection = false result = yield if block_given? Config.block_connection = old result end |