Skip to content

Commit

Permalink
be explicit about the content type of the views.
Browse files Browse the repository at this point in the history
  • Loading branch information
janwijbrand committed Jan 9, 2018
1 parent 5267b87 commit fcf395c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/zope/errorview/browser.py
Expand Up @@ -52,6 +52,8 @@ def update(self):
'Cache-Control', 'no-store, no-cache, must-revalidate')
self.request.response.setHeader(
'Pragma', 'no-cache')
self.request.response.setHeader(
'Content-Type', 'text/plain;charset=utf-8')
principal = self.request.principal
getUtility(IAuthentication).unauthorized(principal.id, self.request)

Expand Down
5 changes: 5 additions & 0 deletions src/zope/errorview/http.py
Expand Up @@ -40,6 +40,8 @@ def __init__(self, context, request):

def update(self):
self.request.response.setStatus(500)
self.request.response.setHeader(
'Content-Type', 'text/plain; charset=utf-8')

def render(self):
return ''
Expand All @@ -60,6 +62,7 @@ class ExceptionView(ExceptionViewBase):
class TraversalExceptionView(ExceptionViewBase):

def update(self):
super(TraversalExceptionView, self).update()
if self.request.method == 'MKCOL' and self.request.getTraversalStack():
# MKCOL with non-existing parent.
self.request.response.setStatus(409)
Expand All @@ -70,6 +73,7 @@ def update(self):
class UnauthorizedView(ExceptionViewBase):

def update(self):
super(UnauthorizedView, self).update()
self.request.unauthorized('basic realm="Zope"')
self.request.response.setStatus(401)

Expand All @@ -85,6 +89,7 @@ def allowed(self):
return []

def update(self):
super(MethodNotAllowedView, self).update()
allow = self.allowed()
self.request.response.setStatus(405)
self.request.response.setHeader('Allow', ', '.join(allow))

0 comments on commit fcf395c

Please sign in to comment.