Changeset 1210
- Timestamp:
- 08/03/06 00:12:54
- Files:
-
- branches/cherrypy-2.x/cherrypy/_cperror.py (modified) (1 diff)
- branches/cherrypy-2.x/cherrypy/_cphttptools.py (modified) (1 diff)
- branches/cherrypy-2.x/cherrypy/lib/cptools.py (modified) (2 diffs)
- branches/cherrypy-2.x/cherrypy/test/test_static_filter.py (modified) (1 diff)
- branches/cherrypy-2.x/cherrypy/test/test_tutorials.py (modified) (1 diff)
- branches/cherrypy-2.x/cherrypy/tutorial/tut09_files.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/cherrypy-2.x/cherrypy/_cperror.py
r972 r1210 126 126 # The "Date" header should have been set in Request.__init__ 127 127 128 # "...the response SHOULD NOT include other entity-headers. 129 for key in ('Allow', 'Content-Encoding', 'Content-Language', 130 'Content-Length', 'Content-Location', 'Content-MD5', 131 'Content-Range', 'Content-Type', 'Expires', 132 'Last-Modified'): 133 if key in response.headers: 134 del response.headers[key] 135 128 136 # "The 304 response MUST NOT contain a message-body." 129 137 response.body = None branches/cherrypy-2.x/cherrypy/_cphttptools.py
r1042 r1210 401 401 # Responses which are not streamed should have a Content-Length, 402 402 # but allow user code to set Content-Length if desired. 403 if self.headers.get('Content-Length') is None: 403 if (self.headers.get('Content-Length') is None 404 and code not in (304,)): 404 405 content = self.collapse_body() 405 406 self.headers['Content-Length'] = len(content) branches/cherrypy-2.x/cherrypy/lib/cptools.py
r1008 r1210 84 84 if cherrypy.request.headers.has_key('If-Modified-Since'): 85 85 if cherrypy.request.headers['If-Modified-Since'] == strModifTime: 86 response.status = "304 Not Modified" 87 response.body = None 88 if getattr(cherrypy, "debug", None): 89 cherrypy.log(" Found file (304 Not Modified): %s" % path, "DEBUG") 90 return False 86 raise cherrypy.HTTPRedirect([], 304) 91 87 response.headers['Last-Modified'] = strModifTime 92 88 return True … … 140 136 if name is None: 141 137 name = os.path.basename(path) 142 cd = "%s; filename=%s"% (disposition, name)138 cd = '%s; filename="%s"' % (disposition, name) 143 139 response.headers["Content-Disposition"] = cd 144 140 branches/cherrypy-2.x/cherrypy/test/test_static_filter.py
r1034 r1210 128 128 ims = ("If-Modified-Since", lastmod) 129 129 self.getPage("/static/dirback.jpg", headers=[ims]) 130 self.assertStatus("304 Not Modified") 130 self.assertStatus(304) 131 self.assertNoHeader("Content-Type") 132 self.assertNoHeader("Content-Length") 133 self.assertNoHeader("Content-Disposition") 134 self.assertBody("") 135 131 136 ## 132 137 ## # Test lots of requests for the same file (no If-Mod). branches/cherrypy-2.x/cherrypy/test/test_tutorials.py
r1022 r1210 160 160 self.assertStatus("200 OK") 161 161 self.assertHeader("Content-Type", "application/x-download") 162 self.assertHeader("Content-Disposition", "attachment; filename=pdf_file.pdf") 162 self.assertHeader("Content-Disposition", 163 # Make sure the filename is quoted. 164 'attachment; filename="pdf_file.pdf"') 163 165 self.assertEqual(len(self.body), 85698) 164 166 branches/cherrypy-2.x/cherrypy/tutorial/tut09_files.py
r956 r1210 32 32 Set "name" to the filename that you expect clients to use when they save 33 33 your file. Note that the "name" argument is ignored if you don't also 34 provide a "disposition" (usually "attach ement"). You can manually set34 provide a "disposition" (usually "attachment"). You can manually set 35 35 "contentType", but be aware that if you also use the EncodingFilter, it 36 36 may choke if the file extension is not recognized as belonging to a known

