typhoeus 0.7.0.pre1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzFhNDA4NzIxZjBjODEyOGU0NGM3MGU4Y2E3NzRjMmRlNDg2YTY0Mg==
4
+ N2YzYzcwNTg0NGRkNzIwOWM0MTJlZWM3OTU0NDU0MWFjMWIxMzY5Mw==
5
5
  data.tar.gz: !binary |-
6
- MWQwYWI4Yjk0ZDM0MWY0ZGE0Y2JmMTQ1NjJhNzRiY2M3MmJhNDM2OQ==
6
+ MGY3YTAxZTUzNTdkYzVhZDlkZGJlZWQ0YWQwMjRmNmU5ZjBmODMzMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDZlYmY3MmVlN2U3YTFkOGYxODU4MGYyMzE1NTZjMzViNWY2NTc2YWEzMTQy
10
- NDhlYzE3N2I4MDM5NTYzY2JkMWNmYmI4MmNhNjg3ZjZmMmVlNGZmYWJkNGU2
11
- NzExODBlMmUyMzgyODZjMjg1N2I1ZTU4ODQwZGEwNzQwNGU2MGE=
9
+ MWYzMGQ5NzU4ODQ0MGE1MjdkMmU0NzE1N2I5Y2QwM2Q5MTA5ZDY2MzdiMWI3
10
+ YTNjMzZmYmMwOTQ5ZGMyNzczZDliNzQ1NzA5NTI3MWQ1MTUyODM2YjBkM2E5
11
+ YmU1OWZmN2EyNDI4ZTkzZTBhMzMzZGM5ZmZiZGM5MGQyMDM2MDM=
12
12
  data.tar.gz: !binary |-
13
- ZjVmOTFlMzExYTI4YzlhOWViYTMzZDE1M2FlY2U0Y2JlMWE5OWQ5Nzk4ZmUy
14
- ZTI1YTE3NzAyNTM5YWFlNzk3NWQ5MDQ2ZTlhNDdmMGJkZjFhYmQyZDc4OTlm
15
- YzQ4OGYzODM5NTNlYjFjZGFlZjA0YmEzOGFkMGUwOTViMzY3NDI=
13
+ MjliYzk1ZWI2NGRlYmYzOWI0NmQyZmU4ZTM4YzkwZmQyMTkwNzczNTg3YTVm
14
+ NmZlNDcxM2MyMDVjYWNhODA0YzM5ZDYzZWEyMDY2YTRhZGYwMzMxZTc2ODAy
15
+ MTYwOTc5NWEzM2QzNmQwNTFhNWEzMDkzMThhM2ZjNWVkNWY5MTY=
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0
4
+
5
+ [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v0.7.0.pre1...v0.7.0)
6
+
7
+ Bugfixes:
8
+
9
+ * Call on_headers and on_body when using stubbed responses.
10
+
3
11
  ## 0.7.0.pre1
4
12
 
5
13
  [Full Changelog](http://github.com/typhoeus/typhoeus/compare/v0.6.9...v0.7.0.pre1)
@@ -7,7 +15,7 @@
7
15
  Enhancements:
8
16
 
9
17
  * Improving timeout behavior and documentation. `no_signal` is now set per default!
10
- ([Jonas Wagner](https://github.com/jwagner), [\#398](https://github.com/typhoeus/typhoeus/pull/398)
18
+ ([Jonas Wagner](https://github.com/jwagner), [\#398](https://github.com/typhoeus/typhoeus/pull/398))
11
19
 
12
20
  ## 0.6.8
13
21
 
@@ -16,7 +24,7 @@ Enhancements:
16
24
  Bugfixes:
17
25
 
18
26
  * Fix Faraday 0.9 compatibility.
19
- ([Gleb Mazovetskiy](https://github.com/glebm), [\#357](https://github.com/typhoeus/typhoeus/pull/357)
27
+ ([Gleb Mazovetskiy](https://github.com/glebm), [\#357](https://github.com/typhoeus/typhoeus/pull/357))
20
28
  * Fix Request#hash for different key orders.
21
29
  ([Matthew Schulkind](https://github.com/mschulkind), [\#344](https://github.com/typhoeus/typhoeus/pull/344))
22
30
 
data/README.md CHANGED
@@ -86,8 +86,10 @@ Typhoeus has some convenience methods for performing single HTTP requests. The a
86
86
  Typhoeus.get("www.example.com")
87
87
  Typhoeus.head("www.example.com")
88
88
  Typhoeus.put("www.example.com/posts/1", body: "whoo, a body")
89
+ Typhoeus.patch("www.example.com/posts/1", body: "a new body")
89
90
  Typhoeus.post("www.example.com/posts", body: { title: "test post", content: "this is my test"})
90
91
  Typhoeus.delete("www.example.com/posts/1")
92
+ Typhoeus.options("www.example.com")
91
93
  ```
92
94
 
93
95
  ### Handling HTTP errors
@@ -149,7 +151,7 @@ Typhoeus will not store the complete response.
149
151
  downloaded_file = File.open 'huge.iso', 'wb'
150
152
  request = Typhoeus::Request.new("www.example.com/huge.iso")
151
153
  request.on_headers do |response|
152
- if ! response.success?
154
+ if response.code != 200
153
155
  raise "Request failed"
154
156
  end
155
157
  end
@@ -189,9 +191,9 @@ How to get an array of response bodies back after executing a queue:
189
191
 
190
192
  ```ruby
191
193
  hydra = Typhoeus::Hydra.new
192
- requests = 10.times.map {
194
+ requests = 10.times.map {
193
195
  request = Typhoeus::Request.new("www.example.com", followlocation: true)
194
- hydra.queue(request)
196
+ hydra.queue(request)
195
197
  request
196
198
  }
197
199
  hydra.run
@@ -204,7 +206,7 @@ responses = requests.map { |request|
204
206
 
205
207
  ```ruby
206
208
  hydra = Typhoeus::Hydra.new
207
- 10.times do
209
+ 10.times do
208
210
  request = Typhoeus::Request.new("www.example.com", followlocation: true)
209
211
  request.on_complete do |response|
210
212
  #do_something_with response
@@ -16,6 +16,8 @@ module Typhoeus
16
16
  # hydra.add(request)
17
17
  def add(request)
18
18
  if response = Expectation.response_for(request)
19
+ request.execute_headers_callbacks(response)
20
+ request.on_body.each{ |callback| callback.call(response.body, response) }
19
21
  request.finish(response)
20
22
  else
21
23
  super
@@ -18,6 +18,8 @@ module Typhoeus
18
18
  # @return [ Response ] The response.
19
19
  def run
20
20
  if response = Expectation.response_for(self)
21
+ execute_headers_callbacks(response)
22
+ self.on_body.each{ |callback| callback.call(response.body, response) }
21
23
  finish(response)
22
24
  else
23
25
  super
@@ -110,7 +110,7 @@ module Typhoeus
110
110
  # until the SSL/SSH connect/handshake to the remote
111
111
  # host was completed. This time is most often very near
112
112
  # to the pre transfer time, except for cases such as HTTP
113
- # pippelining where the pretransfer time can be delayed
113
+ # pipelining where the pretransfer time can be delayed
114
114
  # due to waits in line for the pipeline and more.
115
115
  #
116
116
  # @example Get appconnect_time.
@@ -1,5 +1,5 @@
1
1
  module Typhoeus
2
2
 
3
3
  # The current Typhoeus version.
4
- VERSION = '0.7.0.pre1'
4
+ VERSION = '0.7.0'
5
5
  end
@@ -14,6 +14,26 @@ describe Typhoeus::Hydra::Stubbable do
14
14
  end
15
15
 
16
16
  context "when expectation found" do
17
+ it "calls on_headers callbacks" do
18
+ canary = :not_called
19
+ request.on_headers do
20
+ canary = :called
21
+ end
22
+ hydra.add(request)
23
+ hydra.run
24
+ expect(canary).to eq(:called)
25
+ end
26
+
27
+ it "calls on_body callbacks" do
28
+ canary = :not_called
29
+ request.on_body do
30
+ canary = :called
31
+ end
32
+ hydra.add(request)
33
+ hydra.run
34
+ expect(canary).to eq(:called)
35
+ end
36
+
17
37
  it "finishes response" do
18
38
  expect(request).to receive(:finish)
19
39
  hydra.add(request)
@@ -13,6 +13,24 @@ describe Typhoeus::Request::Stubbable do
13
13
  end
14
14
 
15
15
  context "when expectation found" do
16
+ it "calls on_headers callbacks" do
17
+ canary = :not_called
18
+ request.on_headers do
19
+ canary = :called
20
+ end
21
+ request.run
22
+ expect(canary).to eq(:called)
23
+ end
24
+
25
+ it "calls on_body callbacks" do
26
+ canary = :not_called
27
+ request.on_body do
28
+ canary = :called
29
+ end
30
+ request.run
31
+ expect(canary).to eq(:called)
32
+ end
33
+
16
34
  it "finishes request" do
17
35
  expect(request).to receive(:finish)
18
36
  request.run
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typhoeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.pre1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Balatero
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-11-03 00:00:00.000000000 Z
13
+ date: 2015-01-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ethon