Skip to content

Commit 58546b6

Browse files
Merge branch '4.4' into 5.1
* 4.4: add mising sr (latn & cyrl) translations [Cache] fix ProxyAdapter not persisting items with infinite expiration [HttpClient] fail properly when the server replies with HTTP/0.9 Fix CS [Cache] Limit cache version character range [DI] dump OS-indepent paths in the compiled container allow consumers to mock all methods
2 parents d647270 + acbfed6 commit 58546b6

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

Response/CurlResponse.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
123123
}
124124

125125
curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int {
126+
if ('H' === (curl_getinfo($ch, \CURLINFO_PRIVATE)[0] ?? null)) {
127+
$multi->handlesActivity[$id][] = null;
128+
$multi->handlesActivity[$id][] = new TransportException(sprintf('Unsupported protocol for "%s"', curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL)));
129+
130+
return 0;
131+
}
132+
133+
curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int {
134+
$multi->handlesActivity[$id][] = $data;
135+
136+
return \strlen($data);
137+
});
138+
126139
$multi->handlesActivity[$id][] = $data;
127140

128141
return \strlen($data);

Response/ResponseTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ private static function addResponseHeaders(array $responseHeaders, array &$info,
270270
$debug .= "< \r\n";
271271

272272
if (!$info['http_code']) {
273-
throw new TransportException('Invalid or missing HTTP status line.');
273+
throw new TransportException(sprintf('Invalid or missing HTTP status line for "%s".', implode('', $info['url'])));
274274
}
275275
}
276276

@@ -350,7 +350,7 @@ public static function stream(iterable $responses, float $timeout = null): \Gene
350350

351351
if (\is_string($chunk = array_shift($multi->handlesActivity[$j]))) {
352352
if (null !== $response->inflate && false === $chunk = @inflate_add($response->inflate, $chunk)) {
353-
$multi->handlesActivity[$j] = [null, new TransportException('Error while processing content unencoding.')];
353+
$multi->handlesActivity[$j] = [null, new TransportException(sprintf('Error while processing content unencoding for "%s".', $response->getInfo('url')))];
354354
continue;
355355
}
356356

Tests/CachingHttpClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testRemovesXContentDigest()
8989
'test', [
9090
'response_headers' => [
9191
'X-Content-Digest' => 'some-hash',
92-
]
92+
],
9393
]));
9494
$headers = $response->getHeaders();
9595

@@ -100,7 +100,7 @@ private function runRequest(MockResponse $mockResponse): ResponseInterface
100100
{
101101
$mockClient = new MockHttpClient($mockResponse);
102102

103-
$store = new Store(sys_get_temp_dir() . '/sf_http_cache');
103+
$store = new Store(sys_get_temp_dir().'/sf_http_cache');
104104
$client = new CachingHttpClient($mockClient, $store);
105105

106106
$response = $client->request('GET', 'http://test');

0 commit comments

Comments
 (0)