Skip to content

Add simple streaming API #46

Closed
Closed

Description

@clue

An experimental streaming API has been implemented via #31. However, it's quite cumbersome to work with.

In particular, one still has to wait on a promise progress event until one can access a stream object.

Instead, we should add a simple API that returns a stream right away and then emits events on it once the HTTP response comes in.

Activity

  1. clue commented on Sep 4, 2015

    @clue
    OwnerAuthor

    Also take connection hijacking into account for protocols that write outgoing data even after receiving the response headers.

  2. clue commented on Mar 5, 2016

    @clue
    OwnerAuthor

    This feature will likely be resolved with #30. API draft:

    $browser->get($url)->then(function (Response $response) {
        $stream = $response->stream();
    
        $stream->on('data', function ($chunk) {
            echo $chunk;
        });
    });
    
  3. clue commented on Apr 2, 2016

    @clue
    OwnerAuthor

    I've played around with several approaches to a sane streaming API while implementing this via #56:

    • The response could implement the ReadableStreamInterface. This works out reasonably well for the receiving side through the decorator pattern, but does not really fit for outgoing requests.
    • The fetch API offers additional methods and requires a custom Response object which still has to implement the base ResponseInterface. This works out reasonably well for the receiving side through the decorator pattern, but does not really fit for outgoing requests.
    • The fetch API resolves as soon as the headers has been received without waiting for the whole body. This is the main takeaway here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions