Module: Typhoeus
- Extended by:
- Typhoeus, Request::Actions, Request::Callbacks::Types
- Included in:
- Typhoeus
- Defined in:
- lib/typhoeus.rb,
lib/typhoeus/pool.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/easy_factory.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/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/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 makes 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, Pool Classes: EasyFactory, 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.6.1'
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(base_url, options = {}) ⇒ Typhoeus::Expectation
Stub out specific request.
-
#with_connection ⇒ Object
Execute given block as if block connection is turned off.
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.
95 96 97 98 99 |
# File 'lib/typhoeus.rb', line 95 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.
62 63 64 |
# File 'lib/typhoeus.rb', line 62 def configure yield Config end |
#stub(base_url, options = {}) ⇒ Typhoeus::Expectation
Stub out specific request.
76 77 78 79 80 81 82 83 |
# File 'lib/typhoeus.rb', line 76 def stub(base_url, = {}) expectation = Expectation.all.find{ |e| e.base_url == base_url && e. == } return expectation if expectation Expectation.new(base_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.
119 120 121 122 123 124 125 |
# File 'lib/typhoeus.rb', line 119 def with_connection old = Config.block_connection Config.block_connection = false result = yield if block_given? Config.block_connection = old result end |