Skip to content

Commit 097bdd7

Browse files
committed
Merge branch '5.1' into master
* 5.1: fix merge [Cache] fix previous PR 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 [Mailer] Fixed Mailgun API bridge JsonException when API response is not applicaton/json [String] improve fix fix tests [DI] dump OS-indepent paths in the compiled container [DI] dump OS-indepent paths in the preload file Run postgres setup trigger in transaction allow consumers to mock all methods
2 parents 37bf79b + 58546b6 commit 097bdd7

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
@@ -145,6 +145,19 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
145145
}
146146

147147
curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int {
148+
if ('H' === (curl_getinfo($ch, \CURLINFO_PRIVATE)[0] ?? null)) {
149+
$multi->handlesActivity[$id][] = null;
150+
$multi->handlesActivity[$id][] = new TransportException(sprintf('Unsupported protocol for "%s"', curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL)));
151+
152+
return 0;
153+
}
154+
155+
curl_setopt($ch, \CURLOPT_WRITEFUNCTION, static function ($ch, string $data) use ($multi, $id): int {
156+
$multi->handlesActivity[$id][] = $data;
157+
158+
return \strlen($data);
159+
});
160+
148161
$multi->handlesActivity[$id][] = $data;
149162

150163
return \strlen($data);

Response/TransportResponseTrait.php

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

118118
if (!$info['http_code']) {
119-
throw new TransportException('Invalid or missing HTTP status line.');
119+
throw new TransportException(sprintf('Invalid or missing HTTP status line for "%s".', implode('', $info['url'])));
120120
}
121121
}
122122

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

182182
if (\is_string($chunk = array_shift($multi->handlesActivity[$j]))) {
183183
if (null !== $response->inflate && false === $chunk = @inflate_add($response->inflate, $chunk)) {
184-
$multi->handlesActivity[$j] = [null, new TransportException('Error while processing content unencoding.')];
184+
$multi->handlesActivity[$j] = [null, new TransportException(sprintf('Error while processing content unencoding for "%s".', $response->getInfo('url')))];
185185
continue;
186186
}
187187

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)