Commit e0b3615 1 parent 303e408 commit e0b3615 Copy full SHA for e0b3615
File tree 2 files changed +26
-1
lines changed
client/rest/src/main/java/org/opensearch/client
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 36
36
import org .apache .http .ConnectionClosedException ;
37
37
import org .apache .http .Header ;
38
38
import org .apache .http .HttpEntity ;
39
+ import org .apache .http .entity .HttpEntityWrapper ;
39
40
import org .apache .http .HttpHost ;
40
41
import org .apache .http .HttpRequest ;
41
42
import org .apache .http .HttpResponse ;
@@ -644,6 +645,8 @@ private static HttpRequestBase addRequestBody(
644
645
} else {
645
646
entity = new ContentCompressingEntity (entity );
646
647
}
648
+ } else if (chunkedTransferEncodingEnabled ) {
649
+ entity = new ChunkedHttpEntity (entity );
647
650
}
648
651
((HttpEntityEnclosingRequestBase ) httpRequest ).setEntity (entity );
649
652
} else {
@@ -1045,6 +1048,28 @@ public long getContentLength() {
1045
1048
}
1046
1049
}
1047
1050
1051
+ public static class ChunkedHttpEntity extends HttpEntityWrapper {
1052
+ /**
1053
+ * Creates a {@link ChunkedHttpEntity} instance with the provided HTTP entity.
1054
+ *
1055
+ * @param entity the HTTP entity.
1056
+ */
1057
+ public ChunkedHttpEntity (HttpEntity entity ) {
1058
+ super (entity );
1059
+ }
1060
+
1061
+ /**
1062
+ * A chunked entity requires transfer-encoding:chunked in http headers
1063
+ * which requires isChunked to be true
1064
+ *
1065
+ * @return true
1066
+ */
1067
+ @ Override
1068
+ public boolean isChunked () {
1069
+ return true ;
1070
+ }
1071
+ }
1072
+
1048
1073
/**
1049
1074
* A ByteArrayOutputStream that can be turned into an input stream without copying the underlying buffer.
1050
1075
*/
Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ public RestClientBuilder setCompressionEnabled(boolean compressionEnabled) {
240
240
}
241
241
242
242
/**
243
- * Whether the REST client should use Transfer-Encoding: chunked for compress requests"
243
+ * Whether the REST client should use Transfer-Encoding: chunked for requests or not "
244
244
*
245
245
* @param chunkedTransferEncodingEnabled flag for enabling Transfer-Encoding: chunked
246
246
*/
You can’t perform that action at this time.
0 commit comments