summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-05-01 08:29:18 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-05-01 08:29:18 (GMT)
commitf6c456d32308158f3f68c3de838f3b4666fe15da (patch)
tree158019bf1450111fa71d571f7dc75088f41ef0ac
parent043bad00bcab7f3806e776f9402c776963536495 (diff)
downloadcpython-f6c456d32308158f3f68c3de838f3b4666fe15da.zip
cpython-f6c456d32308158f3f68c3de838f3b4666fe15da.tar.gz
cpython-f6c456d32308158f3f68c3de838f3b4666fe15da.tar.bz2
Merged revisions 80675 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80675 | senthil.kumaran | 2010-05-01 13:31:56 +0530 (Sat, 01 May 2010) | 3 lines Fix issue8582: urllib.urlretrieve fails with ValueError: Invalid format string ........
-rw-r--r--Lib/test/test_urllibnet.py11
-rw-r--r--Lib/urllib/request.py2
2 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index f324be9..c2388b8 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.assertIsInstance(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 ee819c3..ff871f9 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -1779,7 +1779,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':