Merge pull request #137 from warner/2312-deprecation

Appease req.setHeader by passing bytes, not ints.
This commit is contained in:
Daira Hopwood 2015-01-22 02:29:50 +00:00
commit 6f74282688
2 changed files with 3 additions and 3 deletions

View File

@ -206,7 +206,7 @@ def plural(sequence_or_length):
def text_plain(text, ctx):
req = IRequest(ctx)
req.setHeader("content-type", "text/plain")
req.setHeader("content-length", len(text))
req.setHeader("content-length", b"%d" % len(text))
return text
class WebError(Exception):
@ -315,7 +315,7 @@ class MyExceptionHandler(appserver.DefaultExceptionHandler):
req.setHeader("content-type", "text/plain;charset=utf-8")
if isinstance(text, unicode):
text = text.encode("utf-8")
req.setHeader("content-length", str(len(text)))
req.setHeader("content-length", b"%d" % len(text))
req.write(text)
# TODO: consider putting the requested URL here
req.finishRequest(False)

View File

@ -452,7 +452,7 @@ class FileDownloader(rend.Page):
contentsize = last - first + 1
size = contentsize
req.setHeader("content-length", str(contentsize))
req.setHeader("content-length", b"%d" % contentsize)
if req.method == "HEAD":
return ""