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

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

Open
sethmlarson opened this issue May 12, 2020 · 0 comments
Open

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

sethmlarson opened this issue May 12, 2020 · 0 comments

Comments

@sethmlarson
Copy link
Contributor

sethmlarson commented May 12, 2020

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:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant