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

Changeset 1089

Show
Ignore:
Timestamp:
05/02/06 18:04:53
Author:
fumanchu
Message:

Fix for #508 (Content-Type for 304s).

Files:

Legend:

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

    r1082 r1089  
    102102        response = cherrypy.response 
    103103        response.status = status = self.status 
    104         response.headers['Content-Type'] = "text/html" 
    105104         
    106105        if status in (300, 301, 302, 303, 307): 
     106            response.headers['Content-Type'] = "text/html" 
    107107            # "The ... URI SHOULD be given by the Location field 
    108108            # in the response." 
  • trunk/cherrypy/lib/caching.py

    r1083 r1089  
    105105    if c: 
    106106        expirationTime, lastModified, obj = cacheData 
     107        s, h, b = obj 
    107108        modifiedSince = cherrypy.request.headers.get('If-Modified-Since', None) 
    108109        if modifiedSince is not None and modifiedSince == lastModified: 
    109110            cherrypy._cache.totNonModified += 1 
    110111            cherrypy.response.status = "304 Not Modified" 
     112            ct = h.get("Content-Type") 
     113            if ct: 
     114                cherrypy.response.header_list["Content-Type"] = ct 
    111115            cherrypy.response.body = None 
    112116        else: 
    113117            # serve it & get out from the request 
    114             cherrypy.response.status, cherrypy.response.header_list, body = obj 
     118            cherrypy.response.status, cherrypy.response.header_list, body = s, h, b 
    115119            cherrypy.response.body = body 
    116120    return c 
  • trunk/cherrypy/lib/static.py

    r1084 r1089  
    3434    if cherrypy.request.headers.has_key('If-Modified-Since'): 
    3535        if cherrypy.request.headers['If-Modified-Since'] == strModifTime: 
    36             response.status = "304 Not Modified" 
    37             response.body = None 
    38             if getattr(cherrypy, "debug", None): 
    39                 cherrypy.log("    Found file (304 Not Modified): %s" % path, "DEBUG") 
    4036            return False 
    4137    response.headers['Last-Modified'] = strModifTime 
     
    8682     
    8783    if not modified_since(path, stat): 
     84        response.status = "304 Not Modified" 
    8885        response.body = [] 
     86        if getattr(cherrypy, "debug", None): 
     87            cherrypy.log("    Found file (304 Not Modified): %s" % path, "DEBUG") 
    8988        return [] 
    9089     

Hosted by WebFaction

Log in as guest/cpguest to create tickets