Custom ``HTTPSHandler`` that can build a ``HTTPSConnection`` with the args we need for ``source_address`` and ``timeout``
| 556 | |
| 557 | |
| 558 | class SpeedtestHTTPSHandler(AbstractHTTPHandler): |
| 559 | """Custom ``HTTPSHandler`` that can build a ``HTTPSConnection`` with the |
| 560 | args we need for ``source_address`` and ``timeout`` |
| 561 | """ |
| 562 | def __init__(self, debuglevel=0, context=None, source_address=None, |
| 563 | timeout=10): |
| 564 | AbstractHTTPHandler.__init__(self, debuglevel) |
| 565 | self._context = context |
| 566 | self.source_address = source_address |
| 567 | self.timeout = timeout |
| 568 | |
| 569 | def https_open(self, req): |
| 570 | return self.do_open( |
| 571 | _build_connection( |
| 572 | SpeedtestHTTPSConnection, |
| 573 | self.source_address, |
| 574 | self.timeout, |
| 575 | context=self._context, |
| 576 | ), |
| 577 | req |
| 578 | ) |
| 579 | |
| 580 | https_request = AbstractHTTPHandler.do_request_ |
| 581 | |
| 582 | |
| 583 | def build_opener(source_address=None, timeout=10): |