Skip to content

Preserve HTTPX environment proxy behavior with async retry transport #324

Description

@Mattsface

Problem

PR #323 moved async retries into a custom HTTPX transport:

httpx.AsyncClient(
    headers={"User-Agent": _build_user_agent()},
    transport=MlbAsyncRetryTransport(),
)

HTTPX only auto-loads environment proxies when transport is None. Passing a custom transport can therefore bypass HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, and NO_PROXY for library-created async clients.

Before #323, the library-created client was effectively:

httpx.AsyncClient(
    headers={"User-Agent": _build_user_agent()},
)

so normal environment proxy handling remained available.

Example

export HTTPS_PROXY=http://proxy.example.com:8080
from mlbstatsapi import AsyncMlb

async with AsyncMlb() as mlb:
    team = await mlb.get_team(133)

Expected: the request follows HTTPX's normal environment proxy behavior.

Acceptance criteria

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions