Visitar URL original
Support streaming API · Issue #366 · csernazs/pytest-httpserver · GitHub
Skip to content

Support streaming API #366

Open
Open

Description

@hemandev

Hi, first of all, let me say this is a great library, and I've loved using it so far.

I have a use-case where I need to test a streaming API from ChatGPT. Does this library support streaming responses?

I couldn't find anything in the docs, so just checking here.
Thanks!

Activity

  1. csernazs commented on Sep 29, 2024

    @csernazs
    Owner

    hi @hemandev ,

    Thanks! 🙏

    For the first sight, you could try using implementing your own response handler, which is a function accepting a request object and returning a response object.

    https://pytest-httpserver.readthedocs.io/en/latest/howto.html#using-custom-request-handler

    Here, the Response object is provided by werkzeug:
    https://werkzeug.palletsprojects.com/en/3.0.x/wrappers/#werkzeug.wrappers.Response

    ...which allows you to specify an iterable object as response body.

    I haven't made a PoC for this for this yet, but I'd suggest trying this.

    Hope it helps,

    Zsolt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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