Пример #1
0
 def simple(self, ctx, text, code=http.BAD_REQUEST):
     req = IRequest(ctx)
     req.setResponseCode(code)
     #req.responseHeaders.setRawHeaders("content-encoding", [])
     #req.responseHeaders.setRawHeaders("content-disposition", [])
     req.setHeader("content-type", "text/plain;charset=utf-8")
     if isinstance(text, unicode):
         text = text.encode("utf-8")
     req.setHeader("content-length", str(len(text)))
     req.write(text)
     # TODO: consider putting the requested URL here
     req.finishRequest(False)
Пример #2
0
 def simple(self, ctx, text, code=http.BAD_REQUEST):
     req = IRequest(ctx)
     req.setResponseCode(code)
     #req.responseHeaders.setRawHeaders("content-encoding", [])
     #req.responseHeaders.setRawHeaders("content-disposition", [])
     req.setHeader("content-type", "text/plain;charset=utf-8")
     if isinstance(text, unicode):
         text = text.encode("utf-8")
     req.setHeader("content-length", b"%d" % len(text))
     req.write(text)
     # TODO: consider putting the requested URL here
     req.finishRequest(False)
Пример #3
0
 def renderHTTP_exception(self, ctx, failure):
     """Render the error page."""
     request = IRequest(ctx)
     request.setResponseCode(http.INTERNAL_SERVER_ERROR)
     res = self.renderHTTP(ctx)
     request.finishRequest(False)
     log.err(failure)
     service = IService(ctx)
     service.build_and_send(service.ADMIN,
                            '[crash report] mes-souhaits.net',
                            str(failure))
     return res