mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Fix fileclient's get_url when redirecting to a redirect
When a 30x leads to a 200 OK, we properly reset write_body[0] so that we save the body of the response. However, when both A) a 30x redirects to another 30x and B) we've already determined the encoding from the Content-Type (and thus set write_body[2]), then we don't properly set write_body[0], resulting in a zero-length file. This commit fixes this by also resetting the write_body[2] when following redirects, so that we make sure we are getting the encoding for the request to the URL that resulted in the 200 instead of the one that resulted in the 30x.
This commit is contained in:
parent
a8f1750323
commit
9a4f6a260f
@ -623,10 +623,11 @@ class Client(object):
|
|||||||
if write_body[1] is not False and write_body[2] is None:
|
if write_body[1] is not False and write_body[2] is None:
|
||||||
if not hdr.strip() and 'Content-Type' not in write_body[1]:
|
if not hdr.strip() and 'Content-Type' not in write_body[1]:
|
||||||
# We've reached the end of the headers and not yet
|
# We've reached the end of the headers and not yet
|
||||||
# found the Content-Type. Reset the values we're
|
# found the Content-Type. Reset write_body[0] so that
|
||||||
# tracking so that we properly follow the redirect.
|
# we properly follow the redirect. Note that slicing is
|
||||||
write_body[0] = None
|
# used below to ensure that we re-use the same list
|
||||||
write_body[1] = False
|
# rather than creating a new one.
|
||||||
|
write_body[0:2] = (None, False)
|
||||||
return
|
return
|
||||||
# Try to find out what content type encoding is used if
|
# Try to find out what content type encoding is used if
|
||||||
# this is a text file
|
# this is a text file
|
||||||
@ -648,9 +649,12 @@ class Client(object):
|
|||||||
# If write_body[0] is False, this means that this
|
# If write_body[0] is False, this means that this
|
||||||
# header is a 30x redirect, so we need to reset
|
# header is a 30x redirect, so we need to reset
|
||||||
# write_body[0] to None so that we parse the HTTP
|
# write_body[0] to None so that we parse the HTTP
|
||||||
# status code from the redirect target.
|
# status code from the redirect target. Additionally,
|
||||||
|
# we need to reset write_body[2] so that we inspect the
|
||||||
|
# headers for the Content-Type of the URL we're
|
||||||
|
# following.
|
||||||
if write_body[0] is write_body[1] is False:
|
if write_body[0] is write_body[1] is False:
|
||||||
write_body[0] = None
|
write_body[0] = write_body[2] = None
|
||||||
|
|
||||||
# Check the status line of the HTTP request
|
# Check the status line of the HTTP request
|
||||||
if write_body[0] is None:
|
if write_body[0] is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user