Skip to content

Disabling direct access to environment variables by telegram.HTTPXRequest #4424

@asrelo

Description

@asrelo

Issue I am facing

So httpx reads important options from environment variables (SSL settings, HTTP proxying). This is default behavior that can be disabled by passing trust_env=False when instantiating httpx.Client.

telegram.request.HTTPXRequest (that manages httpx.Client) doesn't do that and doesn't expose a way to do that.

I considered writing custom implementation of telegram.request.BaseRequest, replicating HTTPXRequest's interface. That's not ideal because it is not possible to implement the same interface without using undocumented/poorly documented features of httpx (which HTTPXRequest uses, specifically to pass socket_options and some other options).

I don't really understand how this is supposed to be handled without making an implementation inferior, so this issue is marked as question.

Traceback to the issue

No response

Related part of your code

No response

Operating System

Windows 10

Version of Python, python-telegram-bot & dependencies

python-telegram-bot 21.4
Bot API 7.7
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions