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)
| 425 | return True |
| 426 | |
| 427 | def handle_one_request(self): |
| 428 | """Handle a single HTTP request. |
| 429 | |
| 430 | You normally don't need to override this method; see the class |
| 431 | __doc__ string for information on how to handle specific HTTP |
| 432 | commands such as GET and POST. |
| 433 | |
| 434 | """ |
| 435 | try: |
| 436 | self.raw_requestline = self.rfile.readline(65537) |
| 437 | if len(self.raw_requestline) > 65536: |
| 438 | self.requestline = '' |
| 439 | self.request_version = '' |
| 440 | self.command = '' |
| 441 | self.send_error(HTTPStatus.REQUEST_URI_TOO_LONG) |
| 442 | return |
| 443 | if not self.raw_requestline: |
| 444 | self.close_connection = True |
| 445 | return |
| 446 | if not self.parse_request(): |
| 447 | # An error code has been sent, just exit |
| 448 | return |
| 449 | mname = 'do_' + self.command |
| 450 | if not hasattr(self, mname): |
| 451 | self.send_error( |
| 452 | HTTPStatus.NOT_IMPLEMENTED, |
| 453 | "Unsupported method (%r)" % self.command) |
| 454 | return |
| 455 | method = getattr(self, mname) |
| 456 | method() |
| 457 | self.wfile.flush() #actually send the response if not already done. |
| 458 | except TimeoutError as e: |
| 459 | #a read or a write timed out. Discard this connection |
| 460 | self.log_error("Request timed out: %r", e) |
| 461 | self.close_connection = True |
| 462 | return |
| 463 | |
| 464 | def handle(self): |
| 465 | """Handle multiple requests if necessary.""" |
no test coverage detected