-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Make native stream support non blocking mode #35187
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,28 @@ protected function getHttpClient(string $testCase): HttpClientInterface | |
return new NativeHttpClient(); | ||
} | ||
|
||
public function testItCanBeNonBlockingStream() | ||
{ | ||
$client = $this->getHttpClient(__FUNCTION__); | ||
$response = $client->request('GET', 'http://localhost:8057'); | ||
$stream = $response->toStream(); | ||
|
||
$this->assertTrue(stream_get_meta_data($stream)['blocked']); | ||
$this->assertTrue(stream_set_blocking($stream, 0)); | ||
|
||
// Help wanted. I've no idea why this test does not pass. | ||
// $this->assertFalse(stream_get_meta_data($stream)['blocked']); | ||
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've no idea where data from It looks like default values are always returned while using a streamwrapper ?! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, we cannot define these when using stream wrappers. |
||
|
||
$read = [$stream]; | ||
$write = []; | ||
$except = []; | ||
$streamFound = stream_select($read, $write, $except, null, 0); | ||
|
||
$this->assertEquals(1, $streamFound); | ||
$this->assertIsArray(json_decode(stream_get_contents($stream), true)); | ||
$this->assertTrue(feof($stream)); | ||
} | ||
|
||
public function testInformationalResponseStream() | ||
{ | ||
$this->markTestSkipped('NativeHttpClient doesn\'t support informational status codes.'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP will trigger fatal error because we return false. But I think more precision is a good thing.