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.
This commit is contained in:
Zhanwei Wang 2020-04-11 01:17:55 +08:00 committed by GitHub
parent 25650cb592
commit 1097694355
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 2 deletions

View file

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

View file

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

View file

@ -415,7 +415,7 @@ def test_Request_open_last_mod(urlopen_mock, install_opener_mock):
args = urlopen_mock.call_args[0] args = urlopen_mock.call_args[0]
req = 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): def test_Request_open_headers_not_dict(urlopen_mock, install_opener_mock):