http icon indicating copy to clipboard operation
http copied to clipboard

unexpected stream closing

Open unglaublicherdude opened this issue 1 year ago • 0 comments

Hi, I already opened a Discussion here, because I am not sure if this is a bug or expected behavious.

You can find the example code in our repository. Basically what I am confused about, is this line becuase after a http-request with a second Browser instance (yes I know, they share the same Loop) the stream from request 1 is closed without me doing anything with it.

        $browser1 = new Browser();
        $browser2 = new Browser();

        $response1 = await($browser1->requestStreaming("GET", "https://secure.eicar.org/eicar.com.txt"));
        $body1 = $response1->getBody();
        $this->assertEquals(true, $body1->isReadable());

        $response2 = await($browser2->requestStreaming("GET", "https://secure.eicar.org/eicar.com.txt"));
        $this->assertEquals(false, $body1->isReadable());
        $body2 = $response2->getBody();
        $this->assertEquals(true, $body2->isReadable());

Is there any way we can prevent that besides just doing a pause() and resume()? That SDK is currently build, so that customers create and provide the stream to our ForStream function, so we don't have that in our hands yet.

If there is now other way, my Idea would be to Wrap provide our own implementation from the ReadableStreamInterface enforcing the a pause on __construct and resume when actually doing something with it.

unglaublicherdude avatar Jul 02 '24 11:07 unglaublicherdude