Skip to content

How to customize httpx client (for proxy support)? #467

Answered by ItsCEED
ItsCEED asked this question in Questions
Discussion options

You must be logged in to vote

Modifying the class directly did the job.

class AsyncRequest(RequestBase):
    def __init__(self, proxy_url: str = None) -> None:
        super().__init__()
        # Configure the AsyncClient with or without a proxy
        self._client = httpx.AsyncClient(
            follow_redirects=True,
            proxies={"all://": proxy_url} if proxy_url else None
        )

Worked this way with no issues:

import asyncio
from atproto import AsyncClient
from atproto_client.request import AsyncRequest

async def flow():
    proxy_url = "http://user:pass@host:port"

    custom_request = AsyncRequest(proxy_url=proxy_url)

    client = AsyncClient(request=custom_request)

    is_logged = await client.l…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@MarshalX
Comment options

Answer selected by MarshalX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #446 on November 26, 2024 14:53.