-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to disable chunked transfer-encoding #3864
Conversation
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
b12274e
to
9074b65
Compare
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Jitendra Kumar <[email protected]>
Signed-off-by: Jitendra Kumar <[email protected]>
Signed-off-by: Jitendra Kumar <[email protected]>
Signed-off-by: Jitendra Kumar <[email protected]>
Signed-off-by: Jitendra Kumar <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: dblock <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Codecov Report
@@ Coverage Diff @@
## main #3864 +/- ##
============================================
- Coverage 71.10% 70.51% -0.59%
+ Complexity 57060 56689 -371
============================================
Files 4557 4557
Lines 272681 272726 +45
Branches 40038 40046 +8
============================================
- Hits 193884 192322 -1562
- Misses 62773 64194 +1421
- Partials 16024 16210 +186
Continue to review full report at Codecov.
|
client/rest/src/main/java/org/opensearch/client/RestClient.java
Outdated
Show resolved
Hide resolved
entity = new ContentCompressingEntity(entity); | ||
entity = new ContentCompressingEntity(entity, chunkedTransferEncodingEnabled); | ||
} else { | ||
entity = new ContentHttpEntity(entity, chunkedTransferEncodingEnabled); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably could do if (entity.isChunked() != chunkedTransferEncodingEnabled) { .. }
and do wrapping, otherwise we should be good to go as-is , right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reta by default entity.isChunked returns false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reta by default entity.isChunked returns false
@jiten1551 sorry, not sure I get it, HttpEntity
is an interface, we deal with some of its implementation, where is the default you are referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here NByteArrayEntity is created for all request which extends AbstractHttpEntity which has default fault value of is chunked false as we're not setting it anywhere
https://www.javadoc.io/static/org.apache.httpcomponents/httpcore-nio/4.4.10/org/apache/http/nio/entity/NByteArrayEntity.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not rely on any implementation details here, we deal with interface. Anyway, the question is: why we need to wrap the entity
into ContentHttpEntity
if chunking settings are not changing (true
or false
, does not really matter).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jiten1551 I understand what this flag means:
- if
entity.isChunked() == false
andchunkedTransferEncodingEnabled == false
, why we need to wrap? - if
entity.isChunked() == true
andchunkedTransferEncodingEnabled == true
, why we need to wrap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in those cases we don't need to wrap but the thing is for non-compressed request entity.isChunked is always false
we're trying to give that support of chunking for non-compressed based on chunkedTransferEncodingEnabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in those cases we don't need to wrap
that's what I am suggesting to check here, nothing else (whatever assumptions may be deducted from implementation today may change in the future).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the code to use an Optional
and fallback to the entity.isChunked
. It's a bit messy, lmk what you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it this way better (then dealing with null
s fe)
client/rest/src/main/java/org/opensearch/client/RestClient.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
client/rest/src/main/java/org/opensearch/client/RestClient.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
client/rest/src/main/java/org/opensearch/client/RestClient.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
I was able to verify this. |
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
* fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * adding chunk support for non-compressed request Signed-off-by: Jitendra Kumar <[email protected]> * Diable chunked transfer encoding in integration tests. Signed-off-by: dblock <[email protected]> * Replace chunkedTransferEncodingEnabled with chunkedEnabled. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Make chunkedEnabled optional. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Remove Optional<Boolean> constructor. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Remove optionals from constructors. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Use Optional.empty() Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Use a mode idiomatic syntax in isChunked. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> Co-authored-by: Jitendra Kumar <[email protected]> (cherry picked from commit f7894f7)
* fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * adding chunk support for non-compressed request Signed-off-by: Jitendra Kumar <[email protected]> * Diable chunked transfer encoding in integration tests. Signed-off-by: dblock <[email protected]> * Replace chunkedTransferEncodingEnabled with chunkedEnabled. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Make chunkedEnabled optional. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Remove Optional<Boolean> constructor. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Remove optionals from constructors. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Use Optional.empty() Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Use a mode idiomatic syntax in isChunked. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> Co-authored-by: Jitendra Kumar <[email protected]> (cherry picked from commit f7894f7)
* Add option to disable chunked transfer-encoding (#3864) * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * adding chunk support for non-compressed request Signed-off-by: Jitendra Kumar <[email protected]> * Diable chunked transfer encoding in integration tests. Signed-off-by: dblock <[email protected]> * Replace chunkedTransferEncodingEnabled with chunkedEnabled. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Make chunkedEnabled optional. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Remove Optional<Boolean> constructor. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Remove optionals from constructors. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Use Optional.empty() Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Use a mode idiomatic syntax in isChunked. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> Co-authored-by: Jitendra Kumar <[email protected]> (cherry picked from commit f7894f7) * Use JDK8-compatible implementation. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> Co-authored-by: Daniel (dB.) Doubrovkine <[email protected]>
* fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * fix for bug: #3640 Signed-off-by: Jitendra Kumar <[email protected]> * adding chunk support for non-compressed request Signed-off-by: Jitendra Kumar <[email protected]> * Diable chunked transfer encoding in integration tests. Signed-off-by: dblock <[email protected]> * Replace chunkedTransferEncodingEnabled with chunkedEnabled. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Make chunkedEnabled optional. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Remove Optional<Boolean> constructor. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Remove optionals from constructors. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Use Optional.empty() Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> * Use a mode idiomatic syntax in isChunked. Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> Co-authored-by: Jitendra Kumar <[email protected]> (cherry picked from commit f7894f7) Co-authored-by: Daniel (dB.) Doubrovkine <[email protected]>
Description
The goal is to give users an option to disable chunked transfer encoding for compressed streams which force chunked transfer encoding in the default implementation, which doesn't work for Sigv4.
Issues Resolved
Continuing #3665.
Closes #3640.
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.