| 402 | self.will_close = True |
| 403 | |
| 404 | def _check_close(self): |
| 405 | conn = self.headers.get("connection") |
| 406 | if self.version == 11: |
| 407 | # An HTTP/1.1 proxy is assumed to stay open unless |
| 408 | # explicitly closed. |
| 409 | if conn and "close" in conn.lower(): |
| 410 | return True |
| 411 | return False |
| 412 | |
| 413 | # Some HTTP/1.0 implementations have support for persistent |
| 414 | # connections, using rules different than HTTP/1.1. |
| 415 | |
| 416 | # For older HTTP, Keep-Alive indicates persistent connection. |
| 417 | if self.headers.get("keep-alive"): |
| 418 | return False |
| 419 | |
| 420 | # At least Akamai returns a "Connection: Keep-Alive" header, |
| 421 | # which was supposed to be sent by the client. |
| 422 | if conn and "keep-alive" in conn.lower(): |
| 423 | return False |
| 424 | |
| 425 | # Proxy-Connection is a netscape hack. |
| 426 | pconn = self.headers.get("proxy-connection") |
| 427 | if pconn and "keep-alive" in pconn.lower(): |
| 428 | return False |
| 429 | |
| 430 | # otherwise, assume it will close |
| 431 | return True |
| 432 | |
| 433 | def _close_conn(self): |
| 434 | fp = self.fp |