Skip to content

Conversation

l-trotta
Copy link
Contributor

This provides a workaround for a bug which affects empty body requests when sent with the Rest5Client configured to support http2.
The issue was introduced server side by elastic/elasticsearch#129302 and results in empty body requests causing the following exception: Invalid media-type value on headers [Accept, Content-Type].

(bonus: log fixes for Rest5Client)

Copy link
Member

@swallez swallez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, once the explanation comment has been added.

@@ -243,25 +243,20 @@ private <RequestT, ResponseT, ErrorT> TransportHttpClient.Request prepareTranspo
Map<String, String> params = endpoint.queryParameters(request);

List<ByteBuffer> bodyBuffers = null;
HeaderMap headers = DefaultHeaders;
HeaderMap headers = JsonContentTypeHeaders;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a note here explaining why we set the content-type even for requests with no body. It will be useful for our future selves!

@swallez
Copy link
Member

swallez commented Aug 22, 2025

Elasticsearch issue that required this fix: elastic/elasticsearch#133408

@l-trotta l-trotta merged commit 9d7e0cf into main Aug 25, 2025
11 checks passed
@l-trotta l-trotta deleted the http2-issue-fix branch August 25, 2025 08:06
github-actions bot pushed a commit that referenced this pull request Aug 25, 2025
* http2 issue workaround

* adding comment
github-actions bot pushed a commit that referenced this pull request Aug 25, 2025
* http2 issue workaround

* adding comment
l-trotta added a commit that referenced this pull request Aug 25, 2025
* http2 issue workaround

* adding comment

Co-authored-by: Laura Trotta <[email protected]>
l-trotta added a commit that referenced this pull request Aug 25, 2025
* http2 issue workaround

* adding comment

Co-authored-by: Laura Trotta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants