http.rb 1.3.11 → 1.4.0
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 +4 -4
- data/CHANGELOG +15 -0
- data/README.md +13 -0
- data/lib/HTTP/REDIRECT.rb +14 -0
- data/lib/HTTP/VERSION.rb +1 -1
- data/lib/HTTP/request.rb +6 -4
- data/test/HTTP/REDIRECT_test.rb +70 -0
- data/test/HTTP/delete_test.rb +8 -8
- data/test/HTTP/head_test.rb +2 -2
- data/test/HTTP/options_test.rb +8 -8
- data/test/HTTP/patch_test.rb +10 -10
- data/test/HTTP/put_test.rb +10 -10
- data/test/HTTP/trace_test.rb +8 -8
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd64e430f4c763d9a11367ecc26c6d419f9b5a0304c8084c41f995187d5b179a
|
|
4
|
+
data.tar.gz: bd8d9c977ed8e594a80c97a65d546270cf15dc482b2ee4440e5eeb739c2240b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 86146298fe511634f52a083fce07d96b3524a7faf46611cb262bf3e502c4ad413a233081091936a798649b6d9126061945ef34ef0b4a8e2c12ae8f0f2c3a87df
|
|
7
|
+
data.tar.gz: 8d6138d16b159c467dd645e675b7f0753e2693eb0a31c2cdf953731c90a0b9bde5ee3a90cee29ed7be928398a28ad27ab2bfe784cd9eafa66111c2cec4a42d98
|
data/CHANGELOG
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 20261011
|
|
4
|
+
|
|
5
|
+
1.4.0: The method on a redirect is as RFC 9110 has it: a DELETE redirected by a 301 or 302 is now a DELETE, a PUT a PUT, and a HEAD a HEAD.
|
|
6
|
+
|
|
7
|
+
Every 301, 302, and 303 was followed with a GET, whatever the method. RFC 9110 allows a 301 or 302 to make a POST a GET, for historical reasons, and nothing else: a PUT, a PATCH, a DELETE, an OPTIONS, or a TRACE was turned into a GET, which did something other than was asked, and a HEAD was too, which fetched the body a HEAD is made to avoid. A 303 does make the method a GET, except for a HEAD, which stays one. Those which were made a GET will now be repeated as themselves, a DELETE included, which is what the specification asks but which differs from what was done before, so anyone whose redirected DELETE, PUT, or PATCH was quietly becoming a GET will find it isn't.
|
|
8
|
+
|
|
9
|
+
1. ~ lib/HTTP/REDIRECT.rb: + HTTP.redirect_method: 307 and 308 keep the method; 303 makes it a GET, a HEAD excepted; 301 and 302 make a POST a GET and keep the rest.
|
|
10
|
+
2. ~ HTTP.request: a redirect is made with redirect_method, through request_with_body where the request had a body to repeat and request_without_body otherwise, rather than through the named method. Content-Type is left behind only where the method changes, and a body repeated keeps it through body_headers, as 1.3.11 has a 307 or 308 do, which matters the more now that a PUT or PATCH redirected by a 301 or 302 is repeated with its body rather than made a GET.
|
|
11
|
+
3. ~ HTTP.request: a method without a named helper, such as PROPFIND made with request_without_body, is followed. A 307 or 308 was followed with send(request_method), which raised NoMethodError for one.
|
|
12
|
+
4. ~ test/HTTP/{delete,head,options,patch,put,trace}_test.rb: a 301 or 302 is expected to be followed with the method itself rather than with GET.
|
|
13
|
+
5. ~ test/HTTP/REDIRECT_test.rb: + the method through each of 301, 302, 303, 307, and 308: POST, PUT with its body, DELETE, HEAD, and PROPFIND. The ones which keep a method other than GET or POST fail against 1.3.11, and PROPFIND by 307 and 308 raised. The PUT examples assert its Content-Type as well as its body.
|
|
14
|
+
6. ~ README.md: + how the method is kept, under Redirections, with a table of each method through each redirect.
|
|
15
|
+
7. ~ HTTP::VERSION: /1.3.11/1.4.0/
|
|
16
|
+
|
|
17
|
+
|
|
3
18
|
## 20261011
|
|
4
19
|
|
|
5
20
|
1.3.11: A repeated body keeps the Content-Type it was sent with.
|
data/README.md
CHANGED
|
@@ -97,6 +97,19 @@ When both are supplied, the options hash wins.
|
|
|
97
97
|
|
|
98
98
|
301, 302, 303, 307, and 308 responses with a `Location` are followed. Other 3xx responses, such as 300 and 304, are returned as they are.
|
|
99
99
|
|
|
100
|
+
The method is kept as RFC 9110 has it. 307 and 308 repeat the request as it was. 303 makes it a GET, except that a HEAD stays a HEAD. 301 and 302 make a POST a GET, as browsers do, and keep every other method:
|
|
101
|
+
|
|
102
|
+
| Method | 301, 302 | 303 | 307, 308 |
|
|
103
|
+
| --- | --- | --- | --- |
|
|
104
|
+
| GET | GET | GET | GET |
|
|
105
|
+
| HEAD | HEAD | HEAD | HEAD |
|
|
106
|
+
| POST | GET, without its body | GET, without its body | POST, with its body |
|
|
107
|
+
| PUT, PATCH | kept, with its body | GET, without its body | kept, with its body |
|
|
108
|
+
| DELETE, OPTIONS, TRACE | kept | GET | kept |
|
|
109
|
+
| Any other, such as PROPFIND | kept | GET | kept |
|
|
110
|
+
|
|
111
|
+
A body repeated keeps its `Content-Type`, form data's included. Where the method changes, `Content-Type` is left behind with the body.
|
|
112
|
+
|
|
100
113
|
Redirects are followed with the headers they were given, except that `Authorization` and `Cookie`, and the `username:` and `password:` options, go no further than the origin (scheme, host, and port) they were given to. Where a redirect makes the request a GET, `Content-Type` is left behind, there being no body for it to describe.
|
|
101
114
|
|
|
102
115
|
### Preventing redirections
|
data/lib/HTTP/REDIRECT.rb
CHANGED
|
@@ -14,6 +14,20 @@ module HTTP
|
|
|
14
14
|
end
|
|
15
15
|
module_function :redirect?
|
|
16
16
|
|
|
17
|
+
# 307 and 308 keep the method. 303 makes it a GET, a HEAD excepted. 301 and 302 make
|
|
18
|
+
# only a POST a GET, which RFC 9110 allows for historical reasons, and keep the rest.
|
|
19
|
+
def redirect_method(code, request_method)
|
|
20
|
+
case code
|
|
21
|
+
when '303'
|
|
22
|
+
request_method == :head ? :head : :get
|
|
23
|
+
when '301', '302'
|
|
24
|
+
request_method == :post ? :get : request_method
|
|
25
|
+
else
|
|
26
|
+
request_method
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
module_function :redirect_method
|
|
30
|
+
|
|
17
31
|
def same_origin?(a, b)
|
|
18
32
|
[a.scheme, a.host, a.port] == [b.scheme, b.host, b.port]
|
|
19
33
|
end
|
data/lib/HTTP/VERSION.rb
CHANGED
data/lib/HTTP/request.rb
CHANGED
|
@@ -43,11 +43,13 @@ module HTTP
|
|
|
43
43
|
if !no_redirect && redirect?(response)
|
|
44
44
|
redirect_uri = uri.merge(response['location'])
|
|
45
45
|
onward_options = redirect_options(given_options, uri, redirect_uri)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
46
|
+
redirect_method = redirect_method(response.code, request_method)
|
|
47
|
+
if redirect_method != request_method
|
|
48
|
+
return request_without_body(redirect_method, redirect_uri, {}, redirect_headers(headers, uri, redirect_uri, drop_content_type: true), onward_options, &block)
|
|
49
|
+
elsif request_object.body
|
|
50
|
+
return request_with_body(request_method, redirect_uri, request_object.body, redirect_headers(body_headers(headers, request_object), uri, redirect_uri), onward_options, &block)
|
|
49
51
|
else
|
|
50
|
-
return
|
|
52
|
+
return request_without_body(request_method, redirect_uri, {}, redirect_headers(headers, uri, redirect_uri), onward_options, &block)
|
|
51
53
|
end
|
|
52
54
|
end
|
|
53
55
|
if block_given?
|
data/test/HTTP/REDIRECT_test.rb
CHANGED
|
@@ -145,4 +145,74 @@ describe "redirect behaviour" do
|
|
|
145
145
|
_(HTTP.post(uri, {a: 1}, {'Content-Type' => 'application/json'}).success?).must_equal(true)
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
|
+
|
|
149
|
+
describe "the method" do
|
|
150
|
+
%w{301 302}.each do |code|
|
|
151
|
+
describe "via #{code}" do
|
|
152
|
+
it "makes a POST a GET" do
|
|
153
|
+
stub_request(:post, uri).to_return(status: code.to_i, headers: {'location' => same_origin_uri})
|
|
154
|
+
stub_request(:get, same_origin_uri).to_return(status: 200)
|
|
155
|
+
_(HTTP.post(uri, {a: 1}).success?).must_equal(true)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it "keeps a PUT, with its body and its Content-Type" do
|
|
159
|
+
stub_request(:put, uri).to_return(status: code.to_i, headers: {'location' => same_origin_uri})
|
|
160
|
+
stub_request(:put, same_origin_uri).with(body: 'a=1', headers: {'Content-Type' => 'application/x-www-form-urlencoded'}).to_return(status: 200)
|
|
161
|
+
_(HTTP.put(uri, {a: 1}).success?).must_equal(true)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it "keeps a DELETE" do
|
|
165
|
+
stub_request(:delete, uri).to_return(status: code.to_i, headers: {'location' => same_origin_uri})
|
|
166
|
+
stub_request(:delete, same_origin_uri).to_return(status: 200)
|
|
167
|
+
_(HTTP.delete(uri).success?).must_equal(true)
|
|
168
|
+
assert_not_requested(:get, same_origin_uri)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "keeps a HEAD" do
|
|
172
|
+
stub_request(:head, uri).to_return(status: code.to_i, headers: {'location' => same_origin_uri})
|
|
173
|
+
stub_request(:head, same_origin_uri).to_return(status: 200)
|
|
174
|
+
_(HTTP.head(uri).success?).must_equal(true)
|
|
175
|
+
assert_not_requested(:get, same_origin_uri)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it "keeps a method without a named helper" do
|
|
179
|
+
stub_request(:propfind, uri).to_return(status: code.to_i, headers: {'location' => same_origin_uri})
|
|
180
|
+
stub_request(:propfind, same_origin_uri).to_return(status: 207)
|
|
181
|
+
_(HTTP.request_without_body(:propfind, uri).code).must_equal('207')
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
describe "via 303" do
|
|
187
|
+
%i{post put delete}.each do |request_method|
|
|
188
|
+
it "makes a #{request_method.upcase} a GET" do
|
|
189
|
+
stub_request(request_method, uri).to_return(status: 303, headers: {'location' => same_origin_uri})
|
|
190
|
+
stub_request(:get, same_origin_uri).to_return(status: 200)
|
|
191
|
+
_(HTTP.send(request_method, uri).success?).must_equal(true)
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it "keeps a HEAD" do
|
|
196
|
+
stub_request(:head, uri).to_return(status: 303, headers: {'location' => same_origin_uri})
|
|
197
|
+
stub_request(:head, same_origin_uri).to_return(status: 200)
|
|
198
|
+
_(HTTP.head(uri).success?).must_equal(true)
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
%w{307 308}.each do |code|
|
|
203
|
+
describe "via #{code}" do
|
|
204
|
+
it "keeps a POST, with its body" do
|
|
205
|
+
stub_request(:post, uri).to_return(status: code.to_i, headers: {'location' => same_origin_uri})
|
|
206
|
+
stub_request(:post, same_origin_uri).with(body: 'a=1').to_return(status: 200)
|
|
207
|
+
_(HTTP.post(uri, {a: 1}).success?).must_equal(true)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
it "keeps a method without a named helper" do
|
|
211
|
+
stub_request(:propfind, uri).to_return(status: code.to_i, headers: {'location' => same_origin_uri})
|
|
212
|
+
stub_request(:propfind, same_origin_uri).to_return(status: 207)
|
|
213
|
+
_(HTTP.request_without_body(:propfind, uri).code).must_equal('207')
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
end
|
|
148
218
|
end
|
data/test/HTTP/delete_test.rb
CHANGED
|
@@ -143,7 +143,7 @@ describe ".delete" do
|
|
|
143
143
|
let(:redirect_uri){'http://redirected.com'}
|
|
144
144
|
|
|
145
145
|
before do
|
|
146
|
-
stub_request(:
|
|
146
|
+
stub_request(:delete, redirect_uri).
|
|
147
147
|
to_return(status: 200, body: '', headers: {})
|
|
148
148
|
end
|
|
149
149
|
|
|
@@ -157,7 +157,7 @@ describe ".delete" do
|
|
|
157
157
|
response = HTTP.delete(request_uri)
|
|
158
158
|
_(response.success?).must_equal(true)
|
|
159
159
|
assert_requested(:delete, request_uri)
|
|
160
|
-
assert_requested(:
|
|
160
|
+
assert_requested(:delete, redirect_uri)
|
|
161
161
|
end
|
|
162
162
|
end
|
|
163
163
|
|
|
@@ -171,7 +171,7 @@ describe ".delete" do
|
|
|
171
171
|
response = HTTP.delete(request_uri)
|
|
172
172
|
_(response.success?).must_equal(true)
|
|
173
173
|
assert_requested(:delete, request_uri)
|
|
174
|
-
assert_requested(:
|
|
174
|
+
assert_requested(:delete, redirect_uri)
|
|
175
175
|
end
|
|
176
176
|
end
|
|
177
177
|
end
|
|
@@ -182,7 +182,7 @@ describe ".delete" do
|
|
|
182
182
|
let(:redirect_uri){"http://example.com#{redirect_path}"}
|
|
183
183
|
|
|
184
184
|
before do
|
|
185
|
-
stub_request(:
|
|
185
|
+
stub_request(:delete, redirect_uri).
|
|
186
186
|
to_return(status: 200, body: '', headers: {})
|
|
187
187
|
end
|
|
188
188
|
|
|
@@ -195,7 +195,7 @@ describe ".delete" do
|
|
|
195
195
|
it "resolves the relative redirect against the original URI" do
|
|
196
196
|
response = HTTP.delete(request_uri)
|
|
197
197
|
_(response.success?).must_equal(true)
|
|
198
|
-
assert_requested(:
|
|
198
|
+
assert_requested(:delete, redirect_uri)
|
|
199
199
|
end
|
|
200
200
|
end
|
|
201
201
|
|
|
@@ -208,7 +208,7 @@ describe ".delete" do
|
|
|
208
208
|
it "resolves the relative redirect against the original URI" do
|
|
209
209
|
response = HTTP.delete(request_uri)
|
|
210
210
|
_(response.success?).must_equal(true)
|
|
211
|
-
assert_requested(:
|
|
211
|
+
assert_requested(:delete, redirect_uri)
|
|
212
212
|
end
|
|
213
213
|
end
|
|
214
214
|
end
|
|
@@ -245,7 +245,7 @@ describe ".delete" do
|
|
|
245
245
|
it "returns the redirect response without following it" do
|
|
246
246
|
response = HTTP.delete(request_uri, {}, {}, {no_redirect: true})
|
|
247
247
|
_(response.redirection?).must_equal(true)
|
|
248
|
-
assert_not_requested(:
|
|
248
|
+
assert_not_requested(:delete, redirect_uri)
|
|
249
249
|
end
|
|
250
250
|
end
|
|
251
251
|
|
|
@@ -258,7 +258,7 @@ describe ".delete" do
|
|
|
258
258
|
it "returns the redirect response without following it" do
|
|
259
259
|
response = HTTP.delete(request_uri, {}, {}, {no_redirect: true})
|
|
260
260
|
_(response.redirection?).must_equal(true)
|
|
261
|
-
assert_not_requested(:
|
|
261
|
+
assert_not_requested(:delete, redirect_uri)
|
|
262
262
|
end
|
|
263
263
|
end
|
|
264
264
|
end
|
data/test/HTTP/head_test.rb
CHANGED
|
@@ -93,7 +93,7 @@ describe ".head" do
|
|
|
93
93
|
before do
|
|
94
94
|
stub_request(:head, request_uri).
|
|
95
95
|
to_return(status: 301, headers: {'location' => redirect_uri})
|
|
96
|
-
stub_request(:
|
|
96
|
+
stub_request(:head, redirect_uri).
|
|
97
97
|
to_return(status: 200, body: '', headers: {})
|
|
98
98
|
end
|
|
99
99
|
|
|
@@ -101,7 +101,7 @@ describe ".head" do
|
|
|
101
101
|
response = HTTP.head(request_uri)
|
|
102
102
|
_(response.success?).must_equal(true)
|
|
103
103
|
assert_requested(:head, request_uri)
|
|
104
|
-
assert_requested(:
|
|
104
|
+
assert_requested(:head, redirect_uri)
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
data/test/HTTP/options_test.rb
CHANGED
|
@@ -143,7 +143,7 @@ describe ".options" do
|
|
|
143
143
|
let(:redirect_uri){'http://redirected.com'}
|
|
144
144
|
|
|
145
145
|
before do
|
|
146
|
-
stub_request(:
|
|
146
|
+
stub_request(:options, redirect_uri).
|
|
147
147
|
to_return(status: 200, body: '', headers: {})
|
|
148
148
|
end
|
|
149
149
|
|
|
@@ -157,7 +157,7 @@ describe ".options" do
|
|
|
157
157
|
response = HTTP.options(request_uri)
|
|
158
158
|
_(response.success?).must_equal(true)
|
|
159
159
|
assert_requested(:options, request_uri)
|
|
160
|
-
assert_requested(:
|
|
160
|
+
assert_requested(:options, redirect_uri)
|
|
161
161
|
end
|
|
162
162
|
end
|
|
163
163
|
|
|
@@ -171,7 +171,7 @@ describe ".options" do
|
|
|
171
171
|
response = HTTP.options(request_uri)
|
|
172
172
|
_(response.success?).must_equal(true)
|
|
173
173
|
assert_requested(:options, request_uri)
|
|
174
|
-
assert_requested(:
|
|
174
|
+
assert_requested(:options, redirect_uri)
|
|
175
175
|
end
|
|
176
176
|
end
|
|
177
177
|
end
|
|
@@ -182,7 +182,7 @@ describe ".options" do
|
|
|
182
182
|
let(:redirect_uri){"http://example.com#{redirect_path}"}
|
|
183
183
|
|
|
184
184
|
before do
|
|
185
|
-
stub_request(:
|
|
185
|
+
stub_request(:options, redirect_uri).
|
|
186
186
|
to_return(status: 200, body: '', headers: {})
|
|
187
187
|
end
|
|
188
188
|
|
|
@@ -195,7 +195,7 @@ describe ".options" do
|
|
|
195
195
|
it "resolves the relative redirect against the original URI" do
|
|
196
196
|
response = HTTP.options(request_uri)
|
|
197
197
|
_(response.success?).must_equal(true)
|
|
198
|
-
assert_requested(:
|
|
198
|
+
assert_requested(:options, redirect_uri)
|
|
199
199
|
end
|
|
200
200
|
end
|
|
201
201
|
|
|
@@ -208,7 +208,7 @@ describe ".options" do
|
|
|
208
208
|
it "resolves the relative redirect against the original URI" do
|
|
209
209
|
response = HTTP.options(request_uri)
|
|
210
210
|
_(response.success?).must_equal(true)
|
|
211
|
-
assert_requested(:
|
|
211
|
+
assert_requested(:options, redirect_uri)
|
|
212
212
|
end
|
|
213
213
|
end
|
|
214
214
|
end
|
|
@@ -226,7 +226,7 @@ describe ".options" do
|
|
|
226
226
|
it "returns the redirect response without following it" do
|
|
227
227
|
response = HTTP.options(request_uri, {}, {}, {no_redirect: true})
|
|
228
228
|
_(response.redirection?).must_equal(true)
|
|
229
|
-
assert_not_requested(:
|
|
229
|
+
assert_not_requested(:options, redirect_uri)
|
|
230
230
|
end
|
|
231
231
|
end
|
|
232
232
|
|
|
@@ -239,7 +239,7 @@ describe ".options" do
|
|
|
239
239
|
it "returns the redirect response without following it" do
|
|
240
240
|
response = HTTP.options(request_uri, {}, {}, {no_redirect: true})
|
|
241
241
|
_(response.redirection?).must_equal(true)
|
|
242
|
-
assert_not_requested(:
|
|
242
|
+
assert_not_requested(:options, redirect_uri)
|
|
243
243
|
end
|
|
244
244
|
end
|
|
245
245
|
end
|
data/test/HTTP/patch_test.rb
CHANGED
|
@@ -286,7 +286,7 @@ describe ".patch" do
|
|
|
286
286
|
let(:redirect_uri){'http://redirected.com'}
|
|
287
287
|
|
|
288
288
|
before do
|
|
289
|
-
stub_request(:
|
|
289
|
+
stub_request(:patch, redirect_uri).
|
|
290
290
|
to_return(status: 200, body: '', headers: {})
|
|
291
291
|
end
|
|
292
292
|
|
|
@@ -296,11 +296,11 @@ describe ".patch" do
|
|
|
296
296
|
to_return(status: 301, headers: {'location' => redirect_uri})
|
|
297
297
|
end
|
|
298
298
|
|
|
299
|
-
it "follows the redirect with
|
|
299
|
+
it "follows the redirect with PATCH" do
|
|
300
300
|
response = HTTP.patch(request_uri)
|
|
301
301
|
_(response.success?).must_equal(true)
|
|
302
302
|
assert_requested(:patch, request_uri)
|
|
303
|
-
assert_requested(:
|
|
303
|
+
assert_requested(:patch, redirect_uri)
|
|
304
304
|
end
|
|
305
305
|
end
|
|
306
306
|
|
|
@@ -310,11 +310,11 @@ describe ".patch" do
|
|
|
310
310
|
to_return(status: 302, headers: {'location' => redirect_uri})
|
|
311
311
|
end
|
|
312
312
|
|
|
313
|
-
it "follows the redirect with
|
|
313
|
+
it "follows the redirect with PATCH" do
|
|
314
314
|
response = HTTP.patch(request_uri)
|
|
315
315
|
_(response.success?).must_equal(true)
|
|
316
316
|
assert_requested(:patch, request_uri)
|
|
317
|
-
assert_requested(:
|
|
317
|
+
assert_requested(:patch, redirect_uri)
|
|
318
318
|
end
|
|
319
319
|
end
|
|
320
320
|
end
|
|
@@ -325,7 +325,7 @@ describe ".patch" do
|
|
|
325
325
|
let(:redirect_uri){"http://example.com#{redirect_path}"}
|
|
326
326
|
|
|
327
327
|
before do
|
|
328
|
-
stub_request(:
|
|
328
|
+
stub_request(:patch, redirect_uri).
|
|
329
329
|
to_return(status: 200, body: '', headers: {})
|
|
330
330
|
end
|
|
331
331
|
|
|
@@ -338,7 +338,7 @@ describe ".patch" do
|
|
|
338
338
|
it "resolves the relative redirect against the original URI" do
|
|
339
339
|
response = HTTP.patch(request_uri)
|
|
340
340
|
_(response.success?).must_equal(true)
|
|
341
|
-
assert_requested(:
|
|
341
|
+
assert_requested(:patch, redirect_uri)
|
|
342
342
|
end
|
|
343
343
|
end
|
|
344
344
|
|
|
@@ -351,7 +351,7 @@ describe ".patch" do
|
|
|
351
351
|
it "resolves the relative redirect against the original URI" do
|
|
352
352
|
response = HTTP.patch(request_uri)
|
|
353
353
|
_(response.success?).must_equal(true)
|
|
354
|
-
assert_requested(:
|
|
354
|
+
assert_requested(:patch, redirect_uri)
|
|
355
355
|
end
|
|
356
356
|
end
|
|
357
357
|
end
|
|
@@ -388,7 +388,7 @@ describe ".patch" do
|
|
|
388
388
|
it "returns the redirect response without following it" do
|
|
389
389
|
response = HTTP.patch(request_uri, {}, {}, {no_redirect: true})
|
|
390
390
|
_(response.redirection?).must_equal(true)
|
|
391
|
-
assert_not_requested(:
|
|
391
|
+
assert_not_requested(:patch, redirect_uri)
|
|
392
392
|
end
|
|
393
393
|
end
|
|
394
394
|
|
|
@@ -401,7 +401,7 @@ describe ".patch" do
|
|
|
401
401
|
it "returns the redirect response without following it" do
|
|
402
402
|
response = HTTP.patch(request_uri, {}, {}, {no_redirect: true})
|
|
403
403
|
_(response.redirection?).must_equal(true)
|
|
404
|
-
assert_not_requested(:
|
|
404
|
+
assert_not_requested(:patch, redirect_uri)
|
|
405
405
|
end
|
|
406
406
|
end
|
|
407
407
|
end
|
data/test/HTTP/put_test.rb
CHANGED
|
@@ -286,7 +286,7 @@ describe ".put" do
|
|
|
286
286
|
let(:redirect_uri){'http://redirected.com'}
|
|
287
287
|
|
|
288
288
|
before do
|
|
289
|
-
stub_request(:
|
|
289
|
+
stub_request(:put, redirect_uri).
|
|
290
290
|
to_return(status: 200, body: '', headers: {})
|
|
291
291
|
end
|
|
292
292
|
|
|
@@ -296,11 +296,11 @@ describe ".put" do
|
|
|
296
296
|
to_return(status: 301, headers: {'location' => redirect_uri})
|
|
297
297
|
end
|
|
298
298
|
|
|
299
|
-
it "follows the redirect with
|
|
299
|
+
it "follows the redirect with PUT" do
|
|
300
300
|
response = HTTP.put(request_uri)
|
|
301
301
|
_(response.success?).must_equal(true)
|
|
302
302
|
assert_requested(:put, request_uri)
|
|
303
|
-
assert_requested(:
|
|
303
|
+
assert_requested(:put, redirect_uri)
|
|
304
304
|
end
|
|
305
305
|
end
|
|
306
306
|
|
|
@@ -310,11 +310,11 @@ describe ".put" do
|
|
|
310
310
|
to_return(status: 302, headers: {'location' => redirect_uri})
|
|
311
311
|
end
|
|
312
312
|
|
|
313
|
-
it "follows the redirect with
|
|
313
|
+
it "follows the redirect with PUT" do
|
|
314
314
|
response = HTTP.put(request_uri)
|
|
315
315
|
_(response.success?).must_equal(true)
|
|
316
316
|
assert_requested(:put, request_uri)
|
|
317
|
-
assert_requested(:
|
|
317
|
+
assert_requested(:put, redirect_uri)
|
|
318
318
|
end
|
|
319
319
|
end
|
|
320
320
|
end
|
|
@@ -325,7 +325,7 @@ describe ".put" do
|
|
|
325
325
|
let(:redirect_uri){"http://example.com#{redirect_path}"}
|
|
326
326
|
|
|
327
327
|
before do
|
|
328
|
-
stub_request(:
|
|
328
|
+
stub_request(:put, redirect_uri).
|
|
329
329
|
to_return(status: 200, body: '', headers: {})
|
|
330
330
|
end
|
|
331
331
|
|
|
@@ -338,7 +338,7 @@ describe ".put" do
|
|
|
338
338
|
it "resolves the relative redirect against the original URI" do
|
|
339
339
|
response = HTTP.put(request_uri)
|
|
340
340
|
_(response.success?).must_equal(true)
|
|
341
|
-
assert_requested(:
|
|
341
|
+
assert_requested(:put, redirect_uri)
|
|
342
342
|
end
|
|
343
343
|
end
|
|
344
344
|
|
|
@@ -351,7 +351,7 @@ describe ".put" do
|
|
|
351
351
|
it "resolves the relative redirect against the original URI" do
|
|
352
352
|
response = HTTP.put(request_uri)
|
|
353
353
|
_(response.success?).must_equal(true)
|
|
354
|
-
assert_requested(:
|
|
354
|
+
assert_requested(:put, redirect_uri)
|
|
355
355
|
end
|
|
356
356
|
end
|
|
357
357
|
end
|
|
@@ -388,7 +388,7 @@ describe ".put" do
|
|
|
388
388
|
it "returns the redirect response without following it" do
|
|
389
389
|
response = HTTP.put(request_uri, {}, {}, {no_redirect: true})
|
|
390
390
|
_(response.redirection?).must_equal(true)
|
|
391
|
-
assert_not_requested(:
|
|
391
|
+
assert_not_requested(:put, redirect_uri)
|
|
392
392
|
end
|
|
393
393
|
end
|
|
394
394
|
|
|
@@ -401,7 +401,7 @@ describe ".put" do
|
|
|
401
401
|
it "returns the redirect response without following it" do
|
|
402
402
|
response = HTTP.put(request_uri, {}, {}, {no_redirect: true})
|
|
403
403
|
_(response.redirection?).must_equal(true)
|
|
404
|
-
assert_not_requested(:
|
|
404
|
+
assert_not_requested(:put, redirect_uri)
|
|
405
405
|
end
|
|
406
406
|
end
|
|
407
407
|
end
|
data/test/HTTP/trace_test.rb
CHANGED
|
@@ -143,7 +143,7 @@ describe ".trace" do
|
|
|
143
143
|
let(:redirect_uri){'http://redirected.com'}
|
|
144
144
|
|
|
145
145
|
before do
|
|
146
|
-
stub_request(:
|
|
146
|
+
stub_request(:trace, redirect_uri).
|
|
147
147
|
to_return(status: 200, body: '', headers: {})
|
|
148
148
|
end
|
|
149
149
|
|
|
@@ -157,7 +157,7 @@ describe ".trace" do
|
|
|
157
157
|
response = HTTP.trace(request_uri)
|
|
158
158
|
_(response.success?).must_equal(true)
|
|
159
159
|
assert_requested(:trace, request_uri)
|
|
160
|
-
assert_requested(:
|
|
160
|
+
assert_requested(:trace, redirect_uri)
|
|
161
161
|
end
|
|
162
162
|
end
|
|
163
163
|
|
|
@@ -171,7 +171,7 @@ describe ".trace" do
|
|
|
171
171
|
response = HTTP.trace(request_uri)
|
|
172
172
|
_(response.success?).must_equal(true)
|
|
173
173
|
assert_requested(:trace, request_uri)
|
|
174
|
-
assert_requested(:
|
|
174
|
+
assert_requested(:trace, redirect_uri)
|
|
175
175
|
end
|
|
176
176
|
end
|
|
177
177
|
end
|
|
@@ -182,7 +182,7 @@ describe ".trace" do
|
|
|
182
182
|
let(:redirect_uri){"http://example.com#{redirect_path}"}
|
|
183
183
|
|
|
184
184
|
before do
|
|
185
|
-
stub_request(:
|
|
185
|
+
stub_request(:trace, redirect_uri).
|
|
186
186
|
to_return(status: 200, body: '', headers: {})
|
|
187
187
|
end
|
|
188
188
|
|
|
@@ -195,7 +195,7 @@ describe ".trace" do
|
|
|
195
195
|
it "resolves the relative redirect against the original URI" do
|
|
196
196
|
response = HTTP.trace(request_uri)
|
|
197
197
|
_(response.success?).must_equal(true)
|
|
198
|
-
assert_requested(:
|
|
198
|
+
assert_requested(:trace, redirect_uri)
|
|
199
199
|
end
|
|
200
200
|
end
|
|
201
201
|
|
|
@@ -208,7 +208,7 @@ describe ".trace" do
|
|
|
208
208
|
it "resolves the relative redirect against the original URI" do
|
|
209
209
|
response = HTTP.trace(request_uri)
|
|
210
210
|
_(response.success?).must_equal(true)
|
|
211
|
-
assert_requested(:
|
|
211
|
+
assert_requested(:trace, redirect_uri)
|
|
212
212
|
end
|
|
213
213
|
end
|
|
214
214
|
end
|
|
@@ -226,7 +226,7 @@ describe ".trace" do
|
|
|
226
226
|
it "returns the redirect response without following it" do
|
|
227
227
|
response = HTTP.trace(request_uri, {}, {}, {no_redirect: true})
|
|
228
228
|
_(response.redirection?).must_equal(true)
|
|
229
|
-
assert_not_requested(:
|
|
229
|
+
assert_not_requested(:trace, redirect_uri)
|
|
230
230
|
end
|
|
231
231
|
end
|
|
232
232
|
|
|
@@ -239,7 +239,7 @@ describe ".trace" do
|
|
|
239
239
|
it "returns the redirect response without following it" do
|
|
240
240
|
response = HTTP.trace(request_uri, {}, {}, {no_redirect: true})
|
|
241
241
|
_(response.redirection?).must_equal(true)
|
|
242
|
-
assert_not_requested(:
|
|
242
|
+
assert_not_requested(:trace, redirect_uri)
|
|
243
243
|
end
|
|
244
244
|
end
|
|
245
245
|
end
|