Skip to main content

Lightweight Python asyncio HTTP/1.1 client.

Project description

lowhaio CircleCI Maintainability Test Coverage


Work in progress. These docs serve as a rough design spec.


A lightweight Python asyncio HTTP/1.1 client.

Usage

The API is streaming-first: for both request and response bodies, asynchronous generators are used.

import os
from lowhaio import Pool

request, _ = Pool()

path = 'my.file'
content_length = str(os.stat(path).st_size).encode()
async def file_data():
    with open(path, 'rb') as file:
        for chunk in iter(lambda: file.read(65536), b''):
            yield chunk

code, headers, body = await request(
    b'POST', 'https://example.com/path',
    params=(), headers=((b'content-length': content_length),), body=file_data(),
)
async for chunk in body:
    print(chunk)

However, there are helper functions streamed and buffered when this isn't required or possible.

from lowhaio import Pool, streamed, buffered

content = b'some-data'
content_length = 
code, headers, body = await request(
    b'POST', 'https://example.com/path',
    params=(), headers=((b'content-length': content_length),), body=streamed(content),
)

response = await buffered(body)

Scope and structures

The scope of the core functions is restricted to:

  • (TLS) connection opening, closing and pooling;
  • passing and receiving HTTP headers and streaming bodies;
  • decoding chunked responses.

This is to make the core behaviour useful to a reasonable range of uses, but to not include what can be added by layer(s) on top. Specifically not included:

  • following redirects (although this is planned for a helper function);
  • cookies;
  • compressing/decompressing requests/responses;
  • authentication.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

lowhaio-0.0.12.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

lowhaio-0.0.12-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file lowhaio-0.0.12.tar.gz.

File metadata

  • Download URL: lowhaio-0.0.12.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for lowhaio-0.0.12.tar.gz
Algorithm Hash digest
SHA256 967139a0c8f3f515d9687a7ee9acfb351026adac9fb727e9cd0133f088b15dd1
MD5 d0e063a75af2febe074d885dd75cf262
BLAKE2b-256 b36f5a4b51fa102650f9b8b4e5c9b8c4f8fc87cc523899da84f91473f060b964

See more details on using hashes here.

File details

Details for the file lowhaio-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: lowhaio-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for lowhaio-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 e4c8f5c15af82811e81e24e82ee5ef2c83a6bfc8c44a4c4a5828df96d702e806
MD5 8e7564464c7bf41f7033d939fc1a265e
BLAKE2b-256 2e943545232aa03238917dc3883b8a94369591da75ca6a0c4ed84c333fc97162

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