diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-25 19:00:31 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-25 19:00:31 (GMT) |
commit | fce59bf72af67b71fdb70bf8e03ec70c1be89387 (patch) | |
tree | e76586e298c7d11a69286045a3ff9f425c07922e /Lib/urllib2.py | |
parent | 0337ef62faec55c3b19b24725940e4eba2b8ab68 (diff) | |
download | cpython-fce59bf72af67b71fdb70bf8e03ec70c1be89387.zip cpython-fce59bf72af67b71fdb70bf8e03ec70c1be89387.tar.gz cpython-fce59bf72af67b71fdb70bf8e03ec70c1be89387.tar.bz2 |
Get the urllib tests to pass without the email package
Diffstat (limited to 'Lib/urllib2.py')
-rw-r--r-- | Lib/urllib2.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py index 448f2a8..658bc3d 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -1201,7 +1201,7 @@ class FileHandler(BaseHandler): # not entirely sure what the rules are here def open_local_file(self, req): - import email.utils + #import email.utils import mimetypes host = req.get_host() file = req.get_selector() @@ -1209,7 +1209,17 @@ class FileHandler(BaseHandler): try: stats = os.stat(localfile) size = stats.st_size - modified = email.utils.formatdate(stats.st_mtime, usegmt=True) + #modified = email.utils.formatdate(stats.st_mtime, usegmt=True) + # XXX(nnorwitz): inline formatdate until it is restored. + now, zone = time.gmtime(stats.st_mtime), 'GMT' + modified = '%s, %02d %s %04d %02d:%02d:%02d %s' % ( + ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][now[6]], + now[2], + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][now[1] - 1], + now[0], now[3], now[4], now[5], + zone) + mtype = mimetypes.guess_type(file)[0] headers = mimetools.Message(StringIO( 'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' % |