Skip to content

Commit 6ce65ab

Browse files
stayallivecleptric
andauthored
Use HTTP/1.1 when compression is enabled (#1542)
Co-authored-by: Michael Hoffmann <[email protected]>
1 parent f1a297d commit 6ce65ab

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# CHANGELOG
22

3+
## 3.19.1
4+
5+
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v3.19.1.
6+
7+
### Bug Fixes
8+
9+
- Use HTTP/1.1 when compression is enabled [(#1542)](https://github.com/getsentry/sentry-php/pull/1542)
10+
311
## 3.19.0
412

513
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v3.19.0.

phpstan-baseline.neon

+5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ parameters:
5555
count: 1
5656
path: src/HttpClient/HttpClientFactory.php
5757

58+
-
59+
message: "#^Call to static method createWithConfig\\(\\) on an unknown class Http\\\\Adapter\\\\Guzzle6\\\\Client\\.$#"
60+
count: 1
61+
path: src/HttpClient/HttpClientFactory.php
62+
5863
-
5964
message: "#^Constructor of class Sentry\\\\HttpClient\\\\HttpClientFactory has an unused parameter \\$responseFactory\\.$#"
6065
count: 1

psalm-baseline.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
</PossiblyUndefinedArrayOffset>
1010
</file>
1111
<file src="src/HttpClient/HttpClientFactory.php">
12-
<UndefinedClass occurrences="4">
12+
<UndefinedClass occurrences="5">
13+
<code>Guzzle6HttpClient</code>
1314
<code>GuzzleHttpClientOptions</code>
1415
<code>GuzzleHttpClientOptions</code>
1516
<code>GuzzleHttpClientOptions</code>

src/HttpClient/HttpClientFactory.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
namespace Sentry\HttpClient;
66

77
use GuzzleHttp\RequestOptions as GuzzleHttpClientOptions;
8-
use Http\Adapter\Guzzle6\Client as GuzzleHttpClient;
8+
use Http\Adapter\Guzzle6\Client as Guzzle6HttpClient;
9+
use Http\Adapter\Guzzle7\Client as Guzzle7HttpClient;
910
use Http\Client\Common\Plugin\AuthenticationPlugin;
1011
use Http\Client\Common\Plugin\DecoderPlugin;
1112
use Http\Client\Common\Plugin\ErrorPlugin;
@@ -114,6 +115,7 @@ private function resolveClient(Options $options)
114115
$symfonyConfig = [
115116
'timeout' => $options->getHttpConnectTimeout(),
116117
'max_duration' => $options->getHttpTimeout(),
118+
'http_version' => $options->isCompressionEnabled() ? '1.1' : null,
117119
];
118120

119121
if (null !== $options->getHttpProxy()) {
@@ -123,7 +125,7 @@ private function resolveClient(Options $options)
123125
return new SymfonyHttplugClient(SymfonyHttpClient::create($symfonyConfig));
124126
}
125127

126-
if (class_exists(GuzzleHttpClient::class)) {
128+
if (class_exists(Guzzle7HttpClient::class) || class_exists(Guzzle6HttpClient::class)) {
127129
$guzzleConfig = [
128130
GuzzleHttpClientOptions::TIMEOUT => $options->getHttpTimeout(),
129131
GuzzleHttpClientOptions::CONNECT_TIMEOUT => $options->getHttpConnectTimeout(),
@@ -133,12 +135,17 @@ private function resolveClient(Options $options)
133135
$guzzleConfig[GuzzleHttpClientOptions::PROXY] = $options->getHttpProxy();
134136
}
135137

136-
return GuzzleHttpClient::createWithConfig($guzzleConfig);
138+
if (class_exists(Guzzle7HttpClient::class)) {
139+
return Guzzle7HttpClient::createWithConfig($guzzleConfig);
140+
}
141+
142+
return Guzzle6HttpClient::createWithConfig($guzzleConfig);
137143
}
138144

139145
if (class_exists(CurlHttpClient::class)) {
140146
$curlConfig = [
141147
\CURLOPT_TIMEOUT => $options->getHttpTimeout(),
148+
\CURLOPT_HTTP_VERSION => $options->isCompressionEnabled() ? \CURL_HTTP_VERSION_1_1 : \CURL_HTTP_VERSION_NONE,
142149
\CURLOPT_CONNECTTIMEOUT => $options->getHttpConnectTimeout(),
143150
];
144151

0 commit comments

Comments
 (0)