Skip to content

Make HTTPProvider.get_request_headers() a class-level method #3466

@antazoey

Description

@antazoey

What feature should we add?

At the time of writing this issue, the method is defined here:
https://github.com/ethereum/web3.py/blob/main/web3/providers/rpc/rpc.py#L119-L123

It is:

    def get_request_headers(self) -> Dict[str, str]:
        return {
            "Content-Type": "application/json",
            "User-Agent": construct_user_agent(str(type(self))),
        }

I am requesting this method be exposed at the class-level, to be re-written as:

    @classmethod
    def get_request_headers(cls) -> Dict[str, str]:
        return {
            "Content-Type": "application/json",
            "User-Agent": construct_user_agent(str(cls)),
        }

Use-case: This allows me to grab the default headers before constructing an HTTPProvider object for the purpose of modifying them / appending to them, without having to redefine.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions