Make option to turn off chunked encoding for debugging more clear.

This commit is contained in:
Jim Paris 2013-01-01 21:03:33 -05:00
parent 487298986e
commit 389c1d189f
2 changed files with 10 additions and 2 deletions

View File

@ -84,6 +84,10 @@ class HTTPClient(object):
raise ClientError(**args)
else: # pragma: no cover
if code >= 500 and code <= 599:
if args["message"] is None:
args["message"] = ("(no message; try disabling " +
"use_chunked_http_response in " +
"nilmdb.server for better debugging)")
raise ServerError(**args)
else:
raise Error(**args)

View File

@ -23,6 +23,10 @@ class NilmApp(object):
def __init__(self, db):
self.db = db
# Set this to False to get better tracebacks from some requests
# (/stream/extract, /stream/intervals)
use_chunked_http_response = False
version = "1.1"
class Root(NilmApp):
@ -245,7 +249,7 @@ class Stream(NilmApp):
break
start = restart
return content(start, end)
intervals._cp_config = { 'response.stream': True } # chunked HTTP response
intervals._cp_config = { 'response.stream': use_chunked_http_response }
# /stream/extract?path=/newton/prep&start=1234567890.0&end=1234567899.0
@cherrypy.expose
@ -296,7 +300,7 @@ class Stream(NilmApp):
return
start = restart
return content(start, end, count)
extract._cp_config = { 'response.stream': True } # chunked HTTP response
extract._cp_config = { 'response.stream': use_chunked_http_response }
class Exiter(object):