Skip to content

Commit

Permalink
Merge 51e2623 into ebde220
Browse files Browse the repository at this point in the history
  • Loading branch information
romainneutron committed Nov 13, 2020
2 parents ebde220 + 51e2623 commit 8359af4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Used new mapping endpoints classes [#1845](https://github.com/ruflin/Elastica/pull/1845)
* Used new nodes endpoints classes [#1863](https://github.com/ruflin/Elastica/pull/1863)
* Used new settings endpoints classes [#1852](https://github.com/ruflin/Elastica/pull/1852)
* Allow float values for connection timeout and connection connect-timeout, providing ms precision for those. Previous precision was second. [#1868](https://github.com/ruflin/Elastica/pull/1868)
### Deprecated
* Deprecated `Elastica\Aggregation\Range::setKeyedResponse()`, use `setKeyed()` instead [#1848](https://github.com/ruflin/Elastica/pull/1848)
* Deprecated `Elastica\Exception\ResponseException::getElasticsearchException()`, use `getResponse()::getFullError()` instead [#1829](https://github.com/ruflin/Elastica/pull/1829)
Expand Down
11 changes: 7 additions & 4 deletions src/Transport/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function exec(Request $request, array $params): Response
}

\curl_setopt($conn, \CURLOPT_URL, $baseUri);
\curl_setopt($conn, \CURLOPT_TIMEOUT, $connection->getTimeout());
\curl_setopt($conn, \CURLOPT_TIMEOUT_MS, $connection->getTimeout() * 1000);
\curl_setopt($conn, \CURLOPT_FORBID_REUSE, 0);

// Tell ES that we support the compressed responses
Expand All @@ -85,9 +85,12 @@ public function exec(Request $request, array $params): Response
\curl_setopt($conn, \CURLOPT_ENCODING, '');

/* @see Connection::setConnectTimeout() */
$connectTimeout = $connection->getConnectTimeout();
if ($connectTimeout > 0) {
\curl_setopt($conn, \CURLOPT_CONNECTTIMEOUT, $connectTimeout);
$connectTimeoutMs = $connection->getConnectTimeout() * 1000;

// Let's only apply this value if the number of ms is greater than or equal to "1".
// In case "0" is passed as an argument, the value is reset to its default (300 s)
if ($connectTimeoutMs > 1) {
\curl_setopt($conn, \CURLOPT_CONNECTTIMEOUT_MS, $connectTimeoutMs);
}

if (null !== $proxy = $connection->getProxy()) {
Expand Down

0 comments on commit 8359af4

Please sign in to comment.