Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aiohttp have empty body when body is a io-like object #907

Open
tito opened this issue Jan 22, 2025 · 0 comments
Open

aiohttp have empty body when body is a io-like object #907

tito opened this issue Jan 22, 2025 · 0 comments

Comments

@tito
Copy link

tito commented Jan 22, 2025

When using aiohttp and sending a open file as a body (here as io.BytesIO), when using VCR.py, the initial Request construction is consuming the body, so when aiohttp is getting the data, it's empty as VCR.py don't seek back.

@vcr.use_cassette("issue_vcr_aiohttp.yaml")
def test():
    test = io.BytesIO(b"hello")
    async with aiohttp.ClientSession() as session:
        async with session.post("https://httpbin.org/post", data=test, json=None) as response:
            ret = await response.json()
            assert ret["data"] == "hello"

Here is a PR #906 that fix this issue, by ensuring the body is seek back after reading.

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

No branches or pull requests

1 participant