summaryrefslogtreecommitdiffstats
path: root/Lib/rfc822.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-08-27 20:16:53 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-08-27 20:16:53 (GMT)
commit6d8c1aabff765d4958132f750a968769e7cece13 (patch)
tree617d67c72baf597fea0176a99972bc309a7e195c /Lib/rfc822.py
parent53da3178011d5eaf143d6d9d76274a7530204179 (diff)
downloadcpython-6d8c1aabff765d4958132f750a968769e7cece13.zip
cpython-6d8c1aabff765d4958132f750a968769e7cece13.tar.gz
cpython-6d8c1aabff765d4958132f750a968769e7cece13.tar.bz2
Add content-type header to ftp URLs (SF patch #454553)
Modify rfc822.formatdate() to always generate English names, regardless of locale. This is required by RFC 1123. In open_local_file() of urllib and urllib2, use new formatdate() from rfc822.
Diffstat (limited to 'Lib/rfc822.py')
-rw-r--r--Lib/rfc822.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/rfc822.py b/Lib/rfc822.py
index c2249f3..e69c4cb 100644
--- a/Lib/rfc822.py
+++ b/Lib/rfc822.py
@@ -953,11 +953,21 @@ def formatdate(timeval=None):
"""Returns time format preferred for Internet standards.
Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
+
+ According to RFC 1123, day and month names must always be in
+ English. If not for that, this code could use strftime(). It
+ can't because strftime() honors the locale and could generated
+ non-English names.
"""
if timeval is None:
timeval = time.time()
- return "%s" % time.strftime('%a, %d %b %Y %H:%M:%S GMT',
- time.gmtime(timeval))
+ timeval = time.gmtime(timeval)
+ return "%s, %02d %s %04d %02d:%02d:%02d GMT" % (
+ ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][timeval[6]],
+ timeval[2],
+ ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][timeval[1]-1],
+ timeval[0], timeval[3], timeval[4], timeval[5])
# When used as script, run a small test program.