Skip to content

Commit 29d81a5

Browse files
committed
Fixed x-elastic-client-meta header with lowercase value
1 parent e38746f commit 29d81a5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Elasticsearch/Connections/Connection.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,21 +583,26 @@ protected function getCurlRetryException(array $request, array $response): Elast
583583

584584
/**
585585
* Get the x-elastic-client-meta header
586+
*
587+
* The header format is specified by the following regex:
588+
* ^[a-z]{1,}=[a-z0-9\.\-]{1,}(?:,[a-z]{1,}=[a-z0-9\.\-]+)*$
586589
*/
587590
private function getElasticMetaHeader(array $connectionParams): string
588591
{
589592
$phpSemVersion = sprintf("%d.%d.%d", PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION);
593+
// Reduce the size in case of '-snapshot' version
594+
$clientVersion = str_replace('-snapshot', '-s', strtolower(Client::VERSION));
590595
$clientMeta = sprintf(
591596
"es=%s,php=%s,t=%s,a=%d",
592-
Client::VERSION,
597+
$clientVersion,
593598
$phpSemVersion,
594-
Client::VERSION,
599+
$clientVersion,
595600
isset($connectionParams['client']['future']) && $connectionParams['client']['future'] === 'lazy' ? 1 : 0
596601
);
597602
if (function_exists('curl_version')) {
598603
$curlVersion = curl_version();
599604
if (isset($curlVersion['version'])) {
600-
$clientMeta .= sprintf(",c=%s", $curlVersion['version']);
605+
$clientMeta .= sprintf(",cu=%s", $curlVersion['version']); // cu = curl library
601606
}
602607
}
603608
return $clientMeta;

0 commit comments

Comments
 (0)