get_url pass incorrect If-Modified-Since header(#67417) (#67419)

Fix #67417. HTTP header value of `If-Modified-Since` set by `get_url` does not follow HTTP protocol.

(cherry picked from commit 1097694355)
pull/68620/merge
Zhanwei Wang 5 years ago committed by Matt Clay
parent bf3cd041e7
commit f7c63c1201

@ -0,0 +1,2 @@
bugfixes:
- get_url pass incorrect If-Modified-Since header (https://github.com/ansible/ansible/issues/67417)

@ -1274,7 +1274,7 @@ class Request:
request.add_header('cache-control', 'no-cache')
# or we do it if the original is more recent than our copy
elif last_mod_time:
tstamp = rfc2822_date_string(last_mod_time.timetuple())
tstamp = rfc2822_date_string(last_mod_time.timetuple(), 'GMT')
request.add_header('If-Modified-Since', tstamp)
# user defined headers now, which may override things we've set above

@ -415,7 +415,7 @@ def test_Request_open_last_mod(urlopen_mock, install_opener_mock):
args = urlopen_mock.call_args[0]
req = args[0]
assert req.headers.get('If-modified-since') == now.strftime('%a, %d %b %Y %H:%M:%S -0000')
assert req.headers.get('If-modified-since') == now.strftime('%a, %d %b %Y %H:%M:%S GMT')
def test_Request_open_headers_not_dict(urlopen_mock, install_opener_mock):

Loading…
Cancel
Save