Skip to main content

Minimal asyncio-based HTTP/1.1 client

Project description

tiny-aio-http-client

Minimal asyncio-based HTTP/1.1 client for Python 3.8+ with no external dependencies.

Features

  • GET, POST, PUT, PATCH, DELETE, HEAD methods
  • Automatic redirect following
  • Cookie jar with domain/path/secure matching
  • Chunked transfer encoding support
  • JSON request body encoding
  • Query parameter merging
  • HTTP and HTTPS proxy support (including CONNECT tunneling)
  • Proxy resolution from environment variables (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY) and Windows registry
  • SSL verification toggle
  • Per-request and per-client timeouts

Usage

High-level interface: fetch and fetch_chunked

import asyncio
from tiny_aio_http_client import fetch, fetch_chunked

async def main() -> None:
	print(await fetch("https://example.com"))

	with open("index.html", "w") as fp:
		async for chunk in fetch_chunked("https://example.com"):
			fp.write(chunk)

asyncio.run(main())

Low-level interface: HtppClient

import asyncio
from tiny_aio_http_client import HttpClient

async def main() -> None:
    async with HttpClient() as client:
        async with await client.get("https://example.com") as response:
            body = await response.read()
            print(body)

asyncio.run(main())

See the module docstring in tiny_aio_http_client/__init__.py for additional examples.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tiny_aio_http_client-1.0.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file tiny_aio_http_client-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for tiny_aio_http_client-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c682e5fc3b20ab8b9a51a81674b97f64749479533a229a7aa8cbe6eb886b29bd
MD5 85b452702bf852535cda4a511bb2efd3
BLAKE2b-256 09cbbb131f1751873bb7578d1990e4be449bc036de6b6e54d9d6e987fb0ce829

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page