Changeset 309
- Timestamp:
- 06/14/05 12:45:20
- Files:
-
- branches/ooconf/cherrypy/_cpdefaults.py (modified) (2 diffs)
- branches/ooconf/cherrypy/_cphttptools.py (modified) (2 diffs)
- branches/ooconf/cherrypy/_cpwsgiserver.py (modified) (1 diff)
- branches/ooconf/cherrypy/lib/filter/logdebuginfofilter.py (modified) (2 diffs)
- branches/ooconf/cherrypy/lib/filter/tidyfilter.py (modified) (1 diff)
- branches/ooconf/cherrypy/test/helper.py (modified) (1 diff)
- branches/ooconf/cherrypy/test/test.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/ooconf/cherrypy/_cpdefaults.py
r307 r309 33 33 34 34 import time, thread, os 35 try:36 import cStringIO as StringIO37 except ImportError:38 import StringIO39 35 import cPickle as pickle 40 36 import cpg … … 67 63 def _cpOnError(): 68 64 """ Default _cpOnError method """ 69 70 import traceback 71 bodyFile = StringIO.StringIO() 72 traceback.print_exc(file = bodyFile) 73 cpg.response.body = [bodyFile.getvalue()] 65 import sys, traceback 66 content = "".join(traceback.format_exception(*sys.exc_info())) 67 cpg.response.body = [content] 74 68 cpg.response.headerMap['Content-Type'] = 'text/plain' 75 69 branches/ooconf/cherrypy/_cphttptools.py
r307 r309 35 35 import cpg, _cputil, cperror, _cpdefaults 36 36 37 try: 38 import cStringIO as StringIO 39 except ImportError: 40 import StringIO 37 # Can't use cStringIO; doesn't support unicode strings 38 # See http://www.python.org/sf/216388 39 import StringIO 41 40 42 41 from BaseHTTPServer import BaseHTTPRequestHandler … … 395 394 def finalize(): 396 395 """Transform headerMap + cookies into cpg.response.headers.""" 397 398 396 checkStatus() 399 397 400 398 if (cpg.config.get("server.protocolVersion") != "HTTP/1.1" 401 399 and cpg.response.headerMap.get('Content-Length') == 0): 402 buf = StringIO.StringIO() 403 for chunk in cpg.response.body: 404 buf.write(chunk) 405 buf.seek(0) 406 content = buf.read() 407 cpg.response.body = [content] 400 cpg.response.body = content = ''.join(cpg.response.body) 408 401 cpg.response.headerMap['Content-Length'] = len(content) 409 402 branches/ooconf/cherrypy/_cpwsgiserver.py
r251 r309 121 121 self.wfile.flush() 122 122 def terminate(self): 123 if not self.sent_headers: 124 self.sent_headers = True 125 self.send_headers() 123 126 self.rfile.close() 124 127 self.wfile.close() branches/ooconf/cherrypy/lib/filter/logdebuginfofilter.py
r307 r309 27 27 """ 28 28 29 import time , pickle29 import time 30 30 31 31 try: 32 import c StringIO as StringIO32 import cPickle as pickle 33 33 except ImportError: 34 import StringIO 34 import pickle 35 35 36 36 37 … … 72 73 # Pickle session data to get its size 73 74 try: 74 f = StringIO.StringIO() 75 pickle.dump(cpg.request.sessionMap, f, 1) 76 dumpStr = f.getvalue() 77 f.close() 75 dumpStr = pickle.dumps(cpg.request.sessionMap, 1) 78 76 logList.append("Session data size: %.02fKB" % 79 77 (len(dumpStr) / float(1024))) branches/ooconf/cherrypy/lib/filter/tidyfilter.py
r307 r309 28 28 29 29 import os, cgi, traceback 30 31 try: 32 import cStringIO as StringIO 33 except ImportError: 34 import StringIO 30 import StringIO 35 31 36 32 branches/ooconf/cherrypy/test/helper.py
r267 r309 84 84 85 85 # Handle response 86 response = conn.getresponse() 86 try: 87 response = conn.getresponse() 88 except httplib.BadStatusLine: 89 # Improper response from server. 90 print 91 print "Server did not return a response." 92 print "status>", repr(cpg.response.status) 93 print "headers>", repr(cpg.response.headers) 94 print "body>", repr(cpg.response.body) 95 raise 87 96 88 97 cpg.response.status = "%s %s" % (response.status, response.reason) branches/ooconf/cherrypy/test/test.py
r306 r309 166 166 } 167 167 168 for name, server in [("Serverless", None), 168 for name, server in [ 169 ("Serverless", None), 169 170 ("Native HTTP Server", "cherrypy._cphttpserver.embedded_server"), 170 171 ("Native WSGI Server", "cherrypy._cpwsgi.WSGIServer"),

