How to modify http headers sent with an elasticsearch request?
See original GitHub issueI’ve searched the documentation/internet and cannot find an answer to this question. How do I pass in extra headers to http requests in say methods like elasticsearch.Elasticsearch.search
? Well really it would be most convenient if I could just do it once at say instantiation of elasticsearch.Elasticsearch
…
How is this most easily achieved?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
HTTP/REST clients and security | Elasticsearch Guide [master]
Some APIs support secondary authorization headers for situations where you want tasks to run with a different set of credentials. For example, you...
Read more >Send Headers in HTTP post request - Beats - Elastic Discuss
Hi All, I am not able to send additional headers in the http POST request. yml file heartbeat.monitors: - type: http # List...
Read more >API conventions | Elasticsearch Guide [8.5] | Elastic
Elasticsearch ignores any other encoding headings sent with a request. Responses are also UTF-8 encoded. X-Opaque-Id HTTP headeredit. You can pass an X-Opaque- ......
Read more >Strict Content-Type Checking for Elasticsearch REST Requests
This ability to enforce strict content-type checking has existed since Elasticsearch 5.3 via the http.content_type.required configuration ...
Read more >Performing requests | Elasticsearch Java API Client [7.17]
addHeader is for headers that are required for authorization or to work with a proxy in front of Elasticsearch. There is no need...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Currently there is no direct way to inject your own headers. What I recommend is to subclass the connection class and modify the headers there:
Unfortunately there is no easy way to do this on a per-api basis.
Hope this helps.
Thanks for the snippet @HonzaKral For anyone looking at this in future, I modified his code to allow sending a custom header with a value set at request time:
internal_params
is a dict whose keys are the param keys inparams
and values are the header their value should be placed in.