diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py index 63e061a9afb..37cad422ed9 100644 --- a/Lib/test/test_urllibnet.py +++ b/Lib/test/test_urllibnet.py @@ -8,6 +8,7 @@ import urllib.request import sys import os import email.message +import time def _open_with_retry(func, host, *args, **kwargs): @@ -180,6 +181,16 @@ class urlretrieveNetworkTests(unittest.TestCase): self.assertTrue(isinstance(header, email.message.Message), "header is not an instance of email.message.Message") + def test_data_header(self): + logo = "http://www.python.org/community/logos/python-logo-master-v3-TM.png" + file_location, fileheaders = self.urlretrieve(logo) + os.unlink(file_location) + datevalue = fileheaders.get('Date') + dateformat = '%a, %d %b %Y %H:%M:%S GMT' + try: + time.strptime(datevalue, dateformat) + except ValueError: + self.fail('Date value not in %r format', dateformat) def test_main(): diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 0f9e2f81914..002e3261f71 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1781,7 +1781,7 @@ class URLopener: else: encoding = '' msg = [] - msg.append('Date: %s'%time.strftime('%a, %d %b %Y %T GMT', + msg.append('Date: %s'%time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(time.time()))) msg.append('Content-type: %s' % type) if encoding == 'base64':