33__docformat__ = 'restructuredtext'
44
55import base64 , binascii , cgi , codecs , mimetypes , os
6- import quopri , random , re , rfc822 , stat , sys , time
6+ import quopri , random , re , stat , sys , time
77import socket , errno
8+ import email .utils
89from traceback import format_exc
910
1011try :
@@ -495,7 +496,8 @@ def inner_main(self):
495496 # date = time.time() - 1
496497 #else:
497498 # date = time.time() + 5
498- self .additional_headers ['Expires' ] = rfc822 .formatdate (date )
499+ self .additional_headers ['Expires' ] = \
500+ email .utils .formatdate (date , usegmt = True )
499501
500502 # render the content
501503 self .write_html (self .renderContext ())
@@ -1074,7 +1076,7 @@ def _serve_file(self, lmt, mime_type, content=None, filename=None):
10741076
10751077 # spit out headers
10761078 self .additional_headers ['Content-Type' ] = mime_type
1077- self .additional_headers ['Last-Modified' ] = rfc822 .formatdate (lmt )
1079+ self .additional_headers ['Last-Modified' ] = email . utils .formatdate (lmt )
10781080
10791081 ims = None
10801082 # see if there's an if-modified-since...
@@ -1085,7 +1087,7 @@ def _serve_file(self, lmt, mime_type, content=None, filename=None):
10851087 # cgi will put the header in the env var
10861088 ims = self .env ['HTTP_IF_MODIFIED_SINCE' ]
10871089 if ims :
1088- ims = rfc822 .parsedate (ims )[:6 ]
1090+ ims = email . utils .parsedate (ims )[:6 ]
10891091 lmtt = time .gmtime (lmt )[:6 ]
10901092 if lmtt <= ims :
10911093 raise NotModified
0 commit comments