http 0.8.13 → 0.8.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/lib/http/request.rb +15 -2
- data/lib/http/uri.rb +7 -2
- data/lib/http/version.rb +1 -1
- data/spec/lib/http/request_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bde805c006e8d041591f271243d2e889e2134bc1
|
4
|
+
data.tar.gz: ec416925025cf7c7686f3e21b525bafeaa773ce6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66f67e4665d52a746081b25fbf331884eaadcd45c2716cde98de3eccbc33262cce3fea3e581ea3b46699e89e51623f9afe27794f8a2d43c3d6cf7aed4752bd22
|
7
|
+
data.tar.gz: 97bcbc0ec6607e3a34dfcc9d0a6d1e2730501a67f0d3133e9c2141f2967a17af2e4ea9d00f88b70b04a5ffcde954d9db99c7085bd3ebdb737c4dc42e644c78c8
|
data/CHANGES.md
CHANGED
data/lib/http/request.rb
CHANGED
@@ -67,7 +67,7 @@ module HTTP
|
|
67
67
|
# :nodoc:
|
68
68
|
def initialize(verb, uri, headers = {}, proxy = {}, body = nil, version = "1.1") # rubocop:disable ParameterLists
|
69
69
|
@verb = verb.to_s.downcase.to_sym
|
70
|
-
@uri =
|
70
|
+
@uri = normalize_uri uri
|
71
71
|
@scheme = @uri.scheme && @uri.scheme.to_s.downcase.to_sym
|
72
72
|
|
73
73
|
fail(UnsupportedMethodError, "unknown method: #{verb}") unless METHODS.include?(@verb)
|
@@ -124,7 +124,7 @@ module HTTP
|
|
124
124
|
# Compute HTTP request header for direct or proxy request
|
125
125
|
def headline
|
126
126
|
request_uri = using_proxy? ? uri : uri.omit(:scheme, :authority)
|
127
|
-
"#{verb.to_s.upcase} #{request_uri} HTTP/#{version}"
|
127
|
+
"#{verb.to_s.upcase} #{request_uri.omit :fragment} HTTP/#{version}"
|
128
128
|
end
|
129
129
|
|
130
130
|
# @deprecated Will be removed in 1.0.0
|
@@ -178,5 +178,18 @@ module HTTP
|
|
178
178
|
def default_host_header_value
|
179
179
|
PORTS[@scheme] != port ? "#{host}:#{port}" : host
|
180
180
|
end
|
181
|
+
|
182
|
+
# @return [HTTP::URI] URI with all componentes but query being normalized.
|
183
|
+
def normalize_uri(uri)
|
184
|
+
uri = HTTP::URI.parse uri
|
185
|
+
|
186
|
+
HTTP::URI.new(
|
187
|
+
:scheme => uri.normalized_scheme,
|
188
|
+
:authority => uri.normalized_authority,
|
189
|
+
:path => uri.normalized_path,
|
190
|
+
:query => uri.query,
|
191
|
+
:fragment => uri.normalized_fragment
|
192
|
+
)
|
193
|
+
end
|
181
194
|
end
|
182
195
|
end
|
data/lib/http/uri.rb
CHANGED
@@ -2,10 +2,10 @@ require "addressable/uri"
|
|
2
2
|
|
3
3
|
module HTTP
|
4
4
|
class URI < Addressable::URI
|
5
|
-
#
|
5
|
+
# @private
|
6
6
|
HTTP_SCHEME = "http".freeze
|
7
7
|
|
8
|
-
#
|
8
|
+
# @private
|
9
9
|
HTTPS_SCHEME = "https".freeze
|
10
10
|
|
11
11
|
# @return [True] if URI is HTTP
|
@@ -19,5 +19,10 @@ module HTTP
|
|
19
19
|
def https?
|
20
20
|
HTTPS_SCHEME == scheme
|
21
21
|
end
|
22
|
+
|
23
|
+
# @return [String] human-readable representation of URI
|
24
|
+
def inspect
|
25
|
+
format("#<%s:%#0x URI:%s>", self.class, object_id, to_s)
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
data/lib/http/version.rb
CHANGED
@@ -141,11 +141,11 @@ RSpec.describe HTTP::Request do
|
|
141
141
|
describe "#headline" do
|
142
142
|
subject { request.headline }
|
143
143
|
|
144
|
-
it { is_expected.to eq "GET /foo?bar=baz
|
144
|
+
it { is_expected.to eq "GET /foo?bar=baz HTTP/1.1" }
|
145
145
|
|
146
146
|
context "with proxy" do
|
147
147
|
let(:proxy) { {:user => "user", :pass => "pass"} }
|
148
|
-
it { is_expected.to eq "GET http://example.com/foo?bar=baz
|
148
|
+
it { is_expected.to eq "GET http://example.com/foo?bar=baz HTTP/1.1" }
|
149
149
|
end
|
150
150
|
end
|
151
151
|
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.8.
|
4
|
+
version: 0.8.14
|
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-08-
|
14
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: http_parser.rb
|