Skip to content

Gufo HTTP is an accelerated Python HTTP client library

License

Notifications You must be signed in to change notification settings

gufolabs/gufo_http

Repository files navigation

Gufo HTTP

The accelerated Python HTTP client library.

PyPi version Python Versions License Build Sponsors Ruff


Documentation: https://docs.gufolabs.com/gufo_http/

Source Code: https://github.com/gufolabs/gufo_http/


Gufo HTTP is a high-performance Python HTTP client library that handles both asynchronous and synchronous modes. It wraps famous Reqwest HTTP client, written in Rust language with PyO3 wrapper. Our task is to reach maximal performance while maintaining clean and easy-to use API.

The getting of single URL is a simple task:

async with HttpClient() as client:
    resp = client.get("https://docs.gufolabs.com/")
    assert resp.status == 200
    data = resp.content

The HttpClient is highly customizable, for example, to set request headers:

async with HttpClient(headers={"X-My-Header": b"test"}) as client:
    resp = client.get("https://docs.gufolabs.com/")
    ...

The response headers processing as easy as working with dicts:

async with HttpClient(headers={"X-My-Header": b"test"}) as client:
    resp = client.get("https://docs.gufolabs.com/")
    if resp.headers["Content-Type"] == "text/html":
        ...

Gufo HTTP supports common authentication methods out-of-box:

async with HttpClient(auth=BasicAuth("scott", "tiger")) as client:
    resp = client.get("https://protected.example.com/")
    ...

Features

  • Clean async and blocking API.
  • High performance (see Performance section for details).
  • Built with security in mind.
  • Customizabile redirect policy.
  • TLS support.
  • Basic and bearer authorization schemes.
  • HTTP/HTTPS/SOCKS5 Proxy support.
  • Full Python typing support.
  • Editor completion.
  • Well-tested, battle-proven code.

Performance

Gufo HTTP is proved to be one of the fastest Python HTTP client available in the various scenarios. For example:

Single HTTP/1.1 requests scenario

Single requests Lower is better

100 Linear HTTP/1.1 requests scenario

Linear requests Lower is better

100 Parallel HTTP/1.1 requests scenario

Parallel requests Lower is better

Single HTTPS requests scenario

Single requests Lower is better

100 Linear HTTPS requests scenario

Linear requests Lower is better

100 Parallel HTTPS requests scenario

Parallel requests Lower is better

Refer to benchmarks for details.

On Gufo Stack

This product is a part of Gufo Stack - the collaborative effort led by Gufo Labs. Our goal is to create a robust and flexible set of tools to create network management software and automate routine administration tasks.

To do this, we extract the key technologies that have proven themselves in the NOC and bring them as separate packages. Then we work on API, performance tuning, documentation, and testing. The NOC uses the final result as the external dependencies.

Gufo Stack makes the NOC better, and this is our primary task. But other products can benefit from Gufo Stack too. So we believe that our effort will make the other network management products better.