1. Chathuranga Bandara
  2. CherryPy


Carlos Ribeiro  committed 5e1478f

- Set the cpg.response.wfile and the cpg.response.sendResponse attributes *before* calling initRequest. This way filters that are called on the input chain can access the information (specially wfile) that is needed.

- Also, made sure that the handleRequest call uses the value from cpg.response.wfile instead of the local wfile; this allows the filter to redirect or to wrap the original wfile and set the new one on cpg.response.wfile.

  • Participants
  • Parent commits a8462b2
  • Branches cherrypy

Comments (0)

Files changed (1)

File _cphttptools.py

View file
 def doRequest(clientAddress, remoteHost, requestLine, headers, rfile, wfile):
+    # inits the cpg.responsed.wfile so filters can access it
+    cpg.response.wfile = wfile
+    cpg.response.sendResponse = 1
     initRequest(clientAddress, remoteHost, requestLine, headers, rfile, wfile)
+    # reads back wfile; if may be redirected by a filter
+    wfile = cpg.response.wfile
     # Prepare response variables
     now = time.time()
         "Content-Length": 0
     cpg.response.simpleCookie = Cookie.SimpleCookie()
-    cpg.response.wfile = wfile
-    cpg.response.sendResponse = 1