http 0.8.13 → 0.8.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c377300d1381925e494d179d86be2c8c58d6713a
4
- data.tar.gz: eeed70bcd44a8c11b164da27f0de196a77a9a5db
3
+ metadata.gz: bde805c006e8d041591f271243d2e889e2134bc1
4
+ data.tar.gz: ec416925025cf7c7686f3e21b525bafeaa773ce6
5
5
  SHA512:
6
- metadata.gz: b9b9287f6db01ead5a849cb7bfec0a75d9de5de808c8c7f86bcfdd0940d895639b6786f694d533b2d30ed50e2af943093c5fa8102cd4547a7f17e2912f030cbe
7
- data.tar.gz: 2db3d208ee7f88366b9118473257574ae413576820fdef9b780566caeb77598512754e64960a58bb7e6533dad66018fe283c224cd1ed3b88cddb9f93b100cd89
6
+ metadata.gz: 66f67e4665d52a746081b25fbf331884eaadcd45c2716cde98de3eccbc33262cce3fea3e581ea3b46699e89e51623f9afe27794f8a2d43c3d6cf7aed4752bd22
7
+ data.tar.gz: 97bcbc0ec6607e3a34dfcc9d0a6d1e2730501a67f0d3133e9c2141f2967a17af2e4ea9d00f88b70b04a5ffcde954d9db99c7085bd3ebdb737c4dc42e644c78c8
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.8.14 (2015-08-19)
2
+
3
+ * Backport request URI normalization fixes from master. (@ixti)
4
+
5
+
1
6
  ## 0.8.13 (2015-08-14)
2
7
 
3
8
  * Backport params special-chars escaping fix from `v0.9.1`. (@ixti)
@@ -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 = HTTP::URI.parse(uri).normalize
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
@@ -2,10 +2,10 @@ require "addressable/uri"
2
2
 
3
3
  module HTTP
4
4
  class URI < Addressable::URI
5
- # HTTP scheme
5
+ # @private
6
6
  HTTP_SCHEME = "http".freeze
7
7
 
8
- # HTTPS scheme
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
@@ -1,3 +1,3 @@
1
1
  module HTTP
2
- VERSION = "0.8.13".freeze
2
+ VERSION = "0.8.14".freeze
3
3
  end
@@ -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#moo HTTP/1.1" }
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#moo HTTP/1.1" }
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.13
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 00:00:00.000000000 Z
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