http 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of http might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -2
- data/.travis.yml +7 -13
- data/CHANGES.md +15 -0
- data/Gemfile +5 -4
- data/README.md +2 -2
- data/Rakefile +2 -2
- data/examples/parallel_requests_with_celluloid.rb +2 -2
- data/lib/http/authorization_header/bearer_token.rb +7 -8
- data/lib/http/backports/uri.rb +4 -4
- data/lib/http/chainable.rb +9 -2
- data/lib/http/client.rb +1 -1
- data/lib/http/options.rb +7 -35
- data/lib/http/request.rb +27 -3
- data/lib/http/request/writer.rb +11 -6
- data/lib/http/response/parser.rb +2 -4
- data/lib/http/version.rb +1 -1
- data/spec/http/client_spec.rb +1 -1
- data/spec/http/request/writer_spec.rb +1 -1
- data/spec/http/request_spec.rb +57 -16
- data/spec/http_spec.rb +3 -3
- data/spec/spec_helper.rb +8 -9
- data/spec/support/example_server.rb +9 -8
- data/spec/support/proxy_server.rb +1 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaab2ce76635211389fd9480ab6bde7e5dff1e3e
|
4
|
+
data.tar.gz: 7a4769b42117b5fcca8163bbfcd59e2bcb0baccb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2caf7623ed59f9d1bc978928e6174cd84f512acc1f50f9b70df78607eb4fca26c12b9a4899c61483fa86f32630c08a5218e5aeef4b669847de8c54d8036c76f4
|
7
|
+
data.tar.gz: e91ae392e1bf3b142567289e536a59742a35fac2c774c0129a22019cd06e1805adc219e2439cfc39b2f4eb33c7899e0a37037b0ec9732cc2fdeff1331f9ed178
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
2
|
+
Include:
|
3
3
|
- 'Gemfile'
|
4
4
|
- 'Rakefile'
|
5
5
|
- 'http.gemspec'
|
@@ -15,7 +15,7 @@ MethodLength:
|
|
15
15
|
|
16
16
|
ClassLength:
|
17
17
|
CountComments: false
|
18
|
-
Max:
|
18
|
+
Max: 100
|
19
19
|
|
20
20
|
CyclomaticComplexity:
|
21
21
|
Max: 13 # TODO: lower to 6
|
@@ -99,3 +99,18 @@ PercentLiteralDelimiters:
|
|
99
99
|
Semicolon:
|
100
100
|
Exclude:
|
101
101
|
- 'spec/support/'
|
102
|
+
|
103
|
+
# Do not force first argument to be separated with exactly single space.
|
104
|
+
# My (ixti) personal preference is to align code in columns when it makes
|
105
|
+
# sense:
|
106
|
+
#
|
107
|
+
# module HTTP
|
108
|
+
# module MimeType
|
109
|
+
# class JSON < Adapter
|
110
|
+
# register_adapter 'application/json', JSON
|
111
|
+
# register_alias 'application/json', :json
|
112
|
+
# end
|
113
|
+
# end
|
114
|
+
# end
|
115
|
+
SingleSpaceBeforeFirstArg:
|
116
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,26 +1,20 @@
|
|
1
|
-
before_install:
|
2
|
-
- gem update bundler
|
3
|
-
- bundle --version
|
4
|
-
- gem update --system 2.1.11
|
5
|
-
- gem --version
|
6
1
|
bundler_args: --without development
|
2
|
+
env:
|
3
|
+
global:
|
4
|
+
- JRUBY_OPTS="$JRUBY_OPTS --debug"
|
7
5
|
language: ruby
|
8
6
|
rvm:
|
9
7
|
- 1.8.7
|
10
8
|
- 1.9.2
|
11
9
|
- 1.9.3
|
12
10
|
- 2.0.0
|
13
|
-
- 2.1
|
11
|
+
- 2.1
|
12
|
+
- jruby-18mode
|
13
|
+
- jruby-19mode
|
14
|
+
- jruby-head
|
14
15
|
- rbx-2
|
15
16
|
- ruby-head
|
16
17
|
matrix:
|
17
|
-
include:
|
18
|
-
- rvm: jruby-18mode
|
19
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
20
|
-
- rvm: jruby-19mode
|
21
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
22
|
-
- rvm: jruby-head
|
23
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
24
18
|
allow_failures:
|
25
19
|
- rvm: jruby-head
|
26
20
|
- rvm: ruby-head
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
0.6.2 (2014-08-06)
|
2
|
+
------------------
|
3
|
+
|
4
|
+
* Fix default Host header value. See #150. (@ixti)
|
5
|
+
* Deprecate BearerToken authorization header. (@ixti)
|
6
|
+
* Fix handling of chunked responses without Content-Length header. (@ixti)
|
7
|
+
* Rename `HTTP.with_follow` to `HTTP.follow` and mark former one as being
|
8
|
+
deprecated (@ixti)
|
9
|
+
|
1
10
|
0.6.1 (2014-05-07)
|
2
11
|
------------------
|
3
12
|
|
@@ -73,6 +82,12 @@ end
|
|
73
82
|
|
74
83
|
[Changes discussion](https://github.com/tarcieri/http/issues/116)
|
75
84
|
|
85
|
+
0.5.1 (2014-05-27)
|
86
|
+
------------------
|
87
|
+
|
88
|
+
* Backports redirector fixes from 0.6.0 (@ixti)
|
89
|
+
* EOL of 0.5.X branch.
|
90
|
+
|
76
91
|
0.5.0
|
77
92
|
-----
|
78
93
|
* Add query string support
|
data/Gemfile
CHANGED
@@ -17,12 +17,13 @@ end
|
|
17
17
|
|
18
18
|
group :test do
|
19
19
|
gem 'backports'
|
20
|
-
gem 'coveralls'
|
20
|
+
gem 'coveralls'
|
21
21
|
gem 'json', '>= 1.8.1', :platforms => [:jruby, :rbx, :ruby_18, :ruby_19]
|
22
22
|
gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
|
23
|
-
gem '
|
24
|
-
gem '
|
25
|
-
gem '
|
23
|
+
gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
|
24
|
+
gem 'rspec', '~> 2.14'
|
25
|
+
gem 'rubocop', '~> 0.24.0', :platforms => [:ruby_19, :ruby_20, :ruby_21]
|
26
|
+
gem 'simplecov', '>= 0.9'
|
26
27
|
gem 'yardstick'
|
27
28
|
end
|
28
29
|
|
data/README.md
CHANGED
@@ -118,7 +118,7 @@ HTTP.get "http://example.com/resource", :params => {:foo => "bar"}
|
|
118
118
|
Want to POST with a specific body, JSON for instance?
|
119
119
|
|
120
120
|
```ruby
|
121
|
-
HTTP.post "http://example.com/resource", :json => { :foo => '42' }
|
121
|
+
HTTP.post "http://example.com/resource", :json => { :foo => '42' }
|
122
122
|
```
|
123
123
|
|
124
124
|
It's easy!
|
@@ -206,7 +206,7 @@ class HttpFetcher
|
|
206
206
|
include Celluloid::IO
|
207
207
|
|
208
208
|
def fetch(url)
|
209
|
-
HTTP.get(url, socket_class: Celluloid::IO::TCPSocket)
|
209
|
+
HTTP.get(url, socket_class: Celluloid::IO::TCPSocket)
|
210
210
|
end
|
211
211
|
end
|
212
212
|
```
|
data/Rakefile
CHANGED
@@ -15,13 +15,13 @@ class HttpFetcher
|
|
15
15
|
def fetch(url)
|
16
16
|
# Note: For SSL support specify:
|
17
17
|
# ssl_socket_class: Celluloid::IO::SSLSocket
|
18
|
-
HTTP.get(url, :socket_class => Celluloid::IO::TCPSocket)
|
18
|
+
HTTP.get(url, :socket_class => Celluloid::IO::TCPSocket)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
fetcher = HttpFetcher.new
|
23
23
|
|
24
|
-
urls = %w[http://
|
24
|
+
urls = %w[http://ruby-lang.org/ http://rubygems.org/ http://celluloid.io/]
|
25
25
|
|
26
26
|
# Kick off a bunch of future calls to HttpFetcher to grab the URLs in parallel
|
27
27
|
futures = urls.map { |u| [u, fetcher.future.fetch(u)] }
|
@@ -4,23 +4,22 @@ module HTTP
|
|
4
4
|
module AuthorizationHeader
|
5
5
|
# OAuth2 Bearer token authorization header builder
|
6
6
|
# @see http://tools.ietf.org/html/rfc6750
|
7
|
+
#
|
8
|
+
# @deprecated Will be remove in v0.7.0
|
7
9
|
class BearerToken
|
8
10
|
# @param [#fetch] opts
|
9
11
|
# @option opts [#to_s] :token
|
10
|
-
# @option opts [
|
12
|
+
# @option opts [Boolean] :encode (false) deprecated
|
11
13
|
def initialize(opts)
|
12
|
-
|
13
|
-
@token = opts.fetch :token
|
14
|
-
end
|
14
|
+
warn "#{Kernel.caller.first}: [DEPRECATION] BearerToken deprecated."
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
@token
|
16
|
+
@token = opts.fetch :token
|
17
|
+
@token = Base64.strict_encode64 @token if opts.fetch(:encode, false)
|
19
18
|
end
|
20
19
|
|
21
20
|
# :nodoc:
|
22
21
|
def to_s
|
23
|
-
"Bearer #{token}"
|
22
|
+
"Bearer #{@token}"
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
data/lib/http/backports/uri.rb
CHANGED
@@ -81,11 +81,11 @@ module URI
|
|
81
81
|
encode_www_form_component(k)
|
82
82
|
elsif v.respond_to?(:to_ary)
|
83
83
|
v.to_ary.map do |w|
|
84
|
+
next unless w
|
85
|
+
|
84
86
|
str = encode_www_form_component(k)
|
85
|
-
|
86
|
-
|
87
|
-
str << encode_www_form_component(w)
|
88
|
-
end
|
87
|
+
str << '='
|
88
|
+
str << encode_www_form_component(w)
|
89
89
|
end.join('&')
|
90
90
|
else
|
91
91
|
str = encode_www_form_component(k)
|
data/lib/http/chainable.rb
CHANGED
@@ -73,10 +73,17 @@ module HTTP
|
|
73
73
|
with_response(:object)
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
|
-
|
76
|
+
# Make client follow redirects.
|
77
|
+
# @param opts (see Redirector#initialize)
|
78
|
+
# @return [HTTP::Client]
|
79
|
+
def follow(opts = true)
|
80
|
+
branch default_options.with_follow opts
|
78
81
|
end
|
79
82
|
|
83
|
+
# (see #follow)
|
84
|
+
# @deprecated
|
85
|
+
alias_method :with_follow, :follow
|
86
|
+
|
80
87
|
# Make a request with the given headers
|
81
88
|
def with_headers(headers)
|
82
89
|
branch default_options.with_headers(headers)
|
data/lib/http/client.rb
CHANGED
data/lib/http/options.rb
CHANGED
@@ -70,40 +70,12 @@ module HTTP
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
def with_params(params)
|
80
|
-
dup do |opts|
|
81
|
-
opts.params = params
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def with_form(form)
|
86
|
-
dup do |opts|
|
87
|
-
opts.form = form
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def with_json(data)
|
92
|
-
dup do |opts|
|
93
|
-
opts.json = data
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def with_body(body)
|
98
|
-
dup do |opts|
|
99
|
-
opts.body = body
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def with_follow(follow)
|
104
|
-
dup do |opts|
|
105
|
-
opts.follow = follow
|
106
|
-
end
|
73
|
+
%w[proxy params form json body follow].each do |method_name|
|
74
|
+
class_eval <<-RUBY, __FILE__, __LINE__
|
75
|
+
def with_#{method_name}(value)
|
76
|
+
dup { |opts| opts.#{method_name} = value }
|
77
|
+
end
|
78
|
+
RUBY
|
107
79
|
end
|
108
80
|
|
109
81
|
def [](option)
|
@@ -140,7 +112,7 @@ module HTTP
|
|
140
112
|
:socket_class => socket_class,
|
141
113
|
:ssl_socket_class => ssl_socket_class,
|
142
114
|
:ssl_context => ssl_context
|
143
|
-
|
115
|
+
}
|
144
116
|
end
|
145
117
|
|
146
118
|
def dup
|
data/lib/http/request.rb
CHANGED
@@ -15,6 +15,9 @@ module HTTP
|
|
15
15
|
# The scheme of given URI was not understood
|
16
16
|
class UnsupportedSchemeError < RequestError; end
|
17
17
|
|
18
|
+
# Default User-Agent header value
|
19
|
+
USER_AGENT = "RubyHTTPGem/#{HTTP::VERSION}".freeze
|
20
|
+
|
18
21
|
# RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1
|
19
22
|
METHODS = [:options, :get, :head, :post, :put, :delete, :trace, :connect]
|
20
23
|
|
@@ -36,6 +39,14 @@ module HTTP
|
|
36
39
|
# Allowed schemes
|
37
40
|
SCHEMES = [:http, :https, :ws, :wss]
|
38
41
|
|
42
|
+
# Default ports of supported schemes
|
43
|
+
PORTS = {
|
44
|
+
:http => 80,
|
45
|
+
:https => 443,
|
46
|
+
:ws => 80,
|
47
|
+
:wss => 443
|
48
|
+
}
|
49
|
+
|
39
50
|
# Method is given as a lowercase symbol e.g. :get, :post
|
40
51
|
attr_reader :verb
|
41
52
|
|
@@ -48,7 +59,7 @@ module HTTP
|
|
48
59
|
|
49
60
|
# The following method may be removed in two minor versions (0.7.0) or one
|
50
61
|
# major version (1.0.0)
|
51
|
-
def method(*
|
62
|
+
def method(*)
|
52
63
|
warn "#{Kernel.caller.first}: [DEPRECATION] HTTP::Request#method is deprecated. Use #verb instead. For Object#method, use #__method__."
|
53
64
|
@verb
|
54
65
|
end
|
@@ -71,8 +82,8 @@ module HTTP
|
|
71
82
|
|
72
83
|
@headers = HTTP::Headers.coerce(headers || {})
|
73
84
|
|
74
|
-
@headers['Host'] ||=
|
75
|
-
@headers['User-Agent'] ||=
|
85
|
+
@headers['Host'] ||= default_host
|
86
|
+
@headers['User-Agent'] ||= USER_AGENT
|
76
87
|
end
|
77
88
|
|
78
89
|
# Returns new Request with updated uri
|
@@ -125,5 +136,18 @@ module HTTP
|
|
125
136
|
def socket_port
|
126
137
|
using_proxy? ? proxy[:proxy_port] : uri.port
|
127
138
|
end
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
# Default host (with port if needed) header value.
|
143
|
+
#
|
144
|
+
# @return [String]
|
145
|
+
def default_host
|
146
|
+
if PORTS[@scheme] == @uri.port
|
147
|
+
@uri.host
|
148
|
+
else
|
149
|
+
"#{@uri.host}:#{@uri.port}"
|
150
|
+
end
|
151
|
+
end
|
128
152
|
end
|
129
153
|
end
|
data/lib/http/request/writer.rb
CHANGED
@@ -4,18 +4,16 @@ module HTTP
|
|
4
4
|
# CRLF is the universal HTTP delimiter
|
5
5
|
CRLF = "\r\n"
|
6
6
|
|
7
|
+
# Types valid to be used as body source
|
8
|
+
VALID_BODY_TYPES = [String, NilClass, Enumerable]
|
9
|
+
|
7
10
|
def initialize(socket, body, headers, headerstart) # rubocop:disable ParameterLists
|
8
11
|
@body = body
|
9
|
-
fail(RequestError, 'body of wrong type') unless valid_body_type
|
10
12
|
@socket = socket
|
11
13
|
@headers = headers
|
12
14
|
@request_header = [headerstart]
|
13
|
-
end
|
14
15
|
|
15
|
-
|
16
|
-
valid_types = [String, NilClass, Enumerable]
|
17
|
-
checks = valid_types.map { |type| @body.is_a?(type) }
|
18
|
-
checks.any?
|
16
|
+
validate_body_type!
|
19
17
|
end
|
20
18
|
|
21
19
|
# Adds headers to the request header from the headers array
|
@@ -74,6 +72,13 @@ module HTTP
|
|
74
72
|
@socket << '0' << CRLF * 2
|
75
73
|
end
|
76
74
|
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def validate_body_type!
|
79
|
+
return if VALID_BODY_TYPES.any? { |type| @body.is_a? type }
|
80
|
+
fail RequestError, "body of wrong type: #{@body.class}"
|
81
|
+
end
|
77
82
|
end
|
78
83
|
end
|
79
84
|
end
|
data/lib/http/response/parser.rb
CHANGED
data/lib/http/version.rb
CHANGED
data/spec/http/client_spec.rb
CHANGED
@@ -133,7 +133,7 @@ describe HTTP::Client do
|
|
133
133
|
let(:client) { described_class.new :headers => headers }
|
134
134
|
|
135
135
|
it 'keeps `Host` header as is' do
|
136
|
-
expect(client).to receive(:perform) do |req,
|
136
|
+
expect(client).to receive(:perform) do |req, _|
|
137
137
|
expect(req['Host']).to eq 'another.example.com'
|
138
138
|
end
|
139
139
|
|
data/spec/http/request_spec.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe HTTP::Request do
|
4
|
+
let(:headers) { {:accept => 'text/html'} }
|
5
|
+
let(:request_uri) { 'http://example.com/' }
|
6
|
+
|
7
|
+
subject(:request) { HTTP::Request.new(:get, request_uri, headers) }
|
8
|
+
|
4
9
|
it 'includes HTTP::Headers::Mixin' do
|
5
10
|
expect(described_class).to include HTTP::Headers::Mixin
|
6
11
|
end
|
@@ -11,35 +16,57 @@ describe HTTP::Request do
|
|
11
16
|
end
|
12
17
|
|
13
18
|
it 'provides a #scheme accessor' do
|
14
|
-
request = HTTP::Request.new(:get, 'http://example.com/')
|
15
19
|
expect(request.scheme).to eq(:http)
|
16
20
|
end
|
17
21
|
|
18
|
-
|
19
|
-
subject
|
22
|
+
it 'sets given headers' do
|
23
|
+
expect(subject['Accept']).to eq('text/html')
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'Host header' do
|
27
|
+
subject { request['Host'] }
|
28
|
+
|
29
|
+
context 'was not given' do
|
30
|
+
it { is_expected.to eq 'example.com' }
|
20
31
|
|
21
|
-
|
22
|
-
|
32
|
+
context 'and request URI has non-standard port' do
|
33
|
+
let(:request_uri) { 'http://example.com:3000/' }
|
34
|
+
it { is_expected.to eq 'example.com:3000' }
|
35
|
+
end
|
23
36
|
end
|
24
37
|
|
25
|
-
|
26
|
-
|
38
|
+
context 'was explicitly given' do
|
39
|
+
before { headers[:host] = 'github.com' }
|
40
|
+
it { is_expected.to eq 'github.com' }
|
27
41
|
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'User-Agent header' do
|
45
|
+
subject { request['User-Agent'] }
|
28
46
|
|
29
|
-
|
30
|
-
|
47
|
+
context 'was not given' do
|
48
|
+
it { is_expected.to eq HTTP::Request::USER_AGENT }
|
31
49
|
end
|
32
50
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
expect(warning).to match(/\[DEPRECATION\] HTTP::Request#method is deprecated\. Use #verb instead\. For Object#method, use #__method__\.$/)
|
51
|
+
context 'was explicitly given' do
|
52
|
+
before { headers[:user_agent] = 'MrCrawly/123' }
|
53
|
+
it { is_expected.to eq 'MrCrawly/123' }
|
38
54
|
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'provides a #verb accessor' do
|
58
|
+
expect(subject.verb).to eq(:get)
|
59
|
+
end
|
39
60
|
|
40
|
-
|
41
|
-
|
61
|
+
it 'provides a #method accessor that outputs a deprecation warning and returns the verb' do
|
62
|
+
warning = capture_warning do
|
63
|
+
expect(subject.method).to eq(subject.verb)
|
42
64
|
end
|
65
|
+
expect(warning).to match(/\[DEPRECATION\] HTTP::Request#method is deprecated\. Use #verb instead\. For Object#method, use #__method__\.$/)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'provides a #__method__ method that delegates to Object#method' do
|
69
|
+
expect(subject.__method__(:verb)).to be_a(Method)
|
43
70
|
end
|
44
71
|
|
45
72
|
describe '#redirect' do
|
@@ -60,6 +87,20 @@ describe HTTP::Request do
|
|
60
87
|
expect(redirected['Host']).to eq 'blog.example.com'
|
61
88
|
end
|
62
89
|
|
90
|
+
context 'with schema-less absolute URL given' do
|
91
|
+
subject(:redirected) { request.redirect '//another.example.com/blog' }
|
92
|
+
|
93
|
+
its(:uri) { should eq URI.parse 'http://another.example.com/blog' }
|
94
|
+
|
95
|
+
its(:verb) { should eq request.verb }
|
96
|
+
its(:body) { should eq request.body }
|
97
|
+
its(:proxy) { should eq request.proxy }
|
98
|
+
|
99
|
+
it 'presets new Host header' do
|
100
|
+
expect(redirected['Host']).to eq 'another.example.com'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
63
104
|
context 'with relative URL given' do
|
64
105
|
subject(:redirected) { request.redirect '/blog' }
|
65
106
|
|
data/spec/http_spec.rb
CHANGED
@@ -18,15 +18,15 @@ describe HTTP do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'with query string parameters' do
|
21
|
-
it '
|
22
|
-
response = HTTP.get "#{test_endpoint}params"
|
21
|
+
it 'is easy' do
|
22
|
+
response = HTTP.get "#{test_endpoint}params", :params => {:foo => 'bar'}
|
23
23
|
expect(response.to_s).to match(/Params!/)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'with query string parameters in the URI and opts hash' do
|
28
28
|
it 'includes both' do
|
29
|
-
response = HTTP.get "#{test_endpoint}multiple-params?foo=bar"
|
29
|
+
response = HTTP.get "#{test_endpoint}multiple-params?foo=bar", :params => {:baz => 'quux'}
|
30
30
|
expect(response.to_s).to match(/More Params!/)
|
31
31
|
end
|
32
32
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
|
2
|
-
require '
|
1
|
+
if RUBY_VERSION >= '1.9'
|
2
|
+
require 'simplecov'
|
3
|
+
require 'coveralls'
|
3
4
|
|
4
|
-
SimpleCov.
|
5
|
-
SimpleCov::Formatter::HTMLFormatter,
|
6
|
-
Coveralls::SimpleCov::Formatter
|
7
|
-
]
|
5
|
+
SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
|
8
6
|
|
9
|
-
SimpleCov.start do
|
10
|
-
|
11
|
-
|
7
|
+
SimpleCov.start do
|
8
|
+
add_filter '/spec/'
|
9
|
+
minimum_coverage(80)
|
10
|
+
end
|
12
11
|
end
|
13
12
|
|
14
13
|
require 'http'
|
@@ -41,18 +41,19 @@ class ExampleService < WEBrick::HTTPServlet::AbstractServlet
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def handle_params(request, response)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
return unless request.query_string == 'foo=bar'
|
45
|
+
|
46
|
+
response.status = 200
|
47
|
+
response.body = 'Params!'
|
48
48
|
end
|
49
49
|
|
50
50
|
def handle_multiple_params(request, response)
|
51
51
|
params = CGI.parse(request.query_string)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
|
53
|
+
return unless params == {'foo' => ['bar'], 'baz' => ['quux']}
|
54
|
+
|
55
|
+
response.status = 200
|
56
|
+
response.body = 'More Params!'
|
56
57
|
end
|
57
58
|
|
58
59
|
def do_POST(request, response) # rubocop:disable MethodName
|
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.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: http_parser.rb
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.2.
|
134
|
+
rubygems_version: 2.2.2
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: HTTP should be easy
|