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)
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)
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