Changeset 1209
- Timestamp:
- 08/03/06 00:05:01
- Files:
-
- trunk/cherrypy/_cperror.py (modified) (1 diff)
- trunk/cherrypy/_cprequest.py (modified) (1 diff)
- trunk/cherrypy/lib/static.py (modified) (2 diffs)
- trunk/cherrypy/test/test_static.py (modified) (1 diff)
- trunk/cherrypy/test/test_tutorials.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cperror.py
r1203 r1209 112 112 # The "Date" header should have been set in Request.__init__ 113 113 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 114 122 # "The 304 response MUST NOT contain a message-body." 115 123 response.body = None trunk/cherrypy/_cprequest.py
r1203 r1209 685 685 # Responses which are not streamed should have a Content-Length, 686 686 # 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,)): 688 689 content = self.collapse_body() 689 690 dict.__setitem__(headers, 'Content-Length', len(content)) trunk/cherrypy/lib/static.py
r1164 r1209 47 47 raise cherrypy.NotFound() 48 48 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 49 54 if contentType is None: 50 55 # Set content-type based on filename extension … … 56 61 response.headers['Content-Type'] = contentType 57 62 58 # Set the Last-Modified response header, so that59 # modified-since validation code can work.60 response.headers['Last-Modified'] = http.HTTPDate(stat.st_mtime)61 cptools.validate_since()62 63 63 if disposition is not None: 64 64 if name is None: 65 65 name = os.path.basename(path) 66 cd = "%s; filename=%s"% (disposition, name)66 cd = '%s; filename="%s"' % (disposition, name) 67 67 response.headers["Content-Disposition"] = cd 68 68 trunk/cherrypy/test/test_static.py
r1154 r1209 128 128 self.getPage("/static/dirback.jpg", headers=[ims]) 129 129 self.assertStatus(304) 130 self.assertNoHeader("Content-Type") 131 self.assertNoHeader("Content-Length") 132 self.assertNoHeader("Content-Disposition") 133 self.assertBody("") 130 134 131 135 trunk/cherrypy/test/test_tutorials.py
r1114 r1209 164 164 self.assertStatus("200 OK") 165 165 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"') 167 169 self.assertEqual(len(self.body), 85698) 168 170

