Changeset 1158
- Timestamp:
- 06/25/06 17:45:06
- Files:
-
- trunk/cherrypy/_cpmodpy.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cpmodpy.py
r1156 r1158 3 3 from mod_python import apache 4 4 import cherrypy 5 from cherrypy._cperror import format_exc, bare_error 5 6 6 7 … … 87 88 response = request.run(requestLine, headers, rfile) 88 89 89 sendResponse(req, response )90 sendResponse(req, response.status, response.header_list, response.body) 90 91 request.close() 91 92 except: 92 cherrypy.log(traceback=True) 93 tb = format_exc() 94 cherrypy.log(tb) 95 s, h, b = bare_error() 96 sendResponse(req, s, h, b) 93 97 return apache.OK 94 98 95 def sendResponse(req, response):99 def sendResponse(req, status, headers, body): 96 100 # Set response status 97 req.status = int( response.status[:3])101 req.status = int(status[:3]) 98 102 99 103 # Set response headers 100 104 req.content_type = "text/plain" 101 for header, value in response.header_list:105 for header, value in headers: 102 106 if header.lower() == 'content-type': 103 107 req.content_type = value … … 105 109 req.headers_out.add(header, value) 106 110 107 # Cookie108 cook_out = response.simple_cookie.output()109 if cook_out:110 for line in cook_out.split('\n'):111 req.headers_out.add(*tuple(v.strip() for v in line.split(':', 1)))112 113 111 # Set response body 114 if isinstance( response.body, basestring):115 req.write( response.body)112 if isinstance(body, basestring): 113 req.write(body) 116 114 else: 117 for seg in response.body:115 for seg in body: 118 116 req.write(seg) 117

