8000 bug #57569 [HttpClient][Mailer] Revert "Let curl handle transfer enco… · symfony/symfony@792c027 · GitHub
[go: up one dir, main page]

Skip to content

Commit 792c027

Browse files
bug #57569 [HttpClient][Mailer] Revert "Let curl handle transfer encoding", use HTTP/1.1 for Mailgun (nicolas-grekas)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [HttpClient][Mailer] Revert "Let curl handle transfer encoding", use HTTP/1.1 for Mailgun | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #57544 | License | MIT This PR reverts #54517 and fixes #54491 by forcing HTTP/1.1 when talking to Mailgun The issue that #54517 tries to fix shouldn't happen since curl 7.51, which dates back from 2016 (curl/curl@d4c5a91). If you experience it, try upgrading. The previous code worked fine for years but the new one generated reports a few weeks after its release so I'd feel more confident reverting. Commits ------- efc93cd [HttpClient][Mailer] Revert "Let curl handle transfer encoding", use HTTP/1.1 for Mailgun
2 parents ef3d8e7 + efc93cd commit 792c027

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@ public function request(string $method, string $url, array $options = []): Respo
246246

247247
if (isset($options['normalized_headers']['content-length'][0])) {
248248
$curlopts[\CURLOPT_INFILESIZE] = (int) substr($options['normalized_headers']['content-length'][0], \strlen('Content-Length: '));
249-
} elseif (!isset($options['normalized_headers']['transfer-encoding'])) {
250-
$curlopts[\CURLOPT_INFILESIZE] = -1;
249+
}
250+
if (!isset($options['normalized_headers']['transfer-encoding'])) {
251+
$curlopts[\CURLOPT_HTTPHEADER][] = 'Transfer-Encoding:'.(isset($curlopts[\CURLOPT_INFILESIZE]) ? '' : ' chunked');
251252
}
252253

253254
if ('POST' !== $method) {

src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunHttpTransport.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
6363

6464
$endpoint = sprintf('%s/v3/%s/messages.mime', $this->getEndpoint(), urlencode($this->domain));
6565
$response = $this->client->request('POST', 'https://'.$endpoint, [
66+
'http_version' => '1.1',
6667
'auth_basic' => 'api:'.$this->key,
6768
'headers' => $headers,
6869
'body' => $body->bodyToIterable(),

0 commit comments

Comments
 (0)
0