File tree 1 file changed +10
-8
lines changed
Filter options
src/Symfony/Component/HttpClient/Response
1 file changed +10
-8
lines changed
Original file line number Diff line number Diff line change @@ -115,15 +115,13 @@ public function getContent(bool $throw = true): string
115
115
return $ content ;
116
116
}
117
117
118
- if ('HEAD ' === $ this ->info ['http_method ' ] || \in_array ($ this ->info ['http_code ' ], [204 , 304 ], true )) {
119
- return '' ;
118
+ if (null === $ this ->content ) {
119
+ throw new TransportException ('Cannot get the content of the response twice: buffering is disabled. ' );
120
+ }
121
+ } else {
122
+ foreach (self ::stream ([$ this ]) as $ chunk ) {
123
+ // Chunks are buffered in $this->content already
120
124
}
121
-
122
- throw new TransportException ('Cannot get the content of the response twice: buffering is disabled. ' );
123
- }
124
-
125
- foreach (self ::stream ([$ this ]) as $ chunk ) {
126
- // Chunks are buffered in $this->content already
127
125
}
128
126
129
127
rewind ($ this ->content );
@@ -376,6 +374,10 @@ public static function stream(iterable $responses, float $timeout = null): \Gene
376
374
377
375
$ chunk = new ErrorChunk ($ response ->offset , $ e );
378
376
} else {
377
+ if (0 === $ response ->offset && null === $ response ->content ) {
378
+ $ response ->content = fopen ('php://memory ' , 'w+ ' );
379
+ }
380
+
379
381
$ chunk = new LastChunk ($ response ->offset );
380
382
}
381
383
} elseif ($ chunk instanceof ErrorChunk) {
You can’t perform that action at this time.
0 commit comments