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

Changeset 1209

Show
Ignore:
Timestamp:
08/03/06 00:05:01
Author:
fumanchu
Message:

Fixes for #544 and #545 (serveFile issues) in CP 3. Fixes in CP 2 branch coming in a separate changeset.

Files:

Legend:

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

    r1203 r1209  
    112112            # The "Date" header should have been set in Request.__init__ 
    113113             
     114            # "...the response SHOULD NOT include other entity-headers. 
     115            for key in ('Allow', 'Content-Encoding', 'Content-Language', 
     116                        'Content-Length', 'Content-Location', 'Content-MD5', 
     117                        'Content-Range', 'Content-Type', 'Expires', 
     118                        'Last-Modified'): 
     119                if key in response.headers: 
     120                    del response.headers[key] 
     121             
    114122            # "The 304 response MUST NOT contain a message-body." 
    115123            response.body = None 
  • trunk/cherrypy/_cprequest.py

    r1203 r1209  
    685685            # Responses which are not streamed should have a Content-Length, 
    686686            # but allow user code to set Content-Length if desired. 
    687             if dict.get(headers, 'Content-Length') is None: 
     687            if (dict.get(headers, 'Content-Length') is None 
     688                and code not in (304,)): 
    688689                content = self.collapse_body() 
    689690                dict.__setitem__(headers, 'Content-Length', len(content)) 
  • trunk/cherrypy/lib/static.py

    r1164 r1209  
    4747        raise cherrypy.NotFound() 
    4848     
     49    # Set the Last-Modified response header, so that 
     50    # modified-since validation code can work. 
     51    response.headers['Last-Modified'] = http.HTTPDate(stat.st_mtime) 
     52    cptools.validate_since() 
     53     
    4954    if contentType is None: 
    5055        # Set content-type based on filename extension 
     
    5661    response.headers['Content-Type'] = contentType 
    5762     
    58     # Set the Last-Modified response header, so that 
    59     # modified-since validation code can work. 
    60     response.headers['Last-Modified'] = http.HTTPDate(stat.st_mtime) 
    61     cptools.validate_since() 
    62      
    6363    if disposition is not None: 
    6464        if name is None: 
    6565            name = os.path.basename(path) 
    66         cd = "%s; filename=%s" % (disposition, name) 
     66        cd = '%s; filename="%s"' % (disposition, name) 
    6767        response.headers["Content-Disposition"] = cd 
    6868     
  • trunk/cherrypy/test/test_static.py

    r1154 r1209  
    128128        self.getPage("/static/dirback.jpg", headers=[ims]) 
    129129        self.assertStatus(304) 
     130        self.assertNoHeader("Content-Type") 
     131        self.assertNoHeader("Content-Length") 
     132        self.assertNoHeader("Content-Disposition") 
     133        self.assertBody("") 
    130134 
    131135 
  • trunk/cherrypy/test/test_tutorials.py

    r1114 r1209  
    164164        self.assertStatus("200 OK") 
    165165        self.assertHeader("Content-Type", "application/x-download") 
    166         self.assertHeader("Content-Disposition", "attachment; filename=pdf_file.pdf") 
     166        self.assertHeader("Content-Disposition", 
     167                          # Make sure the filename is quoted. 
     168                          'attachment; filename="pdf_file.pdf"') 
    167169        self.assertEqual(len(self.body), 85698) 
    168170     

Hosted by WebFaction

Log in as guest/cpguest to create tickets