Ticket #156: paste-httpexceptions.diff

File paste-httpexceptions.diff, 1.2 KB (added by damjan, 5 years ago)
  • httpexceptions.py

    old new  
    222222                   'server': SERVER_NAME, 
    223223                   'body': body } 
    224224 
    225     def wsgi_application(self, environ, start_response, exc_info=None): 
    226         """ 
    227         This exception as a WSGI application 
    228         """ 
     225    def prepare_content(self, environ): 
    229226        if self.headers: 
    230227            headers = list(self.headers) 
    231228        else: 
     
    245242            replace_header( 
    246243                headers, 'content-type', 
    247244                cur_content_type + '; charset=utf8') 
     245        return headers, content 
     246 
     247    def response(self, environ): 
     248        from paste.wsgiwrappers import WSGIResponse 
     249        headers, content = self.prepare_content(environ) 
     250        resp = WSGIResponse(code=self.code, content=content) 
     251        resp.headers.update(dict(headers)) 
     252        return resp 
     253 
     254    def wsgi_application(self, environ, start_response, exc_info=None): 
     255        """ 
     256        This exception as a WSGI application 
     257        """ 
     258        headers, content = self.prepare_content(environ) 
    248259        start_response('%s %s' % (self.code, self.title), 
    249260                       headers, 
    250261                       exc_info)