http 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c22451fa65c5d83ca271a7ac53671dd039f66f6a
4
- data.tar.gz: ceea0aa11f428af8569bd18de9b188bce8cf65c1
3
+ metadata.gz: 54c45e83923cbc3784598961bd095891ecb59017
4
+ data.tar.gz: 4953e6ce3427e7db773c247930ecbf995d7723ef
5
5
  SHA512:
6
- metadata.gz: 624d636385c6eac2b23ac9c1d11b631b676120344db7904381a85b02f4d19e977d6adfc9d3b42a862ea0567052a3ecac19df8818479ff4922a955847c672f0dd
7
- data.tar.gz: 5721fc63432acfc6969bc6c6267d2c54565001b09d60e610113a89ebdf84890ef51a2a5ed3e8bdf2bf9a2c6db699fc364b23a666e3e438555edca5b1ad783445
6
+ metadata.gz: 7e848c550021771ef39648f5ceeeb0dc246df75be6558ccd2d5a4b04597d9f1c574c236ccdb6b944dd2c3b5433f6480bc51b0cd638e9b64eed82847ea11b84d1
7
+ data.tar.gz: 41f0d37cfa7f2c01ead717b15d3798a1a655cd1e5b2b4c69c06e1c97ada4dbe22fb90fab8efe952bce13c18c95e5af7900208442351294ad0aa959284561ff1a
@@ -19,6 +19,10 @@ Metrics/MethodLength:
19
19
  CountComments: false
20
20
  Max: 22 # TODO: Lower to 15
21
21
 
22
+ Metrics/ModuleLength:
23
+ CountComments: false
24
+ Max: 120
25
+
22
26
  Metrics/ParameterLists:
23
27
  Max: 3
24
28
  CountKeywordArgs: true
data/README.md CHANGED
@@ -253,7 +253,6 @@ There's a little more to it, but that's the core idea!
253
253
  * [Full parallel HTTP fetcher example](https://github.com/httprb/http.rb/wiki/Parallel-requests-with-Celluloid%3A%3AIO)
254
254
  * See also: [Celluloid::IO](https://github.com/celluloid/celluloid-io)
255
255
 
256
-
257
256
  ### Caching
258
257
 
259
258
  http.rb provides caching of HTTP request (per
@@ -278,13 +277,24 @@ storage URL supported by rack-cache is supported by http.rb's cache.
278
277
 
279
278
  ### Timeouts
280
279
 
281
- You can configure http.rb to fail if request (connect / read / write) takes too
282
- long:
280
+ By default, HTTP does not timeout on a request. You can enable per operation (each read/write/connect call) or global (sum of all read/write/connect calls).
281
+
282
+ Per operation timeouts are what `Net::HTTP` and the majority of HTTP clients do:
283
+
284
+ ``` ruby
285
+ HTTP.timeout(:per_operation, :write => 2, :connect => 5, :read => 10).get "http://example.com"
286
+ ```
287
+
288
+ Global timeouts let you set an upper bound of how long a request can take, without having to rely on `Timeout.timeout`:
283
289
 
284
290
  ``` ruby
285
- HTTP.timeout(:connect => 5, :read => 10).get "http://example.com"
291
+ HTTP.timeout(:global, :write => 1, :connect => 1, :read => 1).get "http://example.com"
286
292
  ```
287
293
 
294
+ Uses a timeout of 3 seconds, for the entire `get` call.
295
+
296
+ *Warning!* You cannot use Celluloid::IO with timeouts currently.
297
+
288
298
 
289
299
  ## Supported Ruby Versions
290
300
 
@@ -105,6 +105,7 @@ module HTTP
105
105
  close unless keep_alive?
106
106
 
107
107
  @parser.reset
108
+ @socket.reset_counter if @socket.respond_to?(:reset_counter)
108
109
  reset_timer
109
110
 
110
111
  @pending_response = false
@@ -117,10 +117,9 @@ module HTTP
117
117
  #
118
118
  # @return [Enumerator] if no block given
119
119
  # @return [Headers] self-reference
120
- def each(&blk)
121
- return @pile.each unless blk
122
-
123
- @pile.each(&blk)
120
+ def each
121
+ return to_enum(__method__) unless block_given?
122
+ @pile.each { |arr| yield(arr) }
124
123
  self
125
124
  end
126
125
 
@@ -104,7 +104,9 @@ module HTTP
104
104
  end
105
105
 
106
106
  def merge(other)
107
- h1, h2 = to_hash, other.to_hash
107
+ h1 = to_hash
108
+ h2 = other.to_hash
109
+
108
110
  merged = h1.merge(h2) do |k, v1, v2|
109
111
  case k
110
112
  when :headers
@@ -73,7 +73,9 @@ module HTTP
73
73
  fail(UnsupportedMethodError, "unknown method: #{verb}") unless METHODS.include?(@verb)
74
74
  fail(UnsupportedSchemeError, "unknown scheme: #{scheme}") unless SCHEMES.include?(@scheme)
75
75
 
76
- @proxy, @body, @version = proxy, body, version
76
+ @proxy = proxy
77
+ @body = body
78
+ @version = version
77
79
 
78
80
  @headers = HTTP::Headers.coerce(headers || {})
79
81
 
@@ -30,7 +30,9 @@ module HTTP
30
30
  attr_reader :uri
31
31
 
32
32
  def initialize(status, version, headers, body, uri = nil) # rubocop:disable ParameterLists
33
- @version, @body, @uri = version, body, uri
33
+ @version = version
34
+ @body = body
35
+ @uri = uri
34
36
  @status = HTTP::Response::Status.new status
35
37
  @headers = HTTP::Headers.coerce(headers || {})
36
38
  end
@@ -6,8 +6,11 @@ module HTTP
6
6
  def initialize(*args)
7
7
  super
8
8
 
9
- @time_left = connect_timeout + read_timeout + write_timeout
10
- @total_timeout = time_left
9
+ reset_counter
10
+ end
11
+
12
+ def reset_counter
13
+ @time_left = @total_timeout = connect_timeout + read_timeout + write_timeout
11
14
  end
12
15
 
13
16
  def connect(socket_class, host, port)
@@ -1,3 +1,3 @@
1
1
  module HTTP
2
- VERSION = "0.8.5"
2
+ VERSION = "0.8.6"
3
3
  end
@@ -85,6 +85,17 @@ RSpec.shared_context "HTTP handling" do
85
85
  expect { client.get("#{server.endpoint}/sleep").body.to_s }.
86
86
  to raise_error(HTTP::TimeoutError, /Timed out/)
87
87
  end
88
+
89
+ context "it resets state when reusing connections" do
90
+ let(:options) { {:persistent => server.endpoint} }
91
+
92
+ let(:read_timeout) { 3 }
93
+
94
+ it "does not timeout" do
95
+ client.get("#{server.endpoint}/sleep").body.to_s
96
+ client.get("#{server.endpoint}/sleep").body.to_s
97
+ end
98
+ end
88
99
  end
89
100
  end
90
101
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-05-06 00:00:00.000000000 Z
14
+ date: 2015-05-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: http_parser.rb
@@ -181,9 +181,45 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 2.2.2
184
+ rubygems_version: 2.4.6
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: HTTP should be easy
188
- test_files: []
188
+ test_files:
189
+ - spec/lib/http/cache/headers_spec.rb
190
+ - spec/lib/http/cache_spec.rb
191
+ - spec/lib/http/client_spec.rb
192
+ - spec/lib/http/content_type_spec.rb
193
+ - spec/lib/http/headers/mixin_spec.rb
194
+ - spec/lib/http/headers_spec.rb
195
+ - spec/lib/http/options/body_spec.rb
196
+ - spec/lib/http/options/form_spec.rb
197
+ - spec/lib/http/options/headers_spec.rb
198
+ - spec/lib/http/options/json_spec.rb
199
+ - spec/lib/http/options/merge_spec.rb
200
+ - spec/lib/http/options/new_spec.rb
201
+ - spec/lib/http/options/proxy_spec.rb
202
+ - spec/lib/http/options_spec.rb
203
+ - spec/lib/http/redirector_spec.rb
204
+ - spec/lib/http/request/caching_spec.rb
205
+ - spec/lib/http/request/writer_spec.rb
206
+ - spec/lib/http/request_spec.rb
207
+ - spec/lib/http/response/body_spec.rb
208
+ - spec/lib/http/response/caching_spec.rb
209
+ - spec/lib/http/response/io_body_spec.rb
210
+ - spec/lib/http/response/status_spec.rb
211
+ - spec/lib/http/response/string_body_spec.rb
212
+ - spec/lib/http/response_spec.rb
213
+ - spec/lib/http_spec.rb
214
+ - spec/spec_helper.rb
215
+ - spec/support/black_hole.rb
216
+ - spec/support/capture_warning.rb
217
+ - spec/support/connection_reuse_shared.rb
218
+ - spec/support/dummy_server.rb
219
+ - spec/support/dummy_server/servlet.rb
220
+ - spec/support/http_handling_shared.rb
221
+ - spec/support/proxy_server.rb
222
+ - spec/support/servers/config.rb
223
+ - spec/support/servers/runner.rb
224
+ - spec/support/ssl_helper.rb
189
225
  has_rdoc: