Changeset 1164
- Timestamp:
- 06/27/06 13:01:08
- Files:
-
- trunk/cherrypy/__init__.py (modified) (1 diff)
- trunk/cherrypy/_cpwsgiserver.py (modified) (2 diffs)
- trunk/cherrypy/lib/http.py (modified) (2 diffs)
- trunk/cherrypy/lib/static.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/__init__.py
r1156 r1164 88 88 import datetime 89 89 now = datetime.datetime.now() 90 from cherrypy.lib import http91 month = http.monthname[now.month][:3].capitalize()90 import rfc822 91 month = rfc822._monthnames[now.month - 1].capitalize() 92 92 return '%02d/%s/%04d:%02d:%02d:%02d' % ( 93 93 now.day, month, now.year, now.hour, now.minute, now.second) trunk/cherrypy/_cpwsgiserver.py
r1119 r1164 8 8 import time 9 9 import traceback 10 11 weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']12 monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',13 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']14 10 15 11 import errno … … 152 148 self.close_at_end = True 153 149 if "date" not in self.outheaderkeys: 154 # HTTP 1.1 mandates date output in RFC 1123 format. 155 year, month, day, hh, mm, ss, wd, y, z = time.gmtime() 156 dt = ("%s, %02d %3s %4d %02d:%02d:%02d GMT" % 157 (weekdayname[wd], day, monthname[month], year, hh, mm, ss)) 158 self.outheaders.append(("Date", dt)) 150 self.outheaders.append(("Date", rfc822.formatdate())) 159 151 if "server" not in self.outheaderkeys: 160 152 self.outheaders.append(("Server", self.server.version)) trunk/cherrypy/lib/http.py
r1141 r1164 22 22 import cgi 23 23 import re 24 import rfc822 25 HTTPDate = rfc822.formatdate 24 26 import time 25 27 from urllib import unquote … … 32 34 url = url.replace("//", "/") 33 35 return url 34 35 36 weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']37 monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',38 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']39 40 def HTTPDate(dt=None):41 """Return the given time.struct_time as a string in RFC 1123 format.42 43 If no arguments are provided, the current time (as determined by44 time.gmtime() is used).45 46 RFC 2616: "[Concerning RFC 1123, RFC 850, asctime date formats]...47 HTTP/1.1 clients and servers that parse the date value MUST48 accept all three formats (for compatibility with HTTP/1.0),49 though they MUST only generate the RFC 1123 format for50 representing HTTP-date values in header fields."51 52 RFC 1945 (HTTP/1.0) requires the same.53 54 """55 56 if dt is None:57 dt = time.gmtime()58 59 year, month, day, hh, mm, ss, wd, y, z = dt60 # Is "%a, %d %b %Y %H:%M:%S GMT" better or worse?61 return ("%s, %02d %3s %4d %02d:%02d:%02d GMT" %62 (weekdayname[wd], day, monthname[month], year, hh, mm, ss))63 64 36 65 37 def version_from_http(version_str): trunk/cherrypy/lib/static.py
r1145 r1164 58 58 # Set the Last-Modified response header, so that 59 59 # modified-since validation code can work. 60 response.headers['Last-Modified'] = http.HTTPDate( time.gmtime(stat.st_mtime))60 response.headers['Last-Modified'] = http.HTTPDate(stat.st_mtime) 61 61 cptools.validate_since() 62 62

