http.rb 0.18.1 → 0.18.2

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
  SHA256:
3
- metadata.gz: 3cf46d2fcd2e4e18c1bd5fb1245da1156b14d694871970fb6d827d5a79f2a533
4
- data.tar.gz: 786e1c2b4fc5314e2626f466bfd249d7a24ea80b607ed0f3c67333c6220147e2
3
+ metadata.gz: 5cdc1621048e0c428eb0b0c2ae81ae534921007746d58b426cc1185e6a77557a
4
+ data.tar.gz: 80f9b3f58b9c410093e74243b6a23ac364a50c3579c47ddf51e3e77e9b80a769
5
5
  SHA512:
6
- metadata.gz: 86963812021231537e441627cbe6e617920409c465010296e4f513f838c40df51005edfc25083ad03348566de02c94a80ae9a3ccfa26c956abe00274425857aa
7
- data.tar.gz: d5b6e217124fffa5ee8a23e78c316e9d8bbce7cfe8523613923ac18b34bfa74e003a21294b793ddca56785261ea8f765e158adae3b83663d732aa19c12c38fcc
6
+ metadata.gz: 63d22c4b9ed0a909a8a72dcf9cf00f44d0aad730f5e6bdd0aef6a70616bf27b12b81737ee71f5e5d368d46142355fe7046cafe633d5e6b3b744b4c19c8e42d16
7
+ data.tar.gz: f5bc846fae0969a4892926c1d739a549de54dc1a4765a4996bcbf56144c4d56bfedfb1044fd7399d3cfcfb7cfcd4ee4eca88c11c8c93433b665f1094d96ddd2f
data/CHANGELOG CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
+ # 20260520
4
+ # 0.18.2: Fix relative redirect URL construction.
5
+ 1. ~ HTTP.request: Use URI#merge for redirect URL construction. Preserves original scheme, elides default ports, and resolves relative paths per RFC 3986.
6
+ 2. ~ spec/HTTP/get_spec.rb: Update relative-redirect stubs to elide default port; + context for HTTPS relative redirect.
7
+ 3. ~ spec/HTTP/post_spec.rb: Update relative-redirect stubs to elide default port.
8
+ 4. ~ spec/HTTP/put_spec.rb: Update relative-redirect stubs to elide default port.
9
+ 5. ~ spec/HTTP/delete_spec.rb: Update relative-redirect stubs to elide default port.
10
+ 6. ~ HTTP::VERSION: /0.18.1/0.18.2/
11
+ 7. ~ CHANGELOG: + 0.18.2 entry
12
+
3
13
  # 20260508
4
14
  # 0.18.1: Remove incorrectly added WebDAV verbs.
5
15
  1. - lib/Net/HTTP/Report.rb
data/lib/HTTP/VERSION.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # HTTP::VERSION
3
3
 
4
4
  module HTTP
5
- VERSION = '0.18.1'
5
+ VERSION = '0.18.2'
6
6
  end
data/lib/HTTP/request.rb CHANGED
@@ -27,13 +27,8 @@ module HTTP
27
27
  elsif no_redirect
28
28
  return response
29
29
  end
30
- redirect_uri = URI.parse(response.header['location'])
31
- if redirect_uri.scheme
32
- response = get(response.header['location'], {}, {}, options, &block)
33
- else
34
- new_location = "http://#{uri.host}:#{uri.port}#{response.header['location']}"
35
- response = get(new_location, {}, {}, options, &block)
36
- end
30
+ redirect_uri = uri.merge(response.header['location'])
31
+ response = get(redirect_uri.to_s, {}, {}, options, &block)
37
32
  end
38
33
  if block_given?
39
34
  yield response
@@ -173,7 +173,7 @@ describe ".delete" do
173
173
  context "with path only redirection" do
174
174
  let(:request_uri){'http://example.com/path'}
175
175
  let(:redirect_path){'/new_path'}
176
- let(:redirect_uri){"http://example.com:80#{redirect_path}"}
176
+ let(:redirect_uri){"http://example.com#{redirect_path}"}
177
177
 
178
178
  before do
179
179
  stub_request(:get, redirect_uri).
@@ -173,7 +173,7 @@ describe ".get" do
173
173
  context "with path only redirection" do
174
174
  let(:request_uri){'http://example.com/path'}
175
175
  let(:redirect_path){'/new_path'}
176
- let(:redirect_uri){"http://example.com:80#{redirect_path}"}
176
+ let(:redirect_uri){"http://example.com#{redirect_path}"}
177
177
 
178
178
  before do
179
179
  stub_request(:get, redirect_uri).
@@ -212,6 +212,28 @@ describe ".get" do
212
212
  end
213
213
  end
214
214
 
215
+ context "with path only redirection from HTTPS" do
216
+ let(:request_uri){'https://example.com/path'}
217
+ let(:redirect_path){'/new_path'}
218
+ let(:redirect_uri){"https://example.com#{redirect_path}"}
219
+
220
+ before do
221
+ stub_request(:get, redirect_uri).
222
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
223
+ to_return(status: 200, body: '', headers: {})
224
+ stub_request(:get, request_uri).
225
+ with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}).
226
+ to_return(status: 301, body: '', headers: {'location' => redirect_path})
227
+ end
228
+
229
+ it "preserves the HTTPS scheme on a relative redirect" do
230
+ expect(HTTP).to receive(:get).once.with(request_uri).and_call_original
231
+ expect(HTTP).to receive(:get).once.with(redirect_uri, {}, {}, {use_ssl: true, verify_mode: 0}).and_call_original
232
+ response = HTTP.get(request_uri)
233
+ expect(response.success?).to eq(true)
234
+ end
235
+ end
236
+
215
237
  context "no_redirect true" do
216
238
  let(:request_uri){'http://example.com/path'}
217
239
  let(:redirect_uri){'http://redirected.com'}
@@ -311,7 +311,7 @@ describe ".post" do
311
311
  context "with path only redirection" do
312
312
  let(:request_uri){'http://example.com/path'}
313
313
  let(:redirect_path){'/new_path'}
314
- let(:redirect_uri){"http://example.com:80#{redirect_path}"}
314
+ let(:redirect_uri){"http://example.com#{redirect_path}"}
315
315
 
316
316
  before do
317
317
  stub_request(:get, redirect_uri).
@@ -311,7 +311,7 @@ describe ".put" do
311
311
  context "with path only redirection" do
312
312
  let(:request_uri){'http://example.com/path'}
313
313
  let(:redirect_path){'/new_path'}
314
- let(:redirect_uri){"http://example.com:80#{redirect_path}"}
314
+ let(:redirect_uri){"http://example.com#{redirect_path}"}
315
315
 
316
316
  before do
317
317
  stub_request(:get, redirect_uri).
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.18.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran
@@ -79,6 +79,7 @@ files:
79
79
  - README.md
80
80
  - Rakefile
81
81
  - http.rb.gemspec
82
+ - lib/HTTP.rb
82
83
  - lib/HTTP/VERSION.rb
83
84
  - lib/HTTP/request.rb
84
85
  - lib/HTTP/verbs.rb
@@ -92,7 +93,6 @@ files:
92
93
  - lib/Thoran/Array/FirstX/firstX.rb
93
94
  - lib/Thoran/String/ToConst/to_const.rb
94
95
  - lib/URI/Generic/use_sslQ.rb
95
- - lib/http.rb
96
96
  - spec/HTTP/delete_spec.rb
97
97
  - spec/HTTP/get_spec.rb
98
98
  - spec/HTTP/head_spec.rb
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 4.0.11
120
+ rubygems_version: 4.0.12
121
121
  specification_version: 4
122
122
  summary: HTTP made easy.
123
123
  test_files: []
File without changes