Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1164

Show
Ignore:
Timestamp:
06/27/06 13:01:08
Author:
fumanchu
Message:

Replaced http.HTTPDate with its clone rfc822.formatdate.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/__init__.py

    r1156 r1164  
    8888    import datetime 
    8989    now = datetime.datetime.now() 
    90     from cherrypy.lib import http 
    91     month = http.monthname[now.month][:3].capitalize() 
     90    import rfc822 
     91    month = rfc822._monthnames[now.month - 1].capitalize() 
    9292    return '%02d/%s/%04d:%02d:%02d:%02d' % ( 
    9393        now.day, month, now.year, now.hour, now.minute, now.second) 
  • trunk/cherrypy/_cpwsgiserver.py

    r1119 r1164  
    88import time 
    99import 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'] 
    1410 
    1511import errno 
     
    152148            self.close_at_end = True 
    153149        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())) 
    159151        if "server" not in self.outheaderkeys: 
    160152            self.outheaders.append(("Server", self.server.version)) 
  • trunk/cherrypy/lib/http.py

    r1141 r1164  
    2222import cgi 
    2323import re 
     24import rfc822 
     25HTTPDate = rfc822.formatdate 
    2426import time 
    2527from urllib import unquote 
     
    3234        url = url.replace("//", "/") 
    3335    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 by 
    44     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 MUST 
    48     accept all three formats (for compatibility with HTTP/1.0), 
    49     though they MUST only generate the RFC 1123 format for 
    50     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 = dt 
    60     # 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  
    6436 
    6537def version_from_http(version_str): 
  • trunk/cherrypy/lib/static.py

    r1145 r1164  
    5858    # Set the Last-Modified response header, so that 
    5959    # 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
    6161    cptools.validate_since() 
    6262     

Hosted by WebFaction

Log in as guest/cpguest to create tickets