in src/OpenSearch/Connections/Connection.php [132:190]
public function __construct(
callable $handler,
array $hostDetails,
array $connectionParams,
SerializerInterface $serializer,
LoggerInterface $log,
LoggerInterface $trace
) {
if (isset($hostDetails['port']) !== true) {
$hostDetails['port'] = 9200;
}
if (isset($hostDetails['scheme'])) {
$this->transportSchema = $hostDetails['scheme'];
}
// Only Set the Basic if API Key is not set and setBasicAuthentication was not called prior
if (isset($connectionParams['client']['headers']['Authorization']) === false
&& isset($connectionParams['client']['curl'][CURLOPT_HTTPAUTH]) === false
&& isset($hostDetails['user'])
&& isset($hostDetails['pass'])
) {
$connectionParams['client']['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_BASIC;
$connectionParams['client']['curl'][CURLOPT_USERPWD] = $hostDetails['user'].':'.$hostDetails['pass'];
}
$connectionParams['client']['curl'][CURLOPT_PORT] = $hostDetails['port'];
if (isset($connectionParams['client']['headers'])) {
$this->headers = $connectionParams['client']['headers'];
unset($connectionParams['client']['headers']);
}
// Add the User-Agent using the format: <client-repo-name>/<client-version> (metadata-values)
$this->headers['User-Agent'] = [sprintf(
'opensearch-php/%s (%s %s; PHP %s)',
Client::VERSION,
PHP_OS,
$this->getOSVersion(),
PHP_VERSION
)];
$host = $hostDetails['host'];
$path = null;
if (isset($hostDetails['path']) === true) {
$path = $hostDetails['path'];
}
$port = $hostDetails['port'];
$this->host = $host;
$this->path = $path;
$this->port = $port;
$this->log = $log;
$this->trace = $trace;
$this->connectionParams = $connectionParams;
$this->serializer = $serializer;
$this->handler = $this->wrapHandler($handler);
}