Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b1e1de7

Browse filesBrowse files
[HttpClient] Always "buffer" empty responses
1 parent 3d39874 commit b1e1de7
Copy full SHA for b1e1de7

File tree

1 file changed

+6
-2
lines changed
Filter options

1 file changed

+6
-2
lines changed

‎src/Symfony/Component/HttpClient/Response/ResponseTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Response/ResponseTrait.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ public function getContent(bool $throw = true): string
115115
return $content;
116116
}
117117

118-
if ('HEAD' === $this->info['http_method'] || \in_array($this->info['http_code'], [204, 304], true)) {
119-
return '';
118+
if (null !== $this->content) {
119+
return $this->getContent(false);
120120
}
121121

122122
throw new TransportException('Cannot get the content of the response twice: buffering is disabled.');
@@ -376,6 +376,10 @@ public static function stream(iterable $responses, float $timeout = null): \Gene
376376

377377
$chunk = new ErrorChunk($response->offset, $e);
378378
} else {
379+
if (0 === $response->offset && null === $response->content) {
380+
$response->content = fopen('php://temp', 'w+');
381+
}
382+
379383
$chunk = new LastChunk($response->offset);
380384
}
381385
} elseif ($chunk instanceof ErrorChunk) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.