Module: Typhoeus
- Extended by:
- Request::Actions, Request::Callbacks::Types
- 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/cache/dalli.rb,
lib/typhoeus/cache/rails.rb,
lib/typhoeus/cache/redis.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/cacheable.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/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/response/cacheable.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 provide their own adapter whereas Faraday relies on Faraday::Adapter::Typhoeus since Typhoeus version 0.5.
Defined Under Namespace
Modules: Cache, 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.
'1.4.0'
Class 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 = {}, &block) ⇒ Typhoeus::Expectation
Stub out a 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_headers, on_progress, on_success
Class Method Details
.before(&block) {|Typhoeus::Request| ... } ⇒ Array<Block>
Add before callbacks.
111 112 113 114 115 |
# File 'lib/typhoeus.rb', line 111 def self.before(&block) @before ||= [] @before << block if block_given? @before end |
.configure {|Typhoeus::Config| ... } ⇒ Typhoeus::Config
Set the Typhoeus configuration options by passing a block.
76 77 78 |
# File 'lib/typhoeus.rb', line 76 def self.configure yield Config end |
.stub(base_url, options = {}, &block) ⇒ Typhoeus::Expectation
Stub out a specific request.
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/typhoeus.rb', line 90 def self.stub(base_url, = {}, &block) expectation = Expectation.all.find{ |e| e.base_url == base_url && e. == } if expectation.nil? expectation = Expectation.new(base_url, ) Expectation.all << expectation end expectation.and_return(&block) unless block.nil? expectation end |
.with_connection { ... } ⇒ Object
Execute given block as if block connection is turned off. The old block connection state is restored afterwards.
136 137 138 139 140 141 142 |
# File 'lib/typhoeus.rb', line 136 def self.with_connection old = Config.block_connection Config.block_connection = false result = yield if block_given? Config.block_connection = old result end |