Handle a single HTTP request. You normally don't need to override this method; see the class __doc__ string for information on how to handle specific HTTP commands such as GET and POST.
(self)
| 453 | return True |
| 454 | |
| 455 | def handle_one_request(self): |
| 456 | """Handle a single HTTP request. |
| 457 | |
| 458 | You normally don't need to override this method; see the class |
| 459 | __doc__ string for information on how to handle specific HTTP |
| 460 | commands such as GET and POST. |
| 461 | |
| 462 | """ |
| 463 | try: |
| 464 | self.raw_requestline = self.rfile.readline(65537) |
| 465 | if len(self.raw_requestline) > 65536: |
| 466 | self.requestline = '' |
| 467 | self.request_version = '' |
| 468 | self.command = '' |
| 469 | self.send_error(HTTPStatus.REQUEST_URI_TOO_LONG) |
| 470 | return |
| 471 | if not self.raw_requestline: |
| 472 | self.close_connection = True |
| 473 | return |
| 474 | if not self.parse_request(): |
| 475 | # An error code has been sent, just exit |
| 476 | return |
| 477 | mname = 'do_' + self.command |
| 478 | if not hasattr(self, mname): |
| 479 | self.send_error( |
| 480 | HTTPStatus.NOT_IMPLEMENTED, |
| 481 | "Unsupported method (%r)" % self.command) |
| 482 | return |
| 483 | method = getattr(self, mname) |
| 484 | method() |
| 485 | self.wfile.flush() #actually send the response if not already done. |
| 486 | except TimeoutError as e: |
| 487 | #a read or a write timed out. Discard this connection |
| 488 | self.log_error("Request timed out: %r", e) |
| 489 | self.close_connection = True |
| 490 | return |
| 491 | |
| 492 | def handle(self): |
| 493 | """Handle multiple requests if necessary.""" |
no test coverage detected