HTTPResponse.handleException should set the content type

Bug #98413 reported by Marius Gedminas on 2006-08-07
Affects Status Importance Assigned to Milestone
Zope 3
Status tracked in 3.4
Dmitry Vasiliev

Bug Description

zope.publication.http.HTTPResponse.handleException formats the error as HTML and calls self.setResult, without touching the Content-Type header. This may cause an exception inside setResult:

      File ".../zope3/src/zope/app/publication/", line 355, in handleException
      File ".../zope3/src/zope/publisher/", line 901, in handleException
      File ".../zope3/src/zope/publisher/", line 817, in setResult body, headers = self._implicitResult(result)
      File ".../zope3/src/zope/publisher/", line 861, in _implicitResult
        raise ValueError(
    ValueError: Unicode results must have a text content type.

Suggested fix:

Index: var/src/zope3/src/zope/publisher/
--- var/src/zope3/src/zope/publisher/ (revision 69362)
+++ var/src/zope3/src/zope/publisher/ (working copy)
@@ -897,6 +897,7 @@

         body = self._html(title, "A server error occurred." )
+ self.setHeader('Content-Type', 'text/html')

It needs a unit test before it can be applied.

Martijn Faassen (faassen) wrote :

I ran into this issue as well, through See also some discussion there for details. Odd thing is I attempted the Content-Type fix, but had it not working for me. I'll try again.

Martijn Faassen (faassen) wrote :

Changes: submitter email, edited transcript, importance (medium => critical)

Martijn Faassen (faassen) wrote :

The Content-Type fix actually does "work" for me, but we realized that things may show up in the error reporting utility that don't show up in the SiteError log.

Martijn Faassen (faassen) wrote :

To expand on that, the "working" fix makes things be visible in the error utility as before, but *nothing* whatsoever will show up in the SiteError log (thus STDOUT in the standard configuration) to indicate that there was an error.

Rocky Burt (rocky-burt) wrote :

Getting a bit off-topic. Think for this bug we should just get handleException's content-type stuff right :)

Changed in zope3:
status: Unconfirmed → Confirmed
Dmitry Vasiliev (hdima) wrote :

I'll commit the suggested fix and look into the error reporting issue.

Dmitry Vasiliev (hdima) wrote :

Fixed on the trunk at revision 75799. The error reporting issue needs further investigation. I'll look at it later.

We've had two betas since this fix has been committed, therefore setting status to Fix Released.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers