Skip to content

Commit 47916cd

Browse files
ezimuelszabosteve
andcommitted
[7.x] [DOCS] Added the HTTP meta data section (#1143)
* Added the HTTP meta data section * Update docs/http-meta-data.asciidoc Co-authored-by: István Zoltán Szabó <[email protected]> * Update docs/http-meta-data.asciidoc Co-authored-by: István Zoltán Szabó <[email protected]> * Update docs/http-meta-data.asciidoc Co-authored-by: István Zoltán Szabó <[email protected]> * Update docs/http-meta-data.asciidoc Co-authored-by: István Zoltán Szabó <[email protected]> * Update docs/http-meta-data.asciidoc Co-authored-by: István Zoltán Szabó <[email protected]> * Update docs/http-meta-data.asciidoc Co-authored-by: István Zoltán Szabó <[email protected]> * Update docs/http-meta-data.asciidoc Co-authored-by: István Zoltán Szabó <[email protected]> * Update docs/http-meta-data.asciidoc Co-authored-by: István Zoltán Szabó <[email protected]> Co-authored-by: István Zoltán Szabó <[email protected]>
1 parent a5d8b7c commit 47916cd

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

docs/configuration.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ check sample code that helps you replace the various components.
1111

1212
* <<host-config>>
1313
* <<set-retries>>
14+
* <<http-meta-data>>
1415
* <<enabling_logger>>
1516
* <<http-handler-config>>
1617
* <<namespaces>>
@@ -28,6 +29,8 @@ include::host-config.asciidoc[]
2829

2930
include::set-retries.asciidoc[]
3031

32+
include::http-meta-data.asciidoc[]
33+
3134
include::logger.asciidoc[]
3235

3336
include::http-handler.asciidoc[]

docs/http-meta-data.asciidoc

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[[http-meta-data]]
2+
=== HTTP Meta Data
3+
4+
By default, the client sends some meta data about the HTTP connection using
5+
custom headers.
6+
7+
You can disable or enable it using the following methods:
8+
9+
10+
==== Elastic Meta Header
11+
12+
The client sends a `x-elastic-client-meta` header by default.
13+
This header is used to collect meta data about the versions of the components
14+
used by the client. For instance, a value of `x-elastic-client-meta` can be
15+
`es=7.14.0-s,php=7.4.11,t=7.14.0-s,a=0,cu=7.68.0`, where each value is the
16+
version of `es=Elasticsearch`, `t` is the transport version (same of client),
17+
`a` is asyncronouts (`0=false` by default) and `cu=cURL`.
18+
19+
If you would like to disable it you can use the `setElasticMetaHeader()`
20+
method, as follows:
21+
22+
[source,php]
23+
----
24+
$client = Elasticsearch\ClientBuilder::create()
25+
->setElasticMetaHeader(false)
26+
->build();
27+
----
28+
29+
==== Include port number in Host header
30+
31+
This is a special setting for the client that enables the port in the
32+
Host header. This setting has been introduced to prevent issues with
33+
HTTP proxy layers (see issue https://github.com/elastic/elasticsearch-php/issues/993[#993]).
34+
35+
By default the port number is not included in the Host header.
36+
If you want you can enable it using the `includePortInHostHeader()` function,
37+
as follows:
38+
39+
[source,php]
40+
----
41+
$client = Elasticsearch\ClientBuilder::create()
42+
->includePortInHostHeader(true)
43+
->build();
44+
----
45+
46+
==== Send the API compatibility layer
47+
48+
Starting from version 7.13, {es} supports a compatibility header in
49+
`Content-Type` and `Accept`. The PHP client can be configured to emit the following HTTP headers:
50+
51+
[source]
52+
----
53+
Content-Type: application/vnd.elasticsearch+json; compatible-with=7
54+
Accept: application/vnd.elasticsearch+json; compatible-with=7
55+
----
56+
57+
which signals to {es} that the client is requesting 7.x version of request and response
58+
bodies. This allows upgrading from 7.x to 8.x version of Elasticsearch without upgrading
59+
everything at once. {es} should be upgraded first after the compatibility header is
60+
configured and clients should be upgraded second.
61+
62+
To enable this compatibility header, you need to create an `ELASTIC_CLIENT_APIVERSIONING`
63+
environment variable and set it to `true` or `1`, before the `Client` class initialization.
64+
65+
In PHP you can set this environment variable as follows:
66+
67+
[source,php]
68+
----
69+
putenv("ELASTIC_CLIENT_APIVERSIONING=true");
70+
----

0 commit comments

Comments
 (0)