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 +4 -4
- data/.rubocop.yml +4 -0
- data/README.md +14 -4
- data/lib/http/connection.rb +1 -0
- data/lib/http/headers.rb +3 -4
- data/lib/http/options.rb +3 -1
- data/lib/http/request.rb +3 -1
- data/lib/http/response.rb +3 -1
- data/lib/http/timeout/global.rb +5 -2
- data/lib/http/version.rb +1 -1
- data/spec/support/http_handling_shared.rb +11 -0
- metadata +40 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54c45e83923cbc3784598961bd095891ecb59017
|
4
|
+
data.tar.gz: 4953e6ce3427e7db773c247930ecbf995d7723ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e848c550021771ef39648f5ceeeb0dc246df75be6558ccd2d5a4b04597d9f1c574c236ccdb6b944dd2c3b5433f6480bc51b0cd638e9b64eed82847ea11b84d1
|
7
|
+
data.tar.gz: 41f0d37cfa7f2c01ead717b15d3798a1a655cd1e5b2b4c69c06e1c97ada4dbe22fb90fab8efe952bce13c18c95e5af7900208442351294ad0aa959284561ff1a
|
data/.rubocop.yml
CHANGED
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
|
-
|
282
|
-
|
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 =>
|
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
|
|
data/lib/http/connection.rb
CHANGED
data/lib/http/headers.rb
CHANGED
@@ -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
|
121
|
-
return
|
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
|
|
data/lib/http/options.rb
CHANGED
data/lib/http/request.rb
CHANGED
@@ -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
|
76
|
+
@proxy = proxy
|
77
|
+
@body = body
|
78
|
+
@version = version
|
77
79
|
|
78
80
|
@headers = HTTP::Headers.coerce(headers || {})
|
79
81
|
|
data/lib/http/response.rb
CHANGED
@@ -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
|
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
|
data/lib/http/timeout/global.rb
CHANGED
@@ -6,8 +6,11 @@ module HTTP
|
|
6
6
|
def initialize(*args)
|
7
7
|
super
|
8
8
|
|
9
|
-
|
10
|
-
|
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)
|
data/lib/http/version.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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:
|