diff options
| author | Bert JW Regeer <bertjw@regeer.org> | 2016-04-12 20:16:26 -0600 |
|---|---|---|
| committer | Bert JW Regeer <bertjw@regeer.org> | 2016-04-12 20:21:53 -0600 |
| commit | f16e6ea20899ed6acf7622258b75e42f591d58d7 (patch) | |
| tree | cc3a8f6b5de637d5968844e1c600b7d67e3a0e4c | |
| parent | e195dc00d376ca30bb7d5009227c1eb7528ecdbf (diff) | |
| download | pyramid-f16e6ea20899ed6acf7622258b75e42f591d58d7.tar.gz pyramid-f16e6ea20899ed6acf7622258b75e42f591d58d7.tar.bz2 pyramid-f16e6ea20899ed6acf7622258b75e42f591d58d7.zip | |
We don't need to explicitly set charset for text/*
application/json however doesn't have a charset, so we just specify that
as UTF-8 for the purpose of encoding the bytes.
| -rw-r--r-- | pyramid/httpexceptions.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/pyramid/httpexceptions.py b/pyramid/httpexceptions.py index 5500a0a29..213e4b980 100644 --- a/pyramid/httpexceptions.py +++ b/pyramid/httpexceptions.py @@ -255,7 +255,6 @@ ${body}''') if match == 'text/html': self.content_type = 'text/html' - self.charset = 'utf-8' escape = _html_escape page_template = self.html_template_obj br = '<br/>' @@ -263,7 +262,7 @@ ${body}''') html_comment = '<!-- %s -->' % escape(comment) elif match == 'application/json': self.content_type = 'application/json' - self.charset = '' + self.charset = None escape = _no_escape br = '\n' if comment: @@ -283,7 +282,6 @@ ${body}''') page_template = JsonPageTemplate(self) else: self.content_type = 'text/plain' - self.charset = 'utf-8' escape = _no_escape page_template = self.plain_template_obj br = '\n' @@ -311,7 +309,7 @@ ${body}''') body = body_tmpl.substitute(args) page = page_template.substitute(status=self.status, body=body) if isinstance(page, text_type): - page = page.encode(self.charset) + page = page.encode(self.charset if self.charset else 'UTF-8') self.app_iter = [page] self.body = page |
