Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Add support for Async and Sync Iterators as Request bodies #220

@sethmlarson

Description

@sethmlarson

These two scripts should be allowed to bring us in line with Requests:

def sync_gen():
    yield b"data"

async def async_gen():
    yield b"data"

# ahip supports async and sync iterators

import ahip
import trio

http = ahip.PoolManager()

async def main():
    await http.request("POST", "http://example.com", body=sync_gen())
    await http.request("POST", "http://example.com", body=async_gen())

trio.run(main)

# 'hip' supports only sync

import hip

http = hip.PoolManager()
http.request("POST", "http://example.com", body=sync_gen())

Some notes:

  • Treat both of these cases as errors if a redirect occurs, raise UnrewindableBody exception
  • shouldn't set content-length since length is not known until we drain the body, should be transfer-encoding: chunked

Related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions