Elasticsearch-net: Transfer-Encoding: chunked is enabled by default

Created on 16 Jul 2019  路  5Comments  路  Source: elastic/elasticsearch-net

NEST/Elasticsearch.Net version: 7.0.1

Elasticsearch version: 7.0

Since upgrading from Elasticsearch.Net 7.0.0.alpha to the most current version, all requests made to Elasticsearch are sent with the header "Transfer-Encoding: chunked". Since our Elasticsearch server is behind a reverse proxy, it can no longer pass on the requests. It worked flawlessly with versions 6 and 7 alpha, since this header wasn't included in requests sent through those versions.

I have found no way of disabling this header. Not through the GlobalHeaders() method on the connection settings, nor through a custom HttpConnection. The header is re-added/overwritten at all times.

Is this by design? Is there a workaround available?

PR Pending bug v7.1.0

Most helpful comment

Potential issue in that the advice https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html differs in opinion:

"When possible, consider using HTTP keep alive when connecting for better performance and try to get your favorite client not to do HTTP chunking."

All 5 comments

Thanks for opening, @foleta-developers, this looks like a bug which we'll need to investigate.

This change was introduced in https://github.com/elastic/elasticsearch-net/commit/a525ac8fa5bbac0f387cc14c2689d137d517b893#diff-7dc590a92cd78d1f0749f111402567d8 with the introduction of RequestDataContent which, since it does not return a Computed length for what is written to the request stream, ends up sending with chunked Transfer-Encoding because a Content-Length cannot be computed.

Previously, what ends up being written to the request stream is written first to a StreamContent, backed by a seekable stream from which a Content-length can be computed.

@codebrain @Mpdreamz, I think we ought to make whether chunked Transfer-Encoding is used be configurable

Agreed, although i do believe the new default should remain.

Potential issue in that the advice https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html differs in opinion:

"When possible, consider using HTTP keep alive when connecting for better performance and try to get your favorite client not to do HTTP chunking."

opened #3958 to address

Was this page helpful?
0 / 5 - 0 ratings