Custom ``HTTPHandler`` that can build a ``HTTPConnection`` with the args we need for ``source_address`` and ``timeout``
| 534 | |
| 535 | |
| 536 | class SpeedtestHTTPHandler(AbstractHTTPHandler): |
| 537 | """Custom ``HTTPHandler`` that can build a ``HTTPConnection`` with the |
| 538 | args we need for ``source_address`` and ``timeout`` |
| 539 | """ |
| 540 | def __init__(self, debuglevel=0, source_address=None, timeout=10): |
| 541 | AbstractHTTPHandler.__init__(self, debuglevel) |
| 542 | self.source_address = source_address |
| 543 | self.timeout = timeout |
| 544 | |
| 545 | def http_open(self, req): |
| 546 | return self.do_open( |
| 547 | _build_connection( |
| 548 | SpeedtestHTTPConnection, |
| 549 | self.source_address, |
| 550 | self.timeout |
| 551 | ), |
| 552 | req |
| 553 | ) |
| 554 | |
| 555 | http_request = AbstractHTTPHandler.do_request_ |
| 556 | |
| 557 | |
| 558 | class SpeedtestHTTPSHandler(AbstractHTTPHandler): |