Have you searched for similar issues before submitting this one? Yes.
Is this a bug, question or feature request? Feature request.
Describe the issue you encountered:
Our ElasticSearch servers are configured to provide an "X-ElasticSearch-Server: $hostname" header with all HTTP responses. This helps us identify which server responded and debug when needed. It would be useful if we could define these custom headers in wp-config.php and have ElasticPress include them with the standard X-ElasticPress-Search header.
Current WordPress version: 4.8.2
Current ElasticPress version: 2.3.2
Current Elasticsearch version: 5.6.1
Where do you host your Elasticsearch server: Self-hosted.
Other plugins installed (WooCommerce, Simple Redirect Manager, etc..): WooCommerce
@tlovett1 I'm assigning this one to you to decide what to do with this.
Hi @ahmed-sigmalux!
what you need is an ad-hoc solution and we are likely not going to implement it as of now because the majority of users won't need it. I would like to suggest you add a hook for ep_remote_request action and send that header manually. It can be something like this:
function send_ep_server_header( $query ) {
if ( ! headers_sent() ) {
$server = wp_remote_retrieve_header( $query['request'], 'X-ElasticSearch-Server' );
if ( ! empty( $server ) ) {
header( "X-ElasticSearch-Server: {$server}" );
}
}
}
add_action( 'ep_remote_request', 'send_ep_server_header' );
I am going to close this ticket for now, but if you still have questions, feel free to re-open it.
Most helpful comment
Hi @ahmed-sigmalux!
what you need is an ad-hoc solution and we are likely not going to implement it as of now because the majority of users won't need it. I would like to suggest you add a hook for
ep_remote_requestaction and send that header manually. It can be something like this:I am going to close this ticket for now, but if you still have questions, feel free to re-open it.