@@ -43,13 +43,9 @@ class StreamWrapper
43
43
/**
44
44
* Creates a PHP stream resource from a ResponseInterface.
45
45
*
46
- * @param resource|null $contentBuffer The seekable resource where the response body is buffered
47
- * @param resource|null $selectHandle The resource handle that should be monitored when
48
- * stream_select() is used on the created stream
49
- *
50
46
* @return resource
51
47
*/
52
- public static function createResource (ResponseInterface $ response , HttpClientInterface $ client = null , $ contentBuffer = null , $ selectHandle = null )
48
+ public static function createResource (ResponseInterface $ response , HttpClientInterface $ client = null )
53
49
{
54
50
if (null === $ client && !method_exists ($ response , 'stream ' )) {
55
51
throw new \InvalidArgumentException (sprintf ('Providing a client to "%s()" is required when the response doesn \'t have any "stream()" method. ' , __CLASS__ ));
@@ -63,8 +59,6 @@ public static function createResource(ResponseInterface $response, HttpClientInt
63
59
$ context = [
64
60
'client ' => $ client ?? $ response ,
65
61
'response ' => $ response ,
66
- 'content ' => $ contentBuffer ,
67
- 'handle ' => $ selectHandle ,
68
62
];
69
63
70
64
return fopen ('symfony:// ' .$ response ->getInfo ('url ' ), 'r ' , false , stream_context_create (['symfony ' => $ context ])) ?: null ;
@@ -78,6 +72,17 @@ public function getResponse(): ResponseInterface
78
72
return $ this ->response ;
79
73
}
80
74
75
+ /**
76
+ * @param resource|null $handle The resource handle that should be monitored when
77
+ * stream_select() is used on the created stream
78
+ * @param resource|null $content The seekable resource where the response body is buffered
79
+ */
80
+ public function bindHandles (&$ handle , &$ content ): void
81
+ {
82
+ $ this ->handle = &$ handle ;
83
+ $ this ->content = &$ content ;
84
+ }
85
+
81
86
public function stream_open (string $
C6A6
span>path , string $ mode , int $ options ): bool
82
87
{
83
88
if ('r ' !== $ mode ) {
@@ -91,8 +96,6 @@ public function stream_open(string $path, string $mode, int $options): bool
91
96
$ context = stream_context_get_options ($ this ->context )['symfony ' ] ?? null ;
92
97
$ this ->client = $ context ['client ' ] ?? null ;
93
98
$ this ->response = $ context ['response ' ] ?? null ;
94
- $ this ->content = $ context ['content ' ] ?? null ;
95
- $ this ->handle = $ context ['handle ' ] ?? null ;
96
99
$ this ->context = null ;
97
100
98
101
if (null !== $ this ->client && null !== $ this ->response ) {
@@ -238,6 +241,8 @@ public function stream_seek(int $offset, int $whence = SEEK_SET): bool
238
241
public function stream_cast (int $ castAs )
239
242
{
240
243
if (STREAM_CAST_FOR_SELECT === $ castAs ) {
244
+ $ this ->response ->getHeaders (false );
245
+
241
246
return $ this ->handle ?? false ;
242
247
}
243
248
0 commit comments