From f22e6d428208a0fbfdf0e1407b83c7e2fffd6e24 Mon Sep 17 00:00:00 2001 From: WooParadog Date: Wed, 13 Nov 2013 14:28:38 +0800 Subject: [PATCH] Error message should be able to be encoded in latin1 Broken request can have none latin1 characters which would break `util.write_error(client, status_int, reason, mesg)` --- gunicorn/http/errors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gunicorn/http/errors.py b/gunicorn/http/errors.py index a5189b14..bab7856f 100644 --- a/gunicorn/http/errors.py +++ b/gunicorn/http/errors.py @@ -38,7 +38,7 @@ class InvalidHTTPVersion(ParseException): self.version = version def __str__(self): - return "Invalid HTTP Version: %s" % self.version + return "Invalid HTTP Version: %r" % self.version class InvalidHeader(ParseException): @@ -47,7 +47,7 @@ class InvalidHeader(ParseException): self.req = req def __str__(self): - return "Invalid HTTP Header: %s" % self.hdr + return "Invalid HTTP Header: %r" % self.hdr class InvalidHeaderName(ParseException): @@ -55,7 +55,7 @@ class InvalidHeaderName(ParseException): self.hdr = hdr def __str__(self): - return "Invalid HTTP header name: %s" % self.hdr + return "Invalid HTTP header name: %r" % self.hdr class InvalidChunkSize(IOError): @@ -97,7 +97,7 @@ class InvalidProxyLine(ParseException): self.code = 400 def __str__(self): - return "Invalid PROXY line: %s" % self.line + return "Invalid PROXY line: %r" % self.line class ForbiddenProxyRequest(ParseException): @@ -106,4 +106,4 @@ class ForbiddenProxyRequest(ParseException): self.code = 403 def __str__(self): - return "Proxy request from %s not allowed" % self.host + return "Proxy request from %r not allowed" % self.host