mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
handle 305 redirects via proxy if the plugin is enabled
This commit is contained in:
parent
e740a38bad
commit
d39e7ba8d4
@ -86,10 +86,22 @@ module HTTPX
|
||||
redirect_uri = __get_location_from_response(response)
|
||||
max_redirects = request.max_redirects
|
||||
|
||||
# redirects are **ALWAYS** GET
|
||||
retry_options = options.merge(headers: request.headers,
|
||||
body: request.body,
|
||||
max_redirects: max_redirects - 1)
|
||||
if response.status == 305 && options.respond_to?(:proxy)
|
||||
# The requested resource MUST be accessed through the proxy given by
|
||||
# the Location field. The Location field gives the URI of the proxy.
|
||||
retry_options = options.merge(headers: request.headers,
|
||||
proxy: { uri: redirect_uri },
|
||||
body: request.body,
|
||||
max_redirects: max_redirects - 1)
|
||||
redirect_uri = request.url
|
||||
else
|
||||
|
||||
# redirects are **ALWAYS** GET
|
||||
retry_options = options.merge(headers: request.headers,
|
||||
body: request.body,
|
||||
max_redirects: max_redirects - 1)
|
||||
end
|
||||
|
||||
build_request(:get, redirect_uri, retry_options)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user