http 0.9.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +1 -0
- data/CHANGES.md +143 -92
- data/Gemfile +4 -4
- data/README.md +8 -27
- data/lib/http/chainable.rb +13 -30
- data/lib/http/client.rb +17 -12
- data/lib/http/connection.rb +10 -7
- data/lib/http/errors.rb +3 -0
- data/lib/http/headers.rb +0 -3
- data/lib/http/options.rb +9 -12
- data/lib/http/request/writer.rb +14 -12
- data/lib/http/request.rb +23 -14
- data/lib/http/response/body.rb +7 -6
- data/lib/http/response/parser.rb +2 -1
- data/lib/http/response/status.rb +1 -3
- data/lib/http/response.rb +31 -28
- data/lib/http/timeout/global.rb +2 -1
- data/lib/http/timeout/null.rb +2 -1
- data/lib/http/timeout/per_operation.rb +2 -1
- data/lib/http/version.rb +1 -1
- data/lib/http.rb +0 -2
- data/logo.png +0 -0
- data/spec/lib/http/client_spec.rb +25 -16
- data/spec/lib/http/options/merge_spec.rb +3 -1
- data/spec/lib/http/options_spec.rb +2 -3
- data/spec/lib/http/redirector_spec.rb +39 -34
- data/spec/lib/http/request/writer_spec.rb +3 -3
- data/spec/lib/http/request_spec.rb +41 -7
- data/spec/lib/http/response/body_spec.rb +1 -1
- data/spec/lib/http/response/status_spec.rb +3 -3
- data/spec/lib/http/response_spec.rb +10 -1
- data/spec/lib/http_spec.rb +66 -7
- data/spec/spec_helper.rb +2 -2
- data/spec/support/connection_reuse_shared.rb +1 -1
- data/spec/support/dummy_server/servlet.rb +7 -0
- data/spec/support/http_handling_shared.rb +7 -1
- metadata +3 -4
- data/examples/parallel_requests_with_celluloid.rb +0 -38
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58370408adc111fae0f96e4541839c2a0722ccf5
|
|
4
|
+
data.tar.gz: f3f4ff7f0ba274d7f9c969db7f65d01b134f5711
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8c18ee7df2159660a8ff5909bdac66e61bcc8e598a1be9d5ae13f825cc704112c3a67aaef633396acd22ca395ac2762bc17b48faccf6472c27eb8c31b8e6cc16
|
|
7
|
+
data.tar.gz: bb8e776f129502b8aa1b63be4ee1f935b430a2e4db3f8e613ff96d03059af8137e3760a1a553e4f85a76679a8e7e894ef175e6bc792aa199c46aa053a74f5967
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
|
@@ -1,179 +1,229 @@
|
|
|
1
|
+
## 1.0.0 (2015-12-25)
|
|
2
|
+
|
|
3
|
+
* [#265](https://github.com/httprb/http/pull/265/):
|
|
4
|
+
Remove deprecations ([@tarcieri]):
|
|
5
|
+
- HTTP::Chainable#with_follow (use #follow)
|
|
6
|
+
- HTTP::Chainable#with, #with_headers (use #headers)
|
|
7
|
+
- HTTP::Chainable#auth(:basic, ...) (use #basic_auth)
|
|
8
|
+
- HTTP::Chainable#default_headers (use #default_options[:headers])
|
|
9
|
+
- HTTP::Headers#append (use #add)
|
|
10
|
+
- HTTP::Options#[] hash-like API deprecated in favor of explicit methods
|
|
11
|
+
- HTTP::Request#request_header (use #headline)
|
|
12
|
+
- HTTP::Response::STATUS_CODES (use HTTP::Status::REASONS)
|
|
13
|
+
- HTTP::Response::SYMBOL_TO_STATUS_CODE (no replacement)
|
|
14
|
+
- HTTP::Response#status_code (use #status or #code)
|
|
15
|
+
- HTTP::Response::Status#symbolize (use #to_sym)
|
|
16
|
+
|
|
17
|
+
* [#269](https://github.com/httprb/http/pull/273/):
|
|
18
|
+
Close connection in case of error during request.
|
|
19
|
+
([@ixti])
|
|
20
|
+
|
|
21
|
+
* [#271](https://github.com/httprb/http/pull/273/):
|
|
22
|
+
High-level exception wrappers for low-level I/O errors.
|
|
23
|
+
([@ixti])
|
|
24
|
+
|
|
25
|
+
* [#273](https://github.com/httprb/http/pull/273/):
|
|
26
|
+
Add encoding option.
|
|
27
|
+
([@connorhd])
|
|
28
|
+
|
|
29
|
+
* [#275](https://github.com/httprb/http/pull/273/):
|
|
30
|
+
Support for disabling Nagle's algorithm with `HTTP.nodelay`.
|
|
31
|
+
([@nerdrew])
|
|
32
|
+
|
|
33
|
+
* [#276](https://github.com/httprb/http/pull/276)
|
|
34
|
+
Use Encoding::BINARY as the default encoding for HTTP::Response::Body.
|
|
35
|
+
([@tarcieri])
|
|
36
|
+
|
|
37
|
+
* [#278](https://github.com/httprb/http/pull/278)
|
|
38
|
+
Use an options hash for HTTP::Request initializer API.
|
|
39
|
+
([@ixti])
|
|
40
|
+
|
|
41
|
+
* [#279](https://github.com/httprb/http/pull/279)
|
|
42
|
+
Send headers and body in one write if possible.
|
|
43
|
+
This avoids a pathological case in Nagle's algorithm.
|
|
44
|
+
([@tarcieri])
|
|
45
|
+
|
|
46
|
+
* [#281](https://github.com/httprb/http/pull/281)
|
|
47
|
+
Remove legacy 'Http' constant alias to 'HTTP'.
|
|
48
|
+
([@tarcieri])
|
|
49
|
+
|
|
1
50
|
## 0.9.8 (2015-09-29)
|
|
2
51
|
|
|
3
52
|
* [#260](https://github.com/httprb/http/pull/258):
|
|
4
53
|
Fixed global timeout persisting time left across requests when reusing connections.
|
|
5
|
-
([@zanker]
|
|
54
|
+
([@zanker])
|
|
55
|
+
|
|
6
56
|
|
|
7
57
|
## 0.9.7 (2015-09-19)
|
|
8
58
|
|
|
9
59
|
* [#258](https://github.com/httprb/http/pull/258):
|
|
10
60
|
Unified strategy for handling exception-based and exceptionless non-blocking
|
|
11
|
-
I/O. Fixes SSL support on JRuby 9000. ([@tarcieri]
|
|
61
|
+
I/O. Fixes SSL support on JRuby 9000. ([@tarcieri])
|
|
12
62
|
|
|
13
63
|
|
|
14
64
|
## 0.9.6 (2015-09-06)
|
|
15
65
|
|
|
16
66
|
* [#254](https://github.com/httprb/http/pull/254):
|
|
17
67
|
Removed use of an ActiveSupport specific method #present?
|
|
18
|
-
([@tarcieri]
|
|
68
|
+
([@tarcieri])
|
|
19
69
|
|
|
20
70
|
|
|
21
71
|
## 0.9.5 (2015-09-06)
|
|
22
72
|
|
|
23
73
|
* [#252](https://github.com/httprb/http/pull/252):
|
|
24
74
|
Fixed infinite hang/timeout when a request contained more than ~16,363 bytes.
|
|
25
|
-
([@zanker]
|
|
75
|
+
([@zanker])
|
|
26
76
|
|
|
27
77
|
|
|
28
78
|
## 0.9.4 (2015-08-26)
|
|
29
79
|
|
|
30
80
|
* [#246](https://github.com/httprb/http/issues/246):
|
|
31
81
|
Fixes regression when body streaming was failing on some URIs.
|
|
32
|
-
([@zanker]
|
|
82
|
+
([@zanker])
|
|
33
83
|
* [#243](https://github.com/httprb/http/issues/243):
|
|
34
|
-
Fixes require timeout statements. ([@ixti]
|
|
84
|
+
Fixes require timeout statements. ([@ixti])
|
|
35
85
|
|
|
36
86
|
|
|
37
87
|
## 0.9.3 (2015-08-19)
|
|
38
88
|
|
|
39
89
|
* [#246](https://github.com/httprb/http/issues/246):
|
|
40
|
-
Fixed request URI normalization. ([@ixti]
|
|
90
|
+
Fixed request URI normalization. ([@ixti])
|
|
41
91
|
- Avoids query component normalization
|
|
42
92
|
- Omits fragment component in headline
|
|
43
93
|
|
|
44
94
|
|
|
45
95
|
## 0.9.2 (2015-08-18)
|
|
46
96
|
|
|
47
|
-
* Fixed exceptionless NIO EOF handling. ([@zanker]
|
|
97
|
+
* Fixed exceptionless NIO EOF handling. ([@zanker])
|
|
48
98
|
|
|
49
99
|
|
|
50
100
|
## 0.9.1 (2015-08-14)
|
|
51
101
|
|
|
52
102
|
* [#246](https://github.com/httprb/http/issues/246):
|
|
53
|
-
Fix params special-chars escaping. ([@ixti]
|
|
103
|
+
Fix params special-chars escaping. ([@ixti])
|
|
54
104
|
|
|
55
105
|
|
|
56
106
|
## 0.9.0 (2015-07-23)
|
|
57
107
|
|
|
58
108
|
* [#240](https://github.com/httprb/http/pull/240):
|
|
59
|
-
Support for caching removed. ([@tarcieri]
|
|
109
|
+
Support for caching removed. ([@tarcieri])
|
|
60
110
|
* JRuby 9000 compatibility
|
|
61
111
|
|
|
62
112
|
|
|
63
113
|
## 0.8.14 (2015-08-19)
|
|
64
114
|
|
|
65
|
-
* Backport request URI normalization fixes from master. ([@ixti]
|
|
115
|
+
* Backport request URI normalization fixes from master. ([@ixti])
|
|
66
116
|
|
|
67
117
|
|
|
68
118
|
## 0.8.13 (2015-08-14)
|
|
69
119
|
|
|
70
|
-
* Backport params special-chars escaping fix from `v0.9.1`. ([@ixti]
|
|
120
|
+
* Backport params special-chars escaping fix from `v0.9.1`. ([@ixti])
|
|
71
121
|
|
|
72
122
|
|
|
73
123
|
## 0.8.12 (2015-05-26)
|
|
74
124
|
|
|
75
|
-
* Fix `HTTP.timeout` API (was loosing previously defined options). ([@ixti]
|
|
125
|
+
* Fix `HTTP.timeout` API (was loosing previously defined options). ([@ixti])
|
|
76
126
|
|
|
77
127
|
|
|
78
128
|
## 0.8.11 (2015-05-22)
|
|
79
129
|
|
|
80
130
|
* [#229](https://github.com/httprb/http/pull/229):
|
|
81
|
-
SNI support for HTTPS connections. ([@tarcieri]
|
|
131
|
+
SNI support for HTTPS connections. ([@tarcieri])
|
|
82
132
|
* [#227](https://github.com/httprb/http/pull/227):
|
|
83
|
-
Use "http.rb" in the User-Agent string. ([@tarcieri]
|
|
133
|
+
Use "http.rb" in the User-Agent string. ([@tarcieri])
|
|
84
134
|
|
|
85
135
|
|
|
86
136
|
## 0.8.10 (2015-05-14)
|
|
87
137
|
|
|
88
|
-
* Fix cookie headers generation. ([@ixti]
|
|
138
|
+
* Fix cookie headers generation. ([@ixti])
|
|
89
139
|
|
|
90
140
|
|
|
91
141
|
## 0.8.9 (2015-05-11)
|
|
92
142
|
|
|
93
|
-
* Add cookies support. ([@ixti]
|
|
143
|
+
* Add cookies support. ([@ixti])
|
|
94
144
|
* [#219](https://github.com/httprb/http/pull/219):
|
|
95
|
-
Enforce stringified body encoding. ([@Connorhd]
|
|
145
|
+
Enforce stringified body encoding. ([@Connorhd])
|
|
96
146
|
|
|
97
147
|
|
|
98
148
|
## 0.8.8 (2015-05-09)
|
|
99
149
|
|
|
100
150
|
* [#217](https://github.com/httprb/http/issues/217):
|
|
101
|
-
Fix CONNECT header for proxies. ([@Connorhd]
|
|
151
|
+
Fix CONNECT header for proxies. ([@Connorhd])
|
|
102
152
|
|
|
103
153
|
|
|
104
154
|
## 0.8.7 (2015-05-08)
|
|
105
155
|
|
|
106
|
-
* Fix `HTTP.timeout` API with options only given. ([@ixti]
|
|
156
|
+
* Fix `HTTP.timeout` API with options only given. ([@ixti])
|
|
107
157
|
|
|
108
158
|
|
|
109
159
|
## 0.8.6 (2015-05-08)
|
|
110
160
|
|
|
111
161
|
* [#215](https://github.com/httprb/http/pull/215):
|
|
112
|
-
Reset global timeouts after the request finishes. ([@zanker]
|
|
162
|
+
Reset global timeouts after the request finishes. ([@zanker])
|
|
113
163
|
|
|
114
164
|
|
|
115
165
|
## 0.8.5 (2015-05-06)
|
|
116
166
|
|
|
117
167
|
* [#205](https://github.com/httprb/http/issues/205):
|
|
118
|
-
Add simple timeouts configuration API. ([@ixti]
|
|
119
|
-
* Deprecate `Request#request_header`. Use `Request#headline` instead. ([@ixti]
|
|
168
|
+
Add simple timeouts configuration API. ([@ixti])
|
|
169
|
+
* Deprecate `Request#request_header`. Use `Request#headline` instead. ([@ixti])
|
|
120
170
|
|
|
121
171
|
|
|
122
172
|
## 0.8.4 (2015-04-23)
|
|
123
173
|
|
|
124
|
-
* Deprecate `#default_headers` and `#default_headers=`. ([@ixti]
|
|
174
|
+
* Deprecate `#default_headers` and `#default_headers=`. ([@ixti])
|
|
125
175
|
* [#207](https://github.com/httprb/http/issues/207):
|
|
126
|
-
Deprecate chainable methods with `with_` prefix. ([@ixti]
|
|
176
|
+
Deprecate chainable methods with `with_` prefix. ([@ixti])
|
|
127
177
|
* [#186](https://github.com/httprb/http/pull/186):
|
|
128
|
-
Add support of HTTPS connections through proxy. ([@Connorhd]
|
|
178
|
+
Add support of HTTPS connections through proxy. ([@Connorhd])
|
|
129
179
|
|
|
130
180
|
|
|
131
181
|
## 0.8.3 (2015-04-07)
|
|
132
182
|
|
|
133
183
|
* [#206](https://github.com/httprb/http/issues/206):
|
|
134
|
-
Fix request headline. ([@ixti]
|
|
135
|
-
* Remove deprecated `Request#__method__`. ([@ixti]
|
|
184
|
+
Fix request headline. ([@ixti])
|
|
185
|
+
* Remove deprecated `Request#__method__`. ([@ixti])
|
|
136
186
|
|
|
137
187
|
|
|
138
188
|
## 0.8.2 (2015-04-06)
|
|
139
189
|
|
|
140
190
|
* [#203](https://github.com/httprb/http/issues/203):
|
|
141
|
-
Fix Celluloid::IO compatibility. ([@ixti]
|
|
142
|
-
* Cleanup obsolete code. ([@zanker]
|
|
191
|
+
Fix Celluloid::IO compatibility. ([@ixti])
|
|
192
|
+
* Cleanup obsolete code. ([@zanker])
|
|
143
193
|
|
|
144
194
|
|
|
145
195
|
## 0.8.1 (2015-04-02)
|
|
146
196
|
|
|
147
197
|
* [#202](https://github.com/httprb/http/issues/202):
|
|
148
|
-
Add missing `require "resolv"`. ([@ixti]
|
|
198
|
+
Add missing `require "resolv"`. ([@ixti])
|
|
149
199
|
* [#200](https://github.com/httprb/http/issues/200),
|
|
150
200
|
[#201](https://github.com/httprb/http/pull/201):
|
|
151
|
-
Add block-form `#persistent` calls. ([@ixti]
|
|
201
|
+
Add block-form `#persistent` calls. ([@ixti])
|
|
152
202
|
|
|
153
203
|
|
|
154
204
|
## 0.8.0 (2015-04-01)
|
|
155
205
|
|
|
156
206
|
* [#199](https://github.com/httprb/http/pull/199):
|
|
157
|
-
Properly handle WaitWritable for SSL. ([@zanker]
|
|
207
|
+
Properly handle WaitWritable for SSL. ([@zanker])
|
|
158
208
|
* [#197](https://github.com/httprb/http/pull/197):
|
|
159
|
-
Add support for non-ASCII URis. ([@ixti]
|
|
209
|
+
Add support for non-ASCII URis. ([@ixti])
|
|
160
210
|
* [#187](https://github.com/httprb/http/pull/187),
|
|
161
211
|
[#194](https://github.com/httprb/http/pull/194),
|
|
162
212
|
[#195](https://github.com/httprb/http/pull/195):
|
|
163
|
-
Add configurable connection timeouts. ([@zanker]
|
|
213
|
+
Add configurable connection timeouts. ([@zanker])
|
|
164
214
|
* [#179](https://github.com/httprb/http/pull/179):
|
|
165
|
-
Refactor requests redirect following logic. ([@ixti]
|
|
166
|
-
* Support for persistent HTTP connections ([@zanker]
|
|
215
|
+
Refactor requests redirect following logic. ([@ixti])
|
|
216
|
+
* Support for persistent HTTP connections ([@zanker])
|
|
167
217
|
* [#77](https://github.com/httprb/http/issues/77),
|
|
168
218
|
[#177](https://github.com/httprb/http/pull/177):
|
|
169
|
-
Add caching support. ([@Asmod4n]
|
|
219
|
+
Add caching support. ([@Asmod4n], [@pezra])
|
|
170
220
|
* [#176](https://github.com/httprb/http/pull/176):
|
|
171
221
|
Improve servers used in specs boot up. Issue was initially raised up
|
|
172
|
-
by [@olegkovalenko]
|
|
173
|
-
* Reflect FormData rename changes (FormData -> HTTP::FormData). ([@ixti]
|
|
222
|
+
by [@olegkovalenko]. ([@ixti])
|
|
223
|
+
* Reflect FormData rename changes (FormData -> HTTP::FormData). ([@ixti])
|
|
174
224
|
* [#173](https://github.com/httprb/http/pull/173):
|
|
175
225
|
`HTTP::Headers` now raises `HTTP::InvalidHeaderNameError` in case of
|
|
176
|
-
(surprise) invalid HTTP header field name (e.g.`"Foo:Bar"`). ([@ixti]
|
|
226
|
+
(surprise) invalid HTTP header field name (e.g.`"Foo:Bar"`). ([@ixti])
|
|
177
227
|
|
|
178
228
|
|
|
179
229
|
## 0.7.3 (2015-03-24)
|
|
@@ -181,7 +231,7 @@
|
|
|
181
231
|
* SECURITY FIX: http.rb failed to call the `#post_connection_check` method on
|
|
182
232
|
SSL connections. This method implements hostname verification, and without it
|
|
183
233
|
`http.rb` was vulnerable to MitM attacks. The problem was corrected by calling
|
|
184
|
-
`#post_connection_check` (CVE-2015-1828) ([@zanker]
|
|
234
|
+
`#post_connection_check` (CVE-2015-1828) ([@zanker])
|
|
185
235
|
|
|
186
236
|
|
|
187
237
|
## 0.7.2 (2015-03-02)
|
|
@@ -199,33 +249,33 @@
|
|
|
199
249
|
|
|
200
250
|
* [#73](https://github.com/httprb/http/issues/73),
|
|
201
251
|
[#167](https://github.com/httprb/http/pull/167):
|
|
202
|
-
Add support of multipart form data. ([@ixti]
|
|
252
|
+
Add support of multipart form data. ([@ixti])
|
|
203
253
|
* Fix URI path normalization: `https://github.com` -> `https://github.com/`.
|
|
204
|
-
([@ixti]
|
|
254
|
+
([@ixti])
|
|
205
255
|
* [#163](https://github.com/httprb/http/pull/163),
|
|
206
256
|
[#166](https://github.com/httprb/http/pull/166),
|
|
207
257
|
[#152](https://github.com/httprb/http/issues/152):
|
|
208
|
-
Fix handling of EOF which caused infinite loop. ([@mickm]
|
|
209
|
-
* Drop Ruby 1.8.7 support. ([@ixti]
|
|
258
|
+
Fix handling of EOF which caused infinite loop. ([@mickm], [@ixti])
|
|
259
|
+
* Drop Ruby 1.8.7 support. ([@ixti])
|
|
210
260
|
* [#150](https://github.com/httprb/http/issues/150):
|
|
211
|
-
Fix default Host header value. ([@ixti]
|
|
212
|
-
* Remove BearerToken authorization header. ([@ixti]
|
|
261
|
+
Fix default Host header value. ([@ixti])
|
|
262
|
+
* Remove BearerToken authorization header. ([@ixti])
|
|
213
263
|
* `#auth` sugar now accepts only string value of Authorization header.
|
|
214
264
|
Calling `#auth(:basic, opts)` is deprecated, use `#basic_auth(opts)` instead.
|
|
215
|
-
([@ixti]
|
|
216
|
-
* Fix handling of chunked responses without Content-Length header. ([@ixti]
|
|
265
|
+
([@ixti])
|
|
266
|
+
* Fix handling of chunked responses without Content-Length header. ([@ixti])
|
|
217
267
|
* Remove `HTTP::Request#method` and deprecate `HTTP::Request#__method__`
|
|
218
|
-
([@sferik]
|
|
268
|
+
([@sferik])
|
|
219
269
|
* Deprecate `HTTP::Response::STATUS_CODES`,
|
|
220
|
-
use `HTTP::Response::Status::REASONS` instead ([@ixti]
|
|
221
|
-
* Deprecate `HTTP::Response::SYMBOL_TO_STATUS_CODE` ([@ixti]
|
|
222
|
-
* Deprecate `HTTP::Response#status_code` ([@ixti]
|
|
223
|
-
* `HTTP::Response#status` now returns `HTTP::Response::Status`. ([@ixti]
|
|
270
|
+
use `HTTP::Response::Status::REASONS` instead ([@ixti])
|
|
271
|
+
* Deprecate `HTTP::Response::SYMBOL_TO_STATUS_CODE` ([@ixti])
|
|
272
|
+
* Deprecate `HTTP::Response#status_code` ([@ixti])
|
|
273
|
+
* `HTTP::Response#status` now returns `HTTP::Response::Status`. ([@ixti])
|
|
224
274
|
* `HTTP::Response#reason` and `HTTP::Response#code` are proxies them
|
|
225
|
-
to corresponding methods of `HTTP::Response#status` ([@ixti]
|
|
275
|
+
to corresponding methods of `HTTP::Response#status` ([@ixti])
|
|
226
276
|
* Rename `HTTP.with_follow` to `HTTP.follow` and mark former one as being
|
|
227
|
-
deprecated ([@ixti]
|
|
228
|
-
* Delegate `HTTP::Response#readpartial` to `HTTP::Response::Body` ([@ixti]
|
|
277
|
+
deprecated ([@ixti])
|
|
278
|
+
* Delegate `HTTP::Response#readpartial` to `HTTP::Response::Body` ([@ixti])
|
|
229
279
|
|
|
230
280
|
|
|
231
281
|
## 0.6.4 (2015-03-25)
|
|
@@ -233,57 +283,57 @@
|
|
|
233
283
|
* SECURITY FIX: http.rb failed to call the `#post_connection_check` method on
|
|
234
284
|
SSL connections. This method implements hostname verification, and without it
|
|
235
285
|
`http.rb` was vulnerable to MitM attacks. The problem was corrected by calling
|
|
236
|
-
`#post_connection_check` (CVE-2015-1828) ([@zanker]
|
|
286
|
+
`#post_connection_check` (CVE-2015-1828) ([@zanker], backported by [@nicoolas25])
|
|
237
287
|
|
|
238
288
|
|
|
239
289
|
## 0.6.3 (2014-11-14)
|
|
240
290
|
|
|
241
291
|
* [#166](https://github.com/httprb/http/pull/166):
|
|
242
|
-
Backported EOF fix from master branch. ([@ixti]
|
|
292
|
+
Backported EOF fix from master branch. ([@ixti])
|
|
243
293
|
|
|
244
294
|
|
|
245
295
|
## 0.6.2 (2014-08-06)
|
|
246
296
|
|
|
247
297
|
* [#150](https://github.com/httprb/http/issues/150):
|
|
248
|
-
Fix default Host header value. ([@ixti]
|
|
249
|
-
* Deprecate BearerToken authorization header. ([@ixti]
|
|
250
|
-
* Fix handling of chunked responses without Content-Length header. ([@ixti]
|
|
298
|
+
Fix default Host header value. ([@ixti])
|
|
299
|
+
* Deprecate BearerToken authorization header. ([@ixti])
|
|
300
|
+
* Fix handling of chunked responses without Content-Length header. ([@ixti])
|
|
251
301
|
* Rename `HTTP.with_follow` to `HTTP.follow` and mark former one as being
|
|
252
|
-
deprecated ([@ixti]
|
|
302
|
+
deprecated ([@ixti])
|
|
253
303
|
|
|
254
304
|
|
|
255
305
|
## 0.6.1 (2014-05-07)
|
|
256
306
|
|
|
257
|
-
* Fix request `Content-Length` calculation for Unicode ([@challengee]
|
|
258
|
-
* Add `Response#flush` ([@ixti]
|
|
259
|
-
* Fix `Response::Body#readpartial` default size ([@hannesg]
|
|
260
|
-
* Add missing `CRLF` for chunked bodies ([@hannesg]
|
|
261
|
-
* Fix forgotten CGI require ([@ixti]
|
|
262
|
-
* Improve README ([@tarcieri]
|
|
307
|
+
* Fix request `Content-Length` calculation for Unicode ([@challengee])
|
|
308
|
+
* Add `Response#flush` ([@ixti])
|
|
309
|
+
* Fix `Response::Body#readpartial` default size ([@hannesg], [@ixti])
|
|
310
|
+
* Add missing `CRLF` for chunked bodies ([@hannesg])
|
|
311
|
+
* Fix forgotten CGI require ([@ixti])
|
|
312
|
+
* Improve README ([@tarcieri])
|
|
263
313
|
|
|
264
314
|
|
|
265
315
|
## 0.6.0 (2014-04-04)
|
|
266
316
|
|
|
267
|
-
* Rename `HTTP::Request#method` to `HTTP::Request#verb` ([@krainboltgreene]
|
|
268
|
-
* Add `HTTP::ResponseBody` class ([@tarcieri]
|
|
269
|
-
* Change API of response on `HTTP::Client.request` and "friends" (`#get`, `#post`, etc) ([@tarcieri]
|
|
270
|
-
* Add `HTTP::Response#readpartial` ([@tarcieri]
|
|
271
|
-
* Add `HTTP::Headers` class ([@ixti]
|
|
272
|
-
* Fix and improve following redirects ([@ixti]
|
|
273
|
-
* Add `HTTP::Request#redirect` ([@ixti]
|
|
274
|
-
* Add `HTTP::Response#content_type` ([@ixti]
|
|
275
|
-
* Add `HTTP::Response#mime_type` ([@ixti]
|
|
276
|
-
* Add `HTTP::Response#charset` ([@ixti]
|
|
277
|
-
* Improve error message upon invalid URI scheme ([@ixti]
|
|
278
|
-
* Consolidate errors under common `HTTP::Error` namespace ([@ixti]
|
|
279
|
-
* Add easy way of adding Authorization header ([@ixti]
|
|
280
|
-
* Fix proxy support ([@hundredwatt]
|
|
281
|
-
* Fix and improve query params handing ([@jwinter]
|
|
282
|
-
* Change API of custom MIME type parsers ([@ixti]
|
|
283
|
-
* Remove `HTTP::Chainable#with_response` ([@ixti]
|
|
284
|
-
* Remove `HTTP::Response::BodyDelegator` ([@ixti]
|
|
285
|
-
* Remove `HTTP::Response#parsed_body` ([@ixti]
|
|
286
|
-
* Bump up input buffer from 4K to 16K ([@tarcieri]
|
|
317
|
+
* Rename `HTTP::Request#method` to `HTTP::Request#verb` ([@krainboltgreene])
|
|
318
|
+
* Add `HTTP::ResponseBody` class ([@tarcieri])
|
|
319
|
+
* Change API of response on `HTTP::Client.request` and "friends" (`#get`, `#post`, etc) ([@tarcieri])
|
|
320
|
+
* Add `HTTP::Response#readpartial` ([@tarcieri])
|
|
321
|
+
* Add `HTTP::Headers` class ([@ixti])
|
|
322
|
+
* Fix and improve following redirects ([@ixti])
|
|
323
|
+
* Add `HTTP::Request#redirect` ([@ixti])
|
|
324
|
+
* Add `HTTP::Response#content_type` ([@ixti])
|
|
325
|
+
* Add `HTTP::Response#mime_type` ([@ixti])
|
|
326
|
+
* Add `HTTP::Response#charset` ([@ixti])
|
|
327
|
+
* Improve error message upon invalid URI scheme ([@ixti])
|
|
328
|
+
* Consolidate errors under common `HTTP::Error` namespace ([@ixti])
|
|
329
|
+
* Add easy way of adding Authorization header ([@ixti])
|
|
330
|
+
* Fix proxy support ([@hundredwatt])
|
|
331
|
+
* Fix and improve query params handing ([@jwinter])
|
|
332
|
+
* Change API of custom MIME type parsers ([@ixti])
|
|
333
|
+
* Remove `HTTP::Chainable#with_response` ([@ixti])
|
|
334
|
+
* Remove `HTTP::Response::BodyDelegator` ([@ixti])
|
|
335
|
+
* Remove `HTTP::Response#parsed_body` ([@ixti])
|
|
336
|
+
* Bump up input buffer from 4K to 16K ([@tarcieri])
|
|
287
337
|
|
|
288
338
|
``` ruby
|
|
289
339
|
# Main API change you will mention is that `request` method and it's
|
|
@@ -297,7 +347,7 @@ parsed_body = HTTP.get("http://example.com/users.json").parse
|
|
|
297
347
|
# Second major change in API is work with request/response headers
|
|
298
348
|
# It is now delegated to `HTTP::Headers` class, so you can check it's
|
|
299
349
|
# documentation for details, here we will only outline main difference.
|
|
300
|
-
# Duckface (
|
|
350
|
+
# Duckface (`=`) does not appends headers anymore
|
|
301
351
|
|
|
302
352
|
request[:content_type] = "text/plain"
|
|
303
353
|
request[:content_type] = "text/html"
|
|
@@ -329,7 +379,7 @@ end
|
|
|
329
379
|
|
|
330
380
|
## 0.5.1 (2014-05-27)
|
|
331
381
|
|
|
332
|
-
* Backports redirector fixes from 0.6.0 ([@ixti]
|
|
382
|
+
* Backports redirector fixes from 0.6.0 ([@ixti])
|
|
333
383
|
* EOL of 0.5.X branch.
|
|
334
384
|
|
|
335
385
|
|
|
@@ -398,3 +448,4 @@ end
|
|
|
398
448
|
[@krainboltgreene]: https://github.com/krainboltgreene
|
|
399
449
|
[@hundredwatt]: https://github.com/hundredwatt
|
|
400
450
|
[@jwinter]: https://github.com/jwinter
|
|
451
|
+
[@nerdrew]: https://github.com/nerdrew
|
data/Gemfile
CHANGED
|
@@ -20,11 +20,11 @@ end
|
|
|
20
20
|
group :test do
|
|
21
21
|
gem "backports"
|
|
22
22
|
gem "coveralls"
|
|
23
|
-
gem "simplecov",
|
|
24
|
-
gem "json",
|
|
25
|
-
gem "
|
|
23
|
+
gem "simplecov", ">= 0.9"
|
|
24
|
+
gem "json", ">= 1.8.1"
|
|
25
|
+
gem "rubocop", "= 0.35.1"
|
|
26
|
+
gem "rspec", "~> 3.0"
|
|
26
27
|
gem "rspec-its"
|
|
27
|
-
gem "rubocop"
|
|
28
28
|
gem "yardstick"
|
|
29
29
|
gem "certificate_authority"
|
|
30
30
|
end
|
data/README.md
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
[](http://travis-ci.org/httprb/http)
|
|
5
5
|
[](https://codeclimate.com/github/httprb/http)
|
|
6
6
|
[](https://coveralls.io/r/httprb/http)
|
|
7
|
-
|
|
7
|
+
[](https://github.com/httprb/http/blob/master/LICENSE.txt)
|
|
8
8
|
|
|
9
9
|
## About
|
|
10
10
|
|
|
11
|
-
http.rb is an easy-to-use client library for making requests
|
|
12
|
-
a simple method chaining system for building requests, similar to
|
|
11
|
+
HTTP (The Gem! a.k.a. http.rb) is an easy-to-use client library for making requests
|
|
12
|
+
from Ruby. It uses a simple method chaining system for building requests, similar to
|
|
13
|
+
Python's [Requests].
|
|
13
14
|
|
|
14
15
|
Under the hood, http.rb uses [http_parser.rb], a fast HTTP parsing native
|
|
15
16
|
extension based on the Node.js parser and a Java port thereof. This library
|
|
@@ -55,6 +56,10 @@ Top three reasons:
|
|
|
55
56
|
|
|
56
57
|
Benchmarks performed using excon's benchmarking tool
|
|
57
58
|
|
|
59
|
+
DISCLAIMER: Most benchmarks you find in READMEs are crap,
|
|
60
|
+
including this one. These are out-of-date. If you care about
|
|
61
|
+
performance, benchmark for yourself for your own use cases!
|
|
62
|
+
|
|
58
63
|
## Help and Discussion
|
|
59
64
|
|
|
60
65
|
If you need help or just want to talk about the http.rb,
|
|
@@ -276,30 +281,6 @@ HTTP.persistent('http://en.wikipedia.org') do |http|
|
|
|
276
281
|
end
|
|
277
282
|
```
|
|
278
283
|
|
|
279
|
-
### Celluloid::IO Support
|
|
280
|
-
|
|
281
|
-
http.rb makes it simple to make multiple concurrent HTTP requests from a
|
|
282
|
-
Celluloid::IO actor. Here's a parallel HTTP fetcher combining http.rb with
|
|
283
|
-
Celluloid::IO:
|
|
284
|
-
|
|
285
|
-
```ruby
|
|
286
|
-
require "celluloid/io"
|
|
287
|
-
require "http"
|
|
288
|
-
|
|
289
|
-
class HttpFetcher
|
|
290
|
-
include Celluloid::IO
|
|
291
|
-
|
|
292
|
-
def fetch(url)
|
|
293
|
-
HTTP.get(url, socket_class: Celluloid::IO::TCPSocket)
|
|
294
|
-
end
|
|
295
|
-
end
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
There's a little more to it, but that's the core idea!
|
|
299
|
-
|
|
300
|
-
* [Full parallel HTTP fetcher example](https://github.com/httprb/http/wiki/Parallel-requests-with-Celluloid%3A%3AIO)
|
|
301
|
-
* See also: [Celluloid::IO](https://github.com/celluloid/celluloid-io)
|
|
302
|
-
|
|
303
284
|
### Timeouts
|
|
304
285
|
|
|
305
286
|
By default, HTTP does not timeout on a request. You can enable per operation
|
data/lib/http/chainable.rb
CHANGED
|
@@ -83,7 +83,10 @@ module HTTP
|
|
|
83
83
|
# @option options [Float] :write Write timeout
|
|
84
84
|
# @option options [Float] :connect Connect timeout
|
|
85
85
|
def timeout(klass, options = {})
|
|
86
|
-
|
|
86
|
+
if klass.is_a? Hash
|
|
87
|
+
options = klass
|
|
88
|
+
klass = :per_operation
|
|
89
|
+
end
|
|
87
90
|
|
|
88
91
|
klass = case klass.to_sym
|
|
89
92
|
when :null then HTTP::Timeout::Null
|
|
@@ -166,29 +169,22 @@ module HTTP
|
|
|
166
169
|
branch default_options.with_follow opts
|
|
167
170
|
end
|
|
168
171
|
|
|
169
|
-
# @deprecated will be removed in 1.0.0
|
|
170
|
-
# @see #follow
|
|
171
|
-
alias_method :with_follow, :follow
|
|
172
|
-
|
|
173
172
|
# Make a request with the given headers
|
|
174
173
|
# @param headers
|
|
175
174
|
def headers(headers)
|
|
176
175
|
branch default_options.with_headers(headers)
|
|
177
176
|
end
|
|
178
177
|
|
|
179
|
-
# @deprecated will be removed in 1.0.0
|
|
180
|
-
# @see #headers
|
|
181
|
-
alias_method :with, :headers
|
|
182
|
-
|
|
183
|
-
# @deprecated will be removed in 1.0.0
|
|
184
|
-
# @see #headers
|
|
185
|
-
alias_method :with_headers, :headers
|
|
186
|
-
|
|
187
178
|
# Make a request with the given cookies
|
|
188
179
|
def cookies(cookies)
|
|
189
180
|
branch default_options.with_cookies(cookies)
|
|
190
181
|
end
|
|
191
182
|
|
|
183
|
+
# Force a specific encoding for response body
|
|
184
|
+
def encoding(encoding)
|
|
185
|
+
branch default_options.with_encoding(encoding)
|
|
186
|
+
end
|
|
187
|
+
|
|
192
188
|
# Accept the given MIME type(s)
|
|
193
189
|
# @param type
|
|
194
190
|
def accept(type)
|
|
@@ -197,10 +193,7 @@ module HTTP
|
|
|
197
193
|
|
|
198
194
|
# Make a request with the given Authorization header
|
|
199
195
|
# @param [#to_s] value Authorization header value
|
|
200
|
-
def auth(value
|
|
201
|
-
# shim for deprecated auth(:basic, opts).
|
|
202
|
-
# will be removed in 0.8.0
|
|
203
|
-
return basic_auth(opts) if :basic == value
|
|
196
|
+
def auth(value)
|
|
204
197
|
headers Headers::AUTHORIZATION => value.to_s
|
|
205
198
|
end
|
|
206
199
|
|
|
@@ -229,19 +222,9 @@ module HTTP
|
|
|
229
222
|
@default_options = HTTP::Options.new(opts)
|
|
230
223
|
end
|
|
231
224
|
|
|
232
|
-
#
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
default_options.headers
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
# Set headers of HTTP options
|
|
239
|
-
# @deprecated Will be removed in 1.0.0; Use `#headers`
|
|
240
|
-
# @param headers
|
|
241
|
-
def default_headers=(headers)
|
|
242
|
-
@default_options = default_options.dup do |opts|
|
|
243
|
-
opts.headers = headers
|
|
244
|
-
end
|
|
225
|
+
# Set TCP_NODELAY on the socket
|
|
226
|
+
def nodelay
|
|
227
|
+
branch default_options.with_nodelay(true)
|
|
245
228
|
end
|
|
246
229
|
|
|
247
230
|
private
|