mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Remove streamed response for fileclient to avoid HTTP redirection problems
By using the stream response the client was concatenating all bodies in the redirect path. This means if you have a URL which redirects to a second one the resulting string (previously) was both put together. To fix this we either need to stop streaming, or don't automatically follow redirects. Since we aren't doing any actual processing or writing to disk with the streaming I've removed it for now-- to fix the regression.
This commit is contained in:
parent
a6ecf35f25
commit
acf2d51440
1 changed files with 4 additions and 17 deletions
|
@ -33,7 +33,6 @@ from salt.utils.openstack.swift import SaltSwift
|
|||
import salt.ext.six.moves.BaseHTTPServer as BaseHTTPServer
|
||||
from salt.ext.six.moves.urllib.error import HTTPError, URLError
|
||||
from salt.ext.six.moves.urllib.parse import urlparse, urlunparse
|
||||
from salt.ext.six.moves import range # pylint: disable=redefined-builtin
|
||||
# pylint: enable=no-name-in-module,import-error
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -598,22 +597,9 @@ class Client(object):
|
|||
|
||||
destfp = None
|
||||
try:
|
||||
if no_cache:
|
||||
result = []
|
||||
|
||||
def on_chunk(chunk):
|
||||
result.append(chunk)
|
||||
else:
|
||||
dest_tmp = "{0}.part".format(dest)
|
||||
destfp = salt.utils.fopen(dest_tmp, 'wb')
|
||||
|
||||
def on_chunk(chunk):
|
||||
destfp.write(chunk)
|
||||
|
||||
query = salt.utils.http.query(
|
||||
fixed_url,
|
||||
stream=True,
|
||||
streaming_callback=on_chunk,
|
||||
username=url_data.username,
|
||||
password=url_data.password,
|
||||
**get_kwargs
|
||||
|
@ -621,10 +607,11 @@ class Client(object):
|
|||
if 'handle' not in query:
|
||||
raise MinionError('Error: {0}'.format(query['error']))
|
||||
if no_cache:
|
||||
return ''.join(result)
|
||||
return query['handle'].body
|
||||
else:
|
||||
destfp.close()
|
||||
destfp = None
|
||||
dest_tmp = "{0}.part".format(dest)
|
||||
with salt.utils.fopen(dest_tmp, 'wb') as destfp:
|
||||
destfp.write(query['handle'].body)
|
||||
# Can't just do an os.rename() here, this results in a
|
||||
# WindowsError being raised when the destination path exists on
|
||||
# a Windows machine. Have to remove the file.
|
||||
|
|
Loading…
Add table
Reference in a new issue