Skip to content

Commit 93f0673

Browse files
authored
Always use ms scaled timeouts (#1785)
1 parent af7955a commit 93f0673

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/HttpClient/HttpClient.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,15 @@ public function sendRequest(Request $request, Options $options): Response
6464
curl_setopt($curlHandle, \CURLOPT_URL, $dsn->getEnvelopeApiEndpointUrl());
6565
curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, $requestHeaders);
6666
curl_setopt($curlHandle, \CURLOPT_USERAGENT, $this->sdkIdentifier . '/' . $this->sdkVersion);
67+
curl_setopt($curlHandle, \CURLOPT_TIMEOUT_MS, $options->getHttpTimeout() * 1000);
68+
curl_setopt($curlHandle, \CURLOPT_CONNECTTIMEOUT_MS, $options->getHttpConnectTimeout() * 1000);
6769
curl_setopt($curlHandle, \CURLOPT_ENCODING, '');
6870
curl_setopt($curlHandle, \CURLOPT_POST, true);
6971
curl_setopt($curlHandle, \CURLOPT_POSTFIELDS, $requestData);
7072
curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true);
7173
curl_setopt($curlHandle, \CURLOPT_HEADERFUNCTION, $responseHeaderCallback);
7274
curl_setopt($curlHandle, \CURLOPT_HTTP_VERSION, \CURL_HTTP_VERSION_1_1);
7375

74-
$httpTimeout = $options->getHttpTimeout();
75-
if ($httpTimeout < 1.0) {
76-
curl_setopt($curlHandle, \CURLOPT_TIMEOUT_MS, $httpTimeout * 1000);
77-
} else {
78-
curl_setopt($curlHandle, \CURLOPT_TIMEOUT, $httpTimeout);
79-
}
80-
81-
$connectTimeout = $options->getHttpConnectTimeout();
82-
if ($connectTimeout < 1.0) {
83-
curl_setopt($curlHandle, \CURLOPT_CONNECTTIMEOUT_MS, $connectTimeout * 1000);
84-
} else {
85-
curl_setopt($curlHandle, \CURLOPT_CONNECTTIMEOUT, $connectTimeout);
86-
}
87-
8876
$httpSslVerifyPeer = $options->getHttpSslVerifyPeer();
8977
if (!$httpSslVerifyPeer) {
9078
curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, false);

0 commit comments

Comments
 (0)