Add Basic Auth header to the request.
(
self,
request: ClientRequest,
handler: ClientHandlerType,
)
| 43 | return f"Basic {encoded}" |
| 44 | |
| 45 | async def __call__( |
| 46 | self, |
| 47 | request: ClientRequest, |
| 48 | handler: ClientHandlerType, |
| 49 | ) -> ClientResponse: |
| 50 | """Add Basic Auth header to the request.""" |
| 51 | # Only add auth if not already present |
| 52 | if hdrs.AUTHORIZATION not in request.headers: |
| 53 | request.headers[hdrs.AUTHORIZATION] = self._auth_header |
| 54 | |
| 55 | # Proceed with the request |
| 56 | return await handler(request) |
| 57 | |
| 58 | |
| 59 | class TestServer: |