Mercurial > p > roundup > code
comparison roundup/cgi/client.py @ 5079:65fef7858606
issue2550826 IOError in detector causes apache 'premature end of script headers' error
Capture all exceptions from auditors/reactors and raise a
DetectorError instead. This allows failures like IOErrors from the
detectors (e.g. unable to access files) to be handled. Previously an
IOError just resulted in no output (premature end of headers under
apache). Problem diagnosed and initial patch created by Tom Ekberg
(tekberg).
Patch application/mods and testing by rouilj.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Fri, 10 Jun 2016 23:33:11 -0400 |
| parents | d0aa596daca8 |
| children | 748ba87e1aca |
comparison
equal
deleted
inserted
replaced
| 5078:487dc55e3c5e | 5079:65fef7858606 |
|---|---|
| 17 from roundup.cgi import templating, cgitb, TranslationService | 17 from roundup.cgi import templating, cgitb, TranslationService |
| 18 from roundup.cgi import actions | 18 from roundup.cgi import actions |
| 19 from roundup.exceptions import LoginError, Reject, RejectRaw, Unauthorised | 19 from roundup.exceptions import LoginError, Reject, RejectRaw, Unauthorised |
| 20 from roundup.cgi.exceptions import ( | 20 from roundup.cgi.exceptions import ( |
| 21 FormError, NotFound, NotModified, Redirect, SendFile, SendStaticFile, | 21 FormError, NotFound, NotModified, Redirect, SendFile, SendStaticFile, |
| 22 SeriousError) | 22 DetectorError, SeriousError) |
| 23 from roundup.cgi.form_parser import FormParser | 23 from roundup.cgi.form_parser import FormParser |
| 24 from roundup.mailer import Mailer, MessageSendError, encode_quopri | 24 from roundup.mailer import Mailer, MessageSendError, encode_quopri |
| 25 from roundup.cgi import accept_language | 25 from roundup.cgi import accept_language |
| 26 from roundup import xmlrpc | 26 from roundup import xmlrpc |
| 27 | 27 |
| 570 pass | 570 pass |
| 571 except SysCallError: | 571 except SysCallError: |
| 572 # OpenSSL.SSL.SysCallError is similar to IOError above | 572 # OpenSSL.SSL.SysCallError is similar to IOError above |
| 573 # may happen during write_html and serve_file, too. | 573 # may happen during write_html and serve_file, too. |
| 574 pass | 574 pass |
| 575 except DetectorError as e: | |
| 576 if not self.instance.config.WEB_DEBUG: | |
| 577 # run when we are not in debug mode, so errors | |
| 578 # go to admin too. | |
| 579 self.send_error_to_admin(e.subject, e.html, e.txt) | |
| 580 self.write_html(e.html) | |
| 581 else: | |
| 582 # in debug mode, only write error to screen. | |
| 583 self.write_html(e.html) | |
| 575 except: | 584 except: |
| 576 # Something has gone badly wrong. Therefore, we should | 585 # Something has gone badly wrong. Therefore, we should |
| 577 # make sure that the response code indicates failure. | 586 # make sure that the response code indicates failure. |
| 578 if self.response_code == http_.client.OK: | 587 if self.response_code == http_.client.OK: |
| 579 self.response_code = http_.client.INTERNAL_SERVER_ERROR | 588 self.response_code = http_.client.INTERNAL_SERVER_ERROR |
