Added a usegmt flag to email.Utils.formatdate - this allows it to be

used to replace rfc822.formatdate for protocols like HTTP (where 'GMT' must
be the timezone string).
This commit is contained in:
Anthony Baxter 2004-10-11 13:53:08 +00:00
parent 7f468f29f4
commit 3dd9e46161
5 changed files with 28 additions and 7 deletions

View file

@ -410,7 +410,7 @@ class URLopener:
def open_local_file(self, url):
"""Use local file."""
import mimetypes, mimetools, rfc822, StringIO
import mimetypes, mimetools, email.Utils, StringIO
host, file = splithost(url)
localname = url2pathname(file)
try:
@ -418,7 +418,7 @@ class URLopener:
except OSError, e:
raise IOError(e.errno, e.strerror, e.filename)
size = stats.st_size
modified = rfc822.formatdate(stats.st_mtime)
modified = email.Utils.formatdate(stats.st_mtime, usegmt=True)
mtype = mimetypes.guess_type(url)[0]
headers = mimetools.Message(StringIO.StringIO(
'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %