You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2020/08/13 01:56:57 UTC

[GitHub] [httpcomponents-core] carterkozak commented on a change in pull request #216: HTTPCORE-645: Increase blocking default chunk size to 8 KiB and reuse chunk buffers

carterkozak commented on a change in pull request #216:
URL: https://github.com/apache/httpcomponents-core/pull/216#discussion_r469651855



##########
File path: httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
##########
@@ -147,13 +149,20 @@ protected OutputStream createContentOutputStream(
         if (len >= 0) {
             return new ContentLengthOutputStream(buffer, outputStream, len);
         } else if (len == ContentLengthStrategy.CHUNKED) {
-            final int chunkSizeHint = http1Config.getChunkSizeHint() >= 0 ? http1Config.getChunkSizeHint() : 2048;
-            return new ChunkedOutputStream(buffer, outputStream, chunkSizeHint, trailers);
+            return new ChunkedOutputStream(buffer, outputStream, getChunkedRequestBuffer(), trailers);
         } else {
             return new IdentityOutputStream(buffer, outputStream);
         }
     }
 
+    private byte[] getChunkedRequestBuffer() {
+        if (chunkedRequestBuffer == null) {
+            final int chunkSizeHint = this.http1Config.getChunkSizeHint();
+            chunkedRequestBuffer = new byte[chunkSizeHint > 0 ? chunkSizeHint : 8192];

Review comment:
       I think this should still be `>= 0` to avoid changing behavior when zero is set, allowing each write to produce a chunk.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org