[HttpClient] fix using stream_copy_to_stream() with responses cast to php streams
This commit is contained in:
parent
3d1c59ae7f
commit
cf1404a30b
@ -281,7 +281,7 @@ class StreamWrapper
|
|||||||
'uid' => 0,
|
'uid' => 0,
|
||||||
'gid' => 0,
|
'gid' => 0,
|
||||||
'rdev' => 0,
|
'rdev' => 0,
|
||||||
'size' => (int) ($headers['content-length'][0] ?? 0),
|
'size' => (int) ($headers['content-length'][0] ?? -1),
|
||||||
'atime' => 0,
|
'atime' => 0,
|
||||||
'mtime' => strtotime($headers['last-modified'][0] ?? '') ?: 0,
|
'mtime' => strtotime($headers['last-modified'][0] ?? '') ?: 0,
|
||||||
'ctime' => 0,
|
'ctime' => 0,
|
||||||
|
@ -63,6 +63,19 @@ abstract class HttpClientTestCase extends BaseHttpClientTestCase
|
|||||||
$this->assertTrue(feof($stream));
|
$this->assertTrue(feof($stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testStreamCopyToStream()
|
||||||
|
{
|
||||||
|
$client = $this->getHttpClient(__FUNCTION__);
|
||||||
|
$response = $client->request('GET', 'http://localhost:8057');
|
||||||
|
$h = fopen('php://temp', 'w+');
|
||||||
|
stream_copy_to_stream($response->toStream(), $h);
|
||||||
|
|
||||||
|
$this->assertTrue(rewind($h));
|
||||||
|
$this->assertSame("{\n \"SER", fread($h, 10));
|
||||||
|
$this->assertSame('VER_PROTOCOL', fread($h, 12));
|
||||||
|
$this->assertFalse(feof($h));
|
||||||
|
}
|
||||||
|
|
||||||
public function testToStream404()
|
public function testToStream404()
|
||||||
{
|
{
|
||||||
$client = $this->getHttpClient(__FUNCTION__);
|
$client = $this->getHttpClient(__FUNCTION__);
|
||||||
|
Reference in New Issue
Block a user