From a867d23383a081604b873bf4ff75d1a2e3a0ff1e Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Sat, 2 Apr 2016 20:32:33 +0000 Subject: [PATCH] ensure streaming mode (use for example by file.managed) will works for requests backend --- salt/utils/http.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/salt/utils/http.py b/salt/utils/http.py index a3c127ba1f..db90041a5c 100644 --- a/salt/utils/http.py +++ b/salt/utils/http.py @@ -299,7 +299,16 @@ def query(url, method, url, params=params, data=data, **req_kwargs ) result.raise_for_status() - if stream is True or handle is True: + if stream is True: + # fake a HTTP response header + header_callback('HTTP/1.0 {0} MESSAGE'.format(result.status_code)) + # fake streaming the content + streaming_callback(result.content) + return { + 'handle': result, + } + + if handle is True: return { 'handle': result, 'body': result.content,