Skip to content

Streaming Response Body #274

@qthequartermasterman

Description

@qthequartermasterman

Is there a way to stream a response body? I need to mock an OpenAI-compatible API streaming call. I can do this mock quite easily with pytest-httpx, but I need to add an aiohttp-powered backend to my application, so I now need to do that mock in a way that aiohttp can use it.

It looks like #271 will add support for streaming requests, but I don't see a corresponding way of mocking streaming responses. I see that internally, aioresponses creates a stream reader, but then feeds the body directly into the stream and closes it. Unfortunately, because body is str|bytes, I don't see a way of forcing the stream to return chunks.

Is there a way to stream a mocked response body?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions