http 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGES.md +5 -0
- data/README.md +48 -12
- data/lib/http/client.rb +3 -7
- data/lib/http/connection.rb +18 -7
- data/lib/http/headers.rb +1 -1
- data/lib/http/options.rb +6 -1
- data/lib/http/response/status.rb +1 -1
- data/lib/http/timeout/global.rb +57 -24
- data/lib/http/timeout/per_operation.rb +43 -9
- data/lib/http/version.rb +1 -1
- data/spec/lib/http/client_spec.rb +9 -58
- data/spec/lib/http/options/merge_spec.rb +21 -21
- data/spec/support/dummy_server/servlet.rb +1 -1
- metadata +4 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adf2b0298c33a4f751b0b8ad323e425fbb556dff
|
4
|
+
data.tar.gz: d2a92940efef91c6e5054270d39eed2c46c182d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 752ab8075356ebbe1f69d8bddffb0aac8c3f98c2eab868861da6c4ae136730d08165cbf6cc98942e1199c8c515e940a2bc99dc18cd5de6f074ee35248cedd4a2
|
7
|
+
data.tar.gz: 8745c0368a70ef0b7a130f744e62acc952b540712ac44b573d8d4bbbba583eb82f41d6560af971069b46a1611306fe25e268af2540316919310a4b06d8160d48
|
data/.rubocop.yml
CHANGED
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# ![http.rb](https://raw.github.com/httprb/http.rb/master/logo.png)
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/http.svg)](http://rubygems.org/gems/http)
|
4
|
-
[![Build Status](https://secure.travis-ci.org/httprb/http.
|
5
|
-
[![Code Climate](https://codeclimate.com/github/httprb/http.
|
6
|
-
[![Coverage Status](https://coveralls.io/repos/httprb/http
|
4
|
+
[![Build Status](https://secure.travis-ci.org/httprb/http.svg?branch=master)](http://travis-ci.org/httprb/http)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/httprb/http.svg?branch=master)](https://codeclimate.com/github/httprb/http)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/httprb/http/badge.svg?branch=master)](https://coveralls.io/r/httprb/http)
|
7
7
|
|
8
8
|
|
9
9
|
## About
|
@@ -20,6 +20,41 @@ natively and outsources the parsing to native extensions.
|
|
20
20
|
[http_parser.rb]: https://github.com/tmm1/http_parser.rb
|
21
21
|
|
22
22
|
|
23
|
+
## Another Ruby HTTP library? Why should I care?
|
24
|
+
|
25
|
+
There are a lot of HTTP libraries to choose from in the Ruby ecosystem.
|
26
|
+
So why would you choose this one?
|
27
|
+
|
28
|
+
Top three reasons:
|
29
|
+
|
30
|
+
1. **Clean API**: http.rb offers an easy-to-use API that should be a
|
31
|
+
breath of fresh air after using something like Net::HTTP.
|
32
|
+
|
33
|
+
2. **Maturity**: http.rb is one of the most mature Ruby HTTP clients, supporting
|
34
|
+
features like persistent connections and fine-grained timeouts.
|
35
|
+
|
36
|
+
3. **Performance**: using native parsers and a clean, lightweight implementation,
|
37
|
+
http.rb achieves the best performance of any Ruby HTTP library which
|
38
|
+
implements the HTTP protocol in Ruby instead of C:
|
39
|
+
|
40
|
+
| HTTP client | time |
|
41
|
+
|--------------------------|-----------|
|
42
|
+
| curb (persistent) | 2.519088 |
|
43
|
+
| em-http-request | 2.731645 |
|
44
|
+
| Typhoeus | 2.851911 |
|
45
|
+
| StreamlyFFI (persistent) | 2.853786 |
|
46
|
+
| http.rb (persistent) | 2.970702 |
|
47
|
+
| http.rb | 3.588964 |
|
48
|
+
| HTTParty | 3.931913 |
|
49
|
+
| Net::HTTP | 3.959342 |
|
50
|
+
| Net::HTTP (persistent) | 4.043674 |
|
51
|
+
| open-uri | 4.479817 |
|
52
|
+
| Excon (persistent) | 4.618361 |
|
53
|
+
| Excon | 4.701262 |
|
54
|
+
| RestClient | 26.832668 |
|
55
|
+
|
56
|
+
Benchmarks performed using excon's benchmarking tool
|
57
|
+
|
23
58
|
## Help and Discussion
|
24
59
|
|
25
60
|
If you need help or just want to talk about the http.rb,
|
@@ -59,7 +94,7 @@ Inside of your Ruby program do:
|
|
59
94
|
|
60
95
|
## Documentation
|
61
96
|
|
62
|
-
[Please see the http.rb wiki](https://github.com/httprb/http
|
97
|
+
[Please see the http.rb wiki](https://github.com/httprb/http/wiki)
|
63
98
|
for more detailed documentation and usage notes.
|
64
99
|
|
65
100
|
|
@@ -164,7 +199,7 @@ you want to get the latest commit of this library from GitHub in JSON format.
|
|
164
199
|
One way we could do this is by tacking a filename on the end of the URL:
|
165
200
|
|
166
201
|
```ruby
|
167
|
-
HTTP.get("https://github.com/httprb/http
|
202
|
+
HTTP.get("https://github.com/httprb/http/commit/HEAD.json")
|
168
203
|
```
|
169
204
|
|
170
205
|
The GitHub API happens to support this approach, but really this is a bit of a
|
@@ -175,7 +210,7 @@ intends us to, by using the Accept header:
|
|
175
210
|
|
176
211
|
```ruby
|
177
212
|
HTTP.headers(:accept => "application/json")
|
178
|
-
.get("https://github.com/httprb/http
|
213
|
+
.get("https://github.com/httprb/http/commit/HEAD")
|
179
214
|
```
|
180
215
|
|
181
216
|
This requests JSON from GitHub. GitHub is smart enough to understand our
|
@@ -185,7 +220,7 @@ Shorter alias exists for `HTTP.headers`:
|
|
185
220
|
|
186
221
|
```ruby
|
187
222
|
HTTP[:accept => "application/json"]
|
188
|
-
.get("https://github.com/httprb/http
|
223
|
+
.get("https://github.com/httprb/http/commit/HEAD")
|
189
224
|
```
|
190
225
|
|
191
226
|
|
@@ -222,7 +257,7 @@ right? But usually it's not, and so we end up adding ".json" onto the ends of
|
|
222
257
|
our URLs because the existing mechanisms make it too hard. It should be easy:
|
223
258
|
|
224
259
|
```ruby
|
225
|
-
HTTP.accept(:json).get("https://github.com/httprb/http
|
260
|
+
HTTP.accept(:json).get("https://github.com/httprb/http/commit/HEAD")
|
226
261
|
```
|
227
262
|
|
228
263
|
This adds the appropriate Accept header for retrieving a JSON response for the
|
@@ -236,7 +271,7 @@ reuse the same connection again and again:
|
|
236
271
|
```ruby
|
237
272
|
contents = []
|
238
273
|
targets = %w(Hypertext_Transfer_Protocol Git GitHub Linux Hurd)
|
239
|
-
HTTP.persistent('http://en.wikipedia.org')
|
274
|
+
HTTP.persistent('http://en.wikipedia.org') do |http|
|
240
275
|
targets.each { |target| contents << http.get("/wiki/#{target}") }
|
241
276
|
end
|
242
277
|
```
|
@@ -262,7 +297,7 @@ end
|
|
262
297
|
|
263
298
|
There's a little more to it, but that's the core idea!
|
264
299
|
|
265
|
-
* [Full parallel HTTP fetcher example](https://github.com/httprb/http
|
300
|
+
* [Full parallel HTTP fetcher example](https://github.com/httprb/http/wiki/Parallel-requests-with-Celluloid%3A%3AIO)
|
266
301
|
* See also: [Celluloid::IO](https://github.com/celluloid/celluloid-io)
|
267
302
|
|
268
303
|
### Timeouts
|
@@ -305,6 +340,7 @@ versions:
|
|
305
340
|
* Ruby 2.1.x
|
306
341
|
* Ruby 2.2.x
|
307
342
|
* JRuby 1.7.x
|
343
|
+
* JRuby 9000
|
308
344
|
|
309
345
|
If something doesn't work on one of these versions, it's a bug.
|
310
346
|
|
@@ -319,7 +355,7 @@ patches in a timely fashion. If critical issues for a particular implementation
|
|
319
355
|
exist at the time of a major release, support for that Ruby version may be
|
320
356
|
dropped.
|
321
357
|
|
322
|
-
[travis]: http://travis-ci.org/httprb/http
|
358
|
+
[travis]: http://travis-ci.org/httprb/http
|
323
359
|
|
324
360
|
|
325
361
|
## Contributing to http.rb
|
@@ -334,5 +370,5 @@ dropped.
|
|
334
370
|
|
335
371
|
## Copyright
|
336
372
|
|
337
|
-
Copyright (c) 2011-2015 Tony Arcieri, Erik Michaels-Ober, Alexey V. Zapparov, Zachary Anker
|
373
|
+
Copyright (c) 2011-2015 Tony Arcieri, Erik Michaels-Ober, Alexey V. Zapparov, Zachary Anker.
|
338
374
|
See LICENSE.txt for further details.
|
data/lib/http/client.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
require "forwardable"
|
2
2
|
|
3
|
-
require "cgi"
|
4
|
-
require "uri"
|
5
|
-
|
6
3
|
require "http/form_data"
|
7
4
|
require "http/options"
|
8
5
|
require "http/headers"
|
@@ -109,7 +106,7 @@ module HTTP
|
|
109
106
|
#
|
110
107
|
# @param [#to_s] uri
|
111
108
|
# @return [URI]
|
112
|
-
def make_request_uri(uri,
|
109
|
+
def make_request_uri(uri, opts)
|
113
110
|
uri = uri.to_s
|
114
111
|
|
115
112
|
if default_options.persistent? && uri !~ HTTP_OR_HTTPS_RE
|
@@ -118,9 +115,8 @@ module HTTP
|
|
118
115
|
|
119
116
|
uri = HTTP::URI.parse uri
|
120
117
|
|
121
|
-
if
|
122
|
-
|
123
|
-
uri.query = ::URI.encode_www_form params
|
118
|
+
if opts.params && !opts.params.empty?
|
119
|
+
uri.query = [uri.query, HTTP::URI.form_encode(opts.params)].compact.join("&")
|
124
120
|
end
|
125
121
|
|
126
122
|
# Some proxies (seen on WEBRick) fail if URL has
|
data/lib/http/connection.rb
CHANGED
@@ -77,11 +77,10 @@ module HTTP
|
|
77
77
|
def readpartial(size = BUFFER_SIZE)
|
78
78
|
return unless @pending_response
|
79
79
|
|
80
|
-
|
81
|
-
read_more size
|
82
|
-
finished = @parser.finished?
|
83
|
-
rescue EOFError
|
80
|
+
if read_more(size) == :eof
|
84
81
|
finished = true
|
82
|
+
else
|
83
|
+
finished = @parser.finished?
|
85
84
|
end
|
86
85
|
|
87
86
|
chunk = @parser.chunk
|
@@ -94,10 +93,17 @@ module HTTP
|
|
94
93
|
# Reads data from socket up until headers are loaded
|
95
94
|
# @return [void]
|
96
95
|
def read_headers!
|
97
|
-
|
96
|
+
loop do
|
97
|
+
if read_more(BUFFER_SIZE) == :eof
|
98
|
+
fail EOFError unless @parser.headers?
|
99
|
+
break
|
100
|
+
else
|
101
|
+
break if @parser.headers?
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
98
105
|
set_keep_alive
|
99
106
|
rescue IOError, Errno::ECONNRESET, Errno::EPIPE => e
|
100
|
-
return if e.is_a?(EOFError) && @parser.headers
|
101
107
|
raise IOError, "problem making HTTP request: #{e}"
|
102
108
|
end
|
103
109
|
|
@@ -199,7 +205,12 @@ module HTTP
|
|
199
205
|
# Feeds some more data into parser
|
200
206
|
# @return [void]
|
201
207
|
def read_more(size)
|
202
|
-
|
208
|
+
return if @parser.finished?
|
209
|
+
|
210
|
+
value = @socket.readpartial(size)
|
211
|
+
@parser << value unless value == :eof
|
212
|
+
|
213
|
+
nil
|
203
214
|
end
|
204
215
|
end
|
205
216
|
end
|
data/lib/http/headers.rb
CHANGED
@@ -47,7 +47,7 @@ module HTTP
|
|
47
47
|
# @param [Array<#to_s>, #to_s] value header value(s) to be appended
|
48
48
|
# @return [void]
|
49
49
|
def add(name, value)
|
50
|
-
name
|
50
|
+
name = normalize_header name.to_s
|
51
51
|
Array(value).each { |v| @pile << [name, v.to_s] }
|
52
52
|
end
|
53
53
|
|
data/lib/http/options.rb
CHANGED
@@ -91,8 +91,13 @@ module HTTP
|
|
91
91
|
!persistent.nil?
|
92
92
|
end
|
93
93
|
|
94
|
+
# @deprecated
|
94
95
|
def [](option)
|
95
|
-
send(option)
|
96
|
+
send(option)
|
97
|
+
rescue
|
98
|
+
warn "[DEPRECATED] `HTTP::Options#[:#{option}]` was deprecated. " \
|
99
|
+
"Use `HTTP::Options##{option}` instead."
|
100
|
+
nil
|
96
101
|
end
|
97
102
|
|
98
103
|
def merge(other)
|
data/lib/http/response/status.rb
CHANGED
data/lib/http/timeout/global.rb
CHANGED
@@ -6,11 +6,8 @@ module HTTP
|
|
6
6
|
def initialize(*args)
|
7
7
|
super
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def reset_counter
|
13
|
-
@time_left = @total_timeout = connect_timeout + read_timeout + write_timeout
|
9
|
+
@time_left = connect_timeout + read_timeout + write_timeout
|
10
|
+
@total_timeout = time_left
|
14
11
|
end
|
15
12
|
|
16
13
|
def connect(socket_class, host, port)
|
@@ -38,29 +35,65 @@ module HTTP
|
|
38
35
|
end
|
39
36
|
end
|
40
37
|
|
41
|
-
#
|
42
|
-
|
43
|
-
|
38
|
+
# NIO with exceptions
|
39
|
+
if RUBY_VERSION < "2.1.0"
|
40
|
+
# Read from the socket
|
41
|
+
def readpartial(size)
|
42
|
+
reset_timer
|
43
|
+
|
44
|
+
begin
|
45
|
+
socket.read_nonblock(size)
|
46
|
+
rescue IO::WaitReadable
|
47
|
+
IO.select([socket], nil, nil, time_left)
|
48
|
+
log_time
|
49
|
+
retry
|
50
|
+
end
|
51
|
+
rescue EOFError
|
52
|
+
:eof
|
53
|
+
end
|
44
54
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
# Write to the socket
|
56
|
+
def write(data)
|
57
|
+
reset_timer
|
58
|
+
|
59
|
+
begin
|
60
|
+
socket.write_nonblock(data)
|
61
|
+
rescue IO::WaitWritable
|
62
|
+
IO.select(nil, [socket], nil, time_left)
|
63
|
+
log_time
|
64
|
+
retry
|
65
|
+
end
|
66
|
+
rescue EOFError
|
67
|
+
:eof
|
51
68
|
end
|
52
|
-
end
|
53
69
|
|
54
|
-
#
|
55
|
-
|
56
|
-
reset_timer
|
70
|
+
# NIO without exceptions
|
71
|
+
else
|
57
72
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
73
|
+
# Read from the socket
|
74
|
+
def readpartial(size)
|
75
|
+
reset_timer
|
76
|
+
|
77
|
+
loop do
|
78
|
+
result = socket.read_nonblock(size, :exception => false)
|
79
|
+
break result unless result == :wait_readable
|
80
|
+
|
81
|
+
IO.select([socket], nil, nil, time_left)
|
82
|
+
log_time
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Write to the socket
|
87
|
+
def write(data)
|
88
|
+
reset_timer
|
89
|
+
|
90
|
+
loop do
|
91
|
+
result = socket.write_nonblock(data, :exception => false)
|
92
|
+
break unless result == :wait_writable
|
93
|
+
|
94
|
+
IO.select(nil, [socket], nil, time_left)
|
95
|
+
log_time
|
96
|
+
end
|
64
97
|
end
|
65
98
|
end
|
66
99
|
|
@@ -29,19 +29,53 @@ module HTTP
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
#
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
# NIO with exceptions
|
33
|
+
if RUBY_VERSION < "2.1.0"
|
34
|
+
# Read data from the socket
|
35
|
+
def readpartial(size)
|
36
|
+
rescue_readable do
|
37
|
+
socket.read_nonblock(size)
|
38
|
+
end
|
39
|
+
rescue EOFError
|
40
|
+
:eof
|
41
|
+
end
|
42
|
+
|
43
|
+
# Write data to the socket
|
44
|
+
def write(data)
|
45
|
+
rescue_writable do
|
46
|
+
socket.write_nonblock(data)
|
47
|
+
end
|
48
|
+
rescue EOFError
|
49
|
+
:eof
|
36
50
|
end
|
37
|
-
end
|
38
51
|
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
|
52
|
+
# NIO without exceptions
|
53
|
+
else
|
54
|
+
# Read data from the socket
|
55
|
+
def readpartial(size)
|
56
|
+
loop do
|
57
|
+
result = socket.read_nonblock(size, :exception => false)
|
58
|
+
break result unless result == :wait_readable
|
59
|
+
|
60
|
+
unless IO.select([socket], nil, nil, read_timeout)
|
61
|
+
fail TimeoutError, "Read timed out after #{read_timeout} seconds"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Write data to the socket
|
67
|
+
def write(data)
|
68
|
+
loop do
|
69
|
+
result = socket.write_nonblock(data, :exception => false)
|
70
|
+
break unless result == :wait_writable
|
71
|
+
|
72
|
+
unless IO.select(nil, [socket], nil, write_timeout)
|
73
|
+
fail TimeoutError, "Read timed out after #{write_timeout} seconds"
|
74
|
+
end
|
75
|
+
end
|
43
76
|
end
|
44
77
|
end
|
78
|
+
# rubocop:enable Metrics/BlockNesting
|
45
79
|
end
|
46
80
|
end
|
47
81
|
end
|
data/lib/http/version.rb
CHANGED
@@ -138,6 +138,14 @@ RSpec.describe HTTP::Client do
|
|
138
138
|
|
139
139
|
client.get("http://example.com/?a[]=b&a[]=c", :params => {:d => "e"})
|
140
140
|
end
|
141
|
+
|
142
|
+
it "properly encodes colons" do
|
143
|
+
expect(HTTP::Request).to receive(:new) do |_, uri|
|
144
|
+
expect(uri.query).to eq "t=1970-01-01T00%3A00%3A00Z"
|
145
|
+
end
|
146
|
+
|
147
|
+
client.get("http://example.com/", :params => {:t => "1970-01-01T00:00:00Z"})
|
148
|
+
end
|
141
149
|
end
|
142
150
|
|
143
151
|
describe "passing json" do
|
@@ -156,7 +164,7 @@ RSpec.describe HTTP::Client do
|
|
156
164
|
describe "#request" do
|
157
165
|
context "with non-ASCII URLs" do
|
158
166
|
it "theoretically works like a charm" do
|
159
|
-
client =
|
167
|
+
client = described_class.new
|
160
168
|
expect { client.get "#{dummy.endpoint}/könig" }.not_to raise_error
|
161
169
|
end
|
162
170
|
|
@@ -240,63 +248,6 @@ RSpec.describe HTTP::Client do
|
|
240
248
|
end
|
241
249
|
end
|
242
250
|
|
243
|
-
context "when server closes connection unexpectedly" do
|
244
|
-
before do
|
245
|
-
socket_spy = double
|
246
|
-
|
247
|
-
allow(socket_spy).to receive(:close) { nil }
|
248
|
-
allow(socket_spy).to receive(:closed?) { true }
|
249
|
-
allow(socket_spy).to receive(:readpartial) { chunks.shift.call }
|
250
|
-
allow(socket_spy).to receive(:<<) { nil }
|
251
|
-
|
252
|
-
allow(TCPSocket).to receive(:open) { socket_spy }
|
253
|
-
end
|
254
|
-
|
255
|
-
context "during headers reading" do
|
256
|
-
let :chunks do
|
257
|
-
[
|
258
|
-
proc { "HTTP/1.1 200 OK\r\n" },
|
259
|
-
proc { "Content-Type: text/html\r" },
|
260
|
-
proc { fail EOFError }
|
261
|
-
]
|
262
|
-
end
|
263
|
-
|
264
|
-
it "raises IOError" do
|
265
|
-
expect { client.get dummy.endpoint }.to raise_error IOError
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
context "after headers were flushed" do
|
270
|
-
let :chunks do
|
271
|
-
[
|
272
|
-
proc { "HTTP/1.1 200 OK\r\n" },
|
273
|
-
proc { "Content-Type: text/html\r\n\r\n" },
|
274
|
-
proc { "unexpected end of f" },
|
275
|
-
proc { fail EOFError }
|
276
|
-
]
|
277
|
-
end
|
278
|
-
|
279
|
-
it "reads partially arrived body" do
|
280
|
-
res = client.get(dummy.endpoint).to_s
|
281
|
-
expect(res).to eq "unexpected end of f"
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
context "when body and headers were flushed in one chunk" do
|
286
|
-
let :chunks do
|
287
|
-
[
|
288
|
-
proc { "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nunexpected end of f" },
|
289
|
-
proc { fail EOFError }
|
290
|
-
]
|
291
|
-
end
|
292
|
-
|
293
|
-
it "reads partially arrived body" do
|
294
|
-
res = client.get(dummy.endpoint).to_s
|
295
|
-
expect(res).to eq "unexpected end of f"
|
296
|
-
end
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
251
|
context "when server fully flushes response in one chunk" do
|
301
252
|
before do
|
302
253
|
socket_spy = double
|
@@ -18,43 +18,43 @@ RSpec.describe HTTP::Options, "merge" do
|
|
18
18
|
|
19
19
|
foo = HTTP::Options.new(
|
20
20
|
:response => :body,
|
21
|
-
:params
|
21
|
+
:params => {:baz => "bar"},
|
22
22
|
:form => {:foo => "foo"},
|
23
23
|
:body => "body-foo",
|
24
24
|
:json => {:foo => "foo"},
|
25
|
-
:headers => {:accept
|
25
|
+
:headers => {:accept => "json", :foo => "foo"},
|
26
26
|
:proxy => {})
|
27
27
|
|
28
28
|
bar = HTTP::Options.new(
|
29
|
-
:response
|
30
|
-
:persistent
|
31
|
-
:params
|
32
|
-
:form
|
33
|
-
:body
|
34
|
-
:json
|
29
|
+
:response => :parsed_body,
|
30
|
+
:persistent => "https://www.googe.com",
|
31
|
+
:params => {:plop => "plip"},
|
32
|
+
:form => {:bar => "bar"},
|
33
|
+
:body => "body-bar",
|
34
|
+
:json => {:bar => "bar"},
|
35
35
|
:keep_alive_timeout => 10,
|
36
|
-
:headers
|
37
|
-
:timeout_options
|
38
|
-
:ssl
|
39
|
-
:proxy
|
36
|
+
:headers => {:accept => "xml", :bar => "bar"},
|
37
|
+
:timeout_options => {:foo => :bar},
|
38
|
+
:ssl => {:foo => "bar"},
|
39
|
+
:proxy => {:proxy_address => "127.0.0.1", :proxy_port => 8080})
|
40
40
|
|
41
41
|
expect(foo.merge(bar).to_hash).to eq(
|
42
|
-
:response
|
43
|
-
:timeout_class
|
42
|
+
:response => :parsed_body,
|
43
|
+
:timeout_class => described_class.default_timeout_class,
|
44
44
|
:timeout_options => {:foo => :bar},
|
45
|
-
:params
|
46
|
-
:form
|
47
|
-
:body
|
48
|
-
:json
|
49
|
-
:persistent
|
45
|
+
:params => {:plop => "plip"},
|
46
|
+
:form => {:bar => "bar"},
|
47
|
+
:body => "body-bar",
|
48
|
+
:json => {:bar => "bar"},
|
49
|
+
:persistent => "https://www.googe.com",
|
50
50
|
:keep_alive_timeout => 10,
|
51
51
|
:ssl => {:foo => "bar"},
|
52
|
-
:headers => {"Foo" => "foo", "Accept"
|
52
|
+
:headers => {"Foo" => "foo", "Accept" => "xml", "Bar" => "bar"},
|
53
53
|
:proxy => {:proxy_address => "127.0.0.1", :proxy_port => 8080},
|
54
54
|
:follow => nil,
|
55
55
|
:socket_class => described_class.default_socket_class,
|
56
56
|
:ssl_socket_class => described_class.default_ssl_socket_class,
|
57
57
|
:ssl_context => nil,
|
58
|
-
:cookies
|
58
|
+
:cookies => {})
|
59
59
|
end
|
60
60
|
end
|
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.9.
|
4
|
+
version: 0.9.1
|
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-
|
14
|
+
date: 2015-08-14 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: http_parser.rb
|
@@ -183,39 +183,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
version: '0'
|
184
184
|
requirements: []
|
185
185
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.2.3
|
187
187
|
signing_key:
|
188
188
|
specification_version: 4
|
189
189
|
summary: HTTP should be easy
|
190
|
-
test_files:
|
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/writer_spec.rb
|
205
|
-
- spec/lib/http/request_spec.rb
|
206
|
-
- spec/lib/http/response/body_spec.rb
|
207
|
-
- spec/lib/http/response/status_spec.rb
|
208
|
-
- spec/lib/http/response_spec.rb
|
209
|
-
- spec/lib/http_spec.rb
|
210
|
-
- spec/spec_helper.rb
|
211
|
-
- spec/support/black_hole.rb
|
212
|
-
- spec/support/capture_warning.rb
|
213
|
-
- spec/support/connection_reuse_shared.rb
|
214
|
-
- spec/support/dummy_server.rb
|
215
|
-
- spec/support/dummy_server/servlet.rb
|
216
|
-
- spec/support/http_handling_shared.rb
|
217
|
-
- spec/support/proxy_server.rb
|
218
|
-
- spec/support/servers/config.rb
|
219
|
-
- spec/support/servers/runner.rb
|
220
|
-
- spec/support/ssl_helper.rb
|
190
|
+
test_files: []
|
221
191
|
has_rdoc:
|