Call the appropriate WSGI app and write its iterable output.
(self)
| 525 | return True |
| 526 | |
| 527 | def respond(self): |
| 528 | """Call the appropriate WSGI app and write its iterable output.""" |
| 529 | # Set rfile.maxlen to ensure we don't read past Content-Length. |
| 530 | # This will also be used to read the entire request body if errors |
| 531 | # are raised before the app can read the body. |
| 532 | if self.chunked_read: |
| 533 | # If chunked, Content-Length will be 0. |
| 534 | self.rfile.maxlen = self.max_request_body_size |
| 535 | else: |
| 536 | cl = int(self.environ.get("CONTENT_LENGTH", 0)) |
| 537 | if self.max_request_body_size: |
| 538 | self.rfile.maxlen = min(cl, self.max_request_body_size) |
| 539 | else: |
| 540 | self.rfile.maxlen = cl |
| 541 | self.rfile.bytes_read = 0 |
| 542 | |
| 543 | try: |
| 544 | self._respond() |
| 545 | except MaxSizeExceeded: |
| 546 | if not self.sent_headers: |
| 547 | self.simple_response("413 Request Entity Too Large") |
| 548 | return |
| 549 | |
| 550 | def _respond(self): |
| 551 | if self.chunked_read: |
no test coverage detected