| 538 | |
| 539 | |
| 540 | class MockHTTPHandlerCheckAuth(urllib.request.BaseHandler): |
| 541 | # useful for testing auth |
| 542 | # sends supplied code response |
| 543 | # checks if auth header is specified in request |
| 544 | def __init__(self, code): |
| 545 | self.code = code |
| 546 | self.has_auth_header = False |
| 547 | |
| 548 | def reset(self): |
| 549 | self.has_auth_header = False |
| 550 | |
| 551 | def http_open(self, req): |
| 552 | if req.has_header('Authorization'): |
| 553 | self.has_auth_header = True |
| 554 | name = http.client.responses[self.code] |
| 555 | return MockResponse(self.code, name, MockFile(), "", req.get_full_url()) |
| 556 | |
| 557 | |
| 558 |
no outgoing calls
searching dependent graphs…