summaryrefslogtreecommitdiffstats
path: root/Lib/urllib.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/urllib.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/urllib.py')
-rw-r--r--Lib/urllib.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index a255956..8c1852e 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -406,18 +406,12 @@ class URLopener:
def open_local_file(self, url):
"""Use local file."""
- import mimetypes, mimetools, StringIO
+ import mimetypes, mimetools, rfc822, StringIO
host, file = splithost(url)
localname = url2pathname(file)
stats = os.stat(localname)
size = stats[stat.ST_SIZE]
- modified = time.gmtime(stats[stat.ST_MTIME])
- modified = "%s, %02d %s %04d %02d:%02d:%02d GMT" % (
- ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][modified[6]],
- modified[2],
- ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][modified[1]-1],
- modified[0], modified[3], modified[4], modified[5])
+ modified = rfc822.formatdate(stats[stat.ST_MTIME])
mtype = mimetypes.guess_type(url)[0]
headers = mimetools.Message(StringIO.StringIO(
'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %