From 282173b8c85293ee57bc99de6b1f93bc7d071d1a Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Tue, 29 Oct 2024 19:32:11 +0100 Subject: [PATCH] Always use ms scaled timeouts --- src/HttpClient/HttpClient.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/HttpClient/HttpClient.php b/src/HttpClient/HttpClient.php index 879e570e0..aa5873df3 100644 --- a/src/HttpClient/HttpClient.php +++ b/src/HttpClient/HttpClient.php @@ -64,6 +64,8 @@ public function sendRequest(Request $request, Options $options): Response curl_setopt($curlHandle, \CURLOPT_URL, $dsn->getEnvelopeApiEndpointUrl()); curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, $requestHeaders); curl_setopt($curlHandle, \CURLOPT_USERAGENT, $this->sdkIdentifier . '/' . $this->sdkVersion); + curl_setopt($curlHandle, \CURLOPT_TIMEOUT_MS, $options->getHttpTimeout() * 1000); + curl_setopt($curlHandle, \CURLOPT_CONNECTTIMEOUT_MS, $options->getHttpConnectTimeout() * 1000); curl_setopt($curlHandle, \CURLOPT_ENCODING, ''); curl_setopt($curlHandle, \CURLOPT_POST, true); curl_setopt($curlHandle, \CURLOPT_POSTFIELDS, $requestData); @@ -71,20 +73,6 @@ public function sendRequest(Request $request, Options $options): Response curl_setopt($curlHandle, \CURLOPT_HEADERFUNCTION, $responseHeaderCallback); curl_setopt($curlHandle, \CURLOPT_HTTP_VERSION, \CURL_HTTP_VERSION_1_1); - $httpTimeout = $options->getHttpTimeout(); - if ($httpTimeout < 1.0) { - curl_setopt($curlHandle, \CURLOPT_TIMEOUT_MS, $httpTimeout * 1000); - } else { - curl_setopt($curlHandle, \CURLOPT_TIMEOUT, $httpTimeout); - } - - $connectTimeout = $options->getHttpConnectTimeout(); - if ($connectTimeout < 1.0) { - curl_setopt($curlHandle, \CURLOPT_CONNECTTIMEOUT_MS, $connectTimeout * 1000); - } else { - curl_setopt($curlHandle, \CURLOPT_CONNECTTIMEOUT, $connectTimeout); - } - $httpSslVerifyPeer = $options->getHttpSslVerifyPeer(); if (!$httpSslVerifyPeer) { curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, false);