You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2016/12/11 14:51:20 UTC

svn commit: r1773574 [1/2] - in /httpcomponents/httpcore/trunk: httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ httpcore5/src/main/java/org/apache/hc/core5/http/config/ httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ http...

Author: olegk
Date: Sun Dec 11 14:51:19 2016
New Revision: 1773574

URL: http://svn.apache.org/viewvc?rev=1773574&view=rev
Log:
HTTPCORE-413: Minimal chunk side can now be specified as H1Config#chunkSizeHint. The value is treated as a hint. Both classic and NIO attempt to apply it when sending / receiving messages without providing a strict guarantee.

Modified:
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/ConnectionConfig.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/AbstractMessageParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnectionFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnectionFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParserFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParserFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionOutputBufferImpl.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkDecoder.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkEncoder.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParserFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParserFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/IdentityEncoder.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/LengthDelimitedEncoder.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/HttpMessageParserFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/NHttpMessageParserFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkDecoder.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityDecoder.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedDecoder.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpClientConnection.java Sun Dec 11 14:51:19 2016
@@ -58,16 +58,15 @@ public class LoggingBHttpClientConnectio
 
     public LoggingBHttpClientConnection(
             final int buffersize,
-            final int fragmentSizeHint,
             final CharsetDecoder chardecoder,
             final CharsetEncoder charencoder,
-            final H1Config constraints,
+            final H1Config h1Config,
             final ContentLengthStrategy incomingContentStrategy,
             final ContentLengthStrategy outgoingContentStrategy,
             final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
             final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
-        super(buffersize, fragmentSizeHint, chardecoder, charencoder,
-                constraints, incomingContentStrategy, outgoingContentStrategy,
+        super(buffersize, chardecoder, charencoder,
+                h1Config, incomingContentStrategy, outgoingContentStrategy,
                 requestWriterFactory, responseParserFactory);
         this.id = "http-outgoing-" + COUNT.incrementAndGet();
         this.log = LogManager.getLogger(getClass());
@@ -76,7 +75,7 @@ public class LoggingBHttpClientConnectio
     }
 
     public LoggingBHttpClientConnection(final int buffersize) {
-        this(buffersize, buffersize, null, null, null, null, null, null, null);
+        this(buffersize, null, null, null, null, null, null, null);
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/LoggingBHttpServerConnection.java Sun Dec 11 14:51:19 2016
@@ -57,15 +57,14 @@ public class LoggingBHttpServerConnectio
 
     public LoggingBHttpServerConnection(
             final int buffersize,
-            final int fragmentSizeHint,
             final CharsetDecoder chardecoder,
             final CharsetEncoder charencoder,
-            final H1Config constraints,
+            final H1Config h1Config,
             final ContentLengthStrategy incomingContentStrategy,
             final ContentLengthStrategy outgoingContentStrategy,
             final HttpMessageParserFactory<ClassicHttpRequest> requestParserFactory,
             final HttpMessageWriterFactory<ClassicHttpResponse> responseWriterFactory) {
-        super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints,
+        super(buffersize, chardecoder, charencoder, h1Config,
                 incomingContentStrategy, outgoingContentStrategy,
                 requestParserFactory, responseWriterFactory);
         this.id = "http-incoming-" + COUNT.incrementAndGet();
@@ -75,7 +74,7 @@ public class LoggingBHttpServerConnectio
     }
 
     public LoggingBHttpServerConnection(final int buffersize) {
-        this(buffersize, buffersize, null, null, null, null, null, null, null);
+        this(buffersize, null, null, null, null, null, null, null);
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/ConnectionConfig.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/ConnectionConfig.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/ConnectionConfig.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/ConnectionConfig.java Sun Dec 11 14:51:19 2016
@@ -46,20 +46,17 @@ public class ConnectionConfig {
     public static final ConnectionConfig DEFAULT = new Builder().build();
 
     private final int bufferSize;
-    private final int fragmentSizeHint;
     private final Charset charset;
     private final CodingErrorAction malformedInputAction;
     private final CodingErrorAction unmappableInputAction;
 
     ConnectionConfig(
             final int bufferSize,
-            final int fragmentSizeHint,
             final Charset charset,
             final CodingErrorAction malformedInputAction,
             final CodingErrorAction unmappableInputAction) {
         super();
         this.bufferSize = bufferSize;
-        this.fragmentSizeHint = fragmentSizeHint;
         this.charset = charset;
         this.malformedInputAction = malformedInputAction;
         this.unmappableInputAction = unmappableInputAction;
@@ -69,10 +66,6 @@ public class ConnectionConfig {
         return bufferSize;
     }
 
-    public int getFragmentSizeHint() {
-        return fragmentSizeHint;
-    }
-
     public Charset getCharset() {
         return charset;
     }
@@ -89,7 +82,6 @@ public class ConnectionConfig {
     public String toString() {
         final StringBuilder builder = new StringBuilder();
         builder.append("[bufferSize=").append(this.bufferSize)
-                .append(", fragmentSizeHint=").append(this.fragmentSizeHint)
                 .append(", charset=").append(this.charset)
                 .append(", malformedInputAction=").append(this.malformedInputAction)
                 .append(", unmappableInputAction=").append(this.unmappableInputAction)
@@ -106,7 +98,6 @@ public class ConnectionConfig {
         return new Builder()
             .setBufferSize(config.getBufferSize())
             .setCharset(config.getCharset())
-            .setFragmentSizeHint(config.getFragmentSizeHint())
             .setMalformedInputAction(config.getMalformedInputAction())
             .setUnmappableInputAction(config.getUnmappableInputAction());
     }
@@ -160,10 +151,8 @@ public class ConnectionConfig {
                 cs = StandardCharsets.US_ASCII;
             }
             final int bufSize = this.bufferSize > 0 ? this.bufferSize : 8 * 1024;
-            final int fragmentHintSize  = this.fragmentSizeHint >= 0 ? this.fragmentSizeHint : bufSize;
             return new ConnectionConfig(
                     bufSize,
-                    fragmentHintSize,
                     cs,
                     malformedInputAction,
                     unmappableInputAction);

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java Sun Dec 11 14:51:19 2016
@@ -43,19 +43,26 @@ public class H1Config {
 
     public static final H1Config DEFAULT = new Builder().build();
 
+    private final int chunkSizeHint;
     private final int waitForContinueTimeout;
     private final int maxLineLength;
     private final int maxHeaderCount;
     private final int maxEmptyLineCount;
 
-    H1Config(final int waitForContinueTimeout, final int maxLineLength, final int maxHeaderCount, final int maxEmptyLineCount) {
+    H1Config(final int chunkSizeHint, final int waitForContinueTimeout, final int maxLineLength,
+             final int maxHeaderCount, final int maxEmptyLineCount) {
         super();
+        this.chunkSizeHint = chunkSizeHint;
         this.waitForContinueTimeout = waitForContinueTimeout;
         this.maxLineLength = maxLineLength;
         this.maxHeaderCount = maxHeaderCount;
         this.maxEmptyLineCount = maxEmptyLineCount;
     }
 
+    public int getChunkSizeHint() {
+        return chunkSizeHint;
+    }
+
     public int getWaitForContinueTimeout() {
         return waitForContinueTimeout;
     }
@@ -78,7 +85,8 @@ public class H1Config {
     @Override
     public String toString() {
         final StringBuilder builder = new StringBuilder();
-        builder.append("[waitForContinueTimeout=").append(waitForContinueTimeout)
+        builder.append("[chunkSizeHint=").append(chunkSizeHint)
+                .append(", waitForContinueTimeout=").append(waitForContinueTimeout)
                 .append(", maxLineLength=").append(maxLineLength)
                 .append(", maxHeaderCount=").append(maxHeaderCount)
                 .append(", maxEmptyLineCount=").append(maxEmptyLineCount)
@@ -93,6 +101,7 @@ public class H1Config {
     public static H1Config.Builder copy(final H1Config config) {
         Args.notNull(config, "Message constraints");
         return new Builder()
+                .setChunkSizeHint(config.getChunkSizeHint())
                 .setWaitForContinueTimeout(config.getWaitForContinueTimeout())
                 .setMaxHeaderCount(config.getMaxHeaderCount())
                 .setMaxLineLength(config.getMaxLineLength())
@@ -101,18 +110,25 @@ public class H1Config {
 
     public static class Builder {
 
+        private int chunkSizeHint;
         private int waitForContinueTimeout;
         private int maxLineLength;
         private int maxHeaderCount;
         private int maxEmptyLineCount;
 
         Builder() {
+            this.chunkSizeHint = -1;
             this.waitForContinueTimeout = 3000;
             this.maxLineLength = -1;
             this.maxHeaderCount = -1;
             this.maxEmptyLineCount = 10;
         }
 
+        public Builder setChunkSizeHint(final int chunkSizeHint) {
+            this.chunkSizeHint = chunkSizeHint;
+            return this;
+        }
+
         public Builder setWaitForContinueTimeout(final int waitForContinueTimeout) {
             this.waitForContinueTimeout = waitForContinueTimeout;
             return this;
@@ -134,7 +150,7 @@ public class H1Config {
         }
 
         public H1Config build() {
-            return new H1Config(waitForContinueTimeout, maxLineLength, maxHeaderCount, maxEmptyLineCount);
+            return new H1Config(chunkSizeHint, waitForContinueTimeout, maxLineLength, maxHeaderCount, maxEmptyLineCount);
         }
 
     }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/AbstractMessageParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/AbstractMessageParser.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/AbstractMessageParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/AbstractMessageParser.java Sun Dec 11 14:51:19 2016
@@ -55,7 +55,7 @@ public abstract class AbstractMessagePar
     private static final int HEAD_LINE    = 0;
     private static final int HEADERS      = 1;
 
-    private final H1Config messageConstraints;
+    private final H1Config h1Config;
     private final List<CharArrayBuffer> headerLines;
     private final CharArrayBuffer headLine;
     private final LineParser lineParser;
@@ -68,15 +68,15 @@ public abstract class AbstractMessagePar
      *
      * @param lineParser the line parser. If {@code null}
      *   {@link org.apache.hc.core5.http.message.LazyLineParser#INSTANCE} will be used.
-     * @param constraints the message constraints. If {@code null}
+     * @param h1Config the message h1Config. If {@code null}
      *   {@link H1Config#DEFAULT} will be used.
      *
      * @since 4.3
      */
-    public AbstractMessageParser(final LineParser lineParser, final H1Config constraints) {
+    public AbstractMessageParser(final LineParser lineParser, final H1Config h1Config) {
         super();
         this.lineParser = lineParser != null ? lineParser : LazyLineParser.INSTANCE;
-        this.messageConstraints = constraints != null ? constraints : H1Config.DEFAULT;
+        this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
         this.headerLines = new ArrayList<>();
         this.headLine = new CharArrayBuffer(128);
         this.state = HEAD_LINE;
@@ -236,7 +236,7 @@ public abstract class AbstractMessagePar
         final int st = this.state;
         switch (st) {
         case HEAD_LINE:
-            for (int n = 0; n < this.messageConstraints.getMaxEmptyLineCount(); n++) {
+            for (int n = 0; n < this.h1Config.getMaxEmptyLineCount(); n++) {
                 this.headLine.clear();
                 final int i = buffer.readLine(this.headLine, inputStream);
                 if (i == -1) {
@@ -258,8 +258,8 @@ public abstract class AbstractMessagePar
             final Header[] headers = AbstractMessageParser.parseHeaders(
                     buffer,
                     inputStream,
-                    this.messageConstraints.getMaxHeaderCount(),
-                    this.messageConstraints.getMaxLineLength(),
+                    this.h1Config.getMaxHeaderCount(),
+                    this.h1Config.getMaxLineLength(),
                     this.lineParser,
                     this.headerLines);
             this.message.setHeaders(headers);

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java Sun Dec 11 14:51:19 2016
@@ -39,6 +39,7 @@ import java.nio.charset.CharsetEncoder;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 
+import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.http.ConnectionClosedException;
 import org.apache.hc.core5.http.ContentLengthStrategy;
 import org.apache.hc.core5.http.Header;
@@ -47,7 +48,6 @@ import org.apache.hc.core5.http.HttpEnti
 import org.apache.hc.core5.http.HttpHeaders;
 import org.apache.hc.core5.http.HttpMessage;
 import org.apache.hc.core5.http.ProtocolVersion;
-import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
 import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
@@ -61,7 +61,7 @@ class BHttpConnectionBase implements BHt
 
     final SessionInputBufferImpl inbuffer;
     final SessionOutputBufferImpl outbuffer;
-    final H1Config messageConstraints;
+    final H1Config h1Config;
     final BasicHttpConnectionMetrics connMetrics;
     final AtomicReference<SocketHolder> socketHolderRef;
 
@@ -69,19 +69,17 @@ class BHttpConnectionBase implements BHt
 
     BHttpConnectionBase(
             final int buffersize,
-            final int fragmentSizeHint,
             final CharsetDecoder chardecoder,
             final CharsetEncoder charencoder,
-            final H1Config messageConstraints) {
-        super();
+            final H1Config h1Config) {
         Args.positive(buffersize, "Buffer size");
         final BasicHttpTransportMetrics inTransportMetrics = new BasicHttpTransportMetrics();
         final BasicHttpTransportMetrics outTransportMetrics = new BasicHttpTransportMetrics();
         this.inbuffer = new SessionInputBufferImpl(inTransportMetrics, buffersize, -1,
-                messageConstraints != null ? messageConstraints : H1Config.DEFAULT, chardecoder);
-        this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, buffersize, fragmentSizeHint,
-                charencoder);
-        this.messageConstraints = messageConstraints;
+                (h1Config != null ? h1Config : H1Config.DEFAULT).getMaxLineLength(), chardecoder);
+        this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, buffersize,
+                (h1Config != null ? h1Config : H1Config.DEFAULT).getChunkSizeHint(), charencoder);
+        this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
         this.connMetrics = new BasicHttpConnectionMetrics(inTransportMetrics, outTransportMetrics);
         this.socketHolderRef = new AtomicReference<>();
     }
@@ -139,7 +137,8 @@ class BHttpConnectionBase implements BHt
         if (len >= 0) {
             return new ContentLengthOutputStream(buffer, outputStream, len);
         } else if (len == ContentLengthStrategy.CHUNKED) {
-            return new ChunkedOutputStream(2048, buffer, outputStream, trailers);
+            final int chunkSizeHint = h1Config.getChunkSizeHint() >= 0 ? h1Config.getChunkSizeHint() : 2048;
+            return new ChunkedOutputStream(buffer, outputStream, chunkSizeHint, trailers);
         } else {
             return new IdentityOutputStream(buffer, outputStream);
         }
@@ -154,7 +153,7 @@ class BHttpConnectionBase implements BHt
         } else if (len == 0) {
             return EmptyInputStream.INSTANCE;
         } else if (len == ContentLengthStrategy.CHUNKED) {
-            return new ChunkedInputStream(buffer, inputStream, this.messageConstraints);
+            return new ChunkedInputStream(buffer, inputStream, this.h1Config);
         } else {
             return new IdentityInputStream(buffer, inputStream);
         }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java Sun Dec 11 14:51:19 2016
@@ -70,7 +70,7 @@ public class ChunkedInputStream extends
     private final SessionInputBuffer buffer;
     private final InputStream inputStream;
     private final CharArrayBuffer lineBuffer;
-    private final H1Config constraints;
+    private final H1Config h1Config;
 
     private int state;
 
@@ -93,17 +93,17 @@ public class ChunkedInputStream extends
      *
      * @param buffer Session input buffer
      * @param inputStream Input stream
-     * @param constraints Message constraints. If {@code null} {@link H1Config#DEFAULT} will be used.
+     * @param h1Config Message h1Config. If {@code null} {@link H1Config#DEFAULT} will be used.
      *
      * @since 4.4
      */
-    public ChunkedInputStream(final SessionInputBuffer buffer, final InputStream inputStream, final H1Config constraints) {
+    public ChunkedInputStream(final SessionInputBuffer buffer, final InputStream inputStream, final H1Config h1Config) {
         super();
         this.buffer = Args.notNull(buffer, "Session input buffer");
         this.inputStream = Args.notNull(inputStream, "Input stream");
         this.pos = 0L;
         this.lineBuffer = new CharArrayBuffer(16);
-        this.constraints = constraints != null ? constraints : H1Config.DEFAULT;
+        this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
         this.state = CHUNK_LEN;
     }
 
@@ -286,8 +286,8 @@ public class ChunkedInputStream extends
     private void parseTrailerHeaders() throws IOException {
         try {
             this.footers = AbstractMessageParser.parseHeaders(buffer, inputStream,
-                    constraints.getMaxHeaderCount(),
-                    constraints.getMaxLineLength(),
+                    h1Config.getMaxHeaderCount(),
+                    h1Config.getMaxLineLength(),
                     null);
         } catch (final HttpException ex) {
             final IOException ioe = new MalformedChunkCodingException("Invalid trailing header: "

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedOutputStream.java Sun Dec 11 14:51:19 2016
@@ -31,12 +31,12 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.util.List;
 
+import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.http.FormattedHeader;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.StreamClosedException;
 import org.apache.hc.core5.http.io.SessionOutputBuffer;
 import org.apache.hc.core5.http.message.BasicLineFormatter;
-import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.CharArrayBuffer;
 
@@ -67,19 +67,22 @@ public class ChunkedOutputStream extends
     /**
      * Default constructor.
      *
-     * @param minChunkSize The minimum chunk size (excluding last chunk)
      * @param buffer Session output buffer
      * @param outputStream Output stream
+     * @param chunkSizeHint minimal chunk size hint
      * @param trailerSupplier Trailer supplier. May be {@code null}
      *
      * @since 5.0
      */
-    public ChunkedOutputStream(final int minChunkSize, final SessionOutputBuffer buffer, final OutputStream outputStream,
-                               final Supplier<List<? extends Header>> trailerSupplier) {
+    public ChunkedOutputStream(
+            final SessionOutputBuffer buffer,
+            final OutputStream outputStream,
+            final int chunkSizeHint,
+            final Supplier<List<? extends Header>> trailerSupplier) {
         super();
         this.buffer = Args.notNull(buffer, "Session output buffer");
         this.outputStream = Args.notNull(outputStream, "Output stream");
-        this.cache = new byte[minChunkSize];
+        this.cache = new byte[chunkSizeHint > 0 ? chunkSizeHint : 2048];
         this.lineBuffer = new CharArrayBuffer(32);
         this.trailerSupplier = trailerSupplier;
     }
@@ -87,12 +90,12 @@ public class ChunkedOutputStream extends
     /**
      * Constructor with no trailers.
      *
-     * @param minChunkSize The minimum chunk size (excluding last chunk)
      * @param buffer Session output buffer
      * @param outputStream Output stream
+     * @param chunkSizeHint minimal chunk size hint
      */
-    public ChunkedOutputStream(final int minChunkSize, final SessionOutputBuffer buffer, final OutputStream outputStream) {
-        this(minChunkSize, buffer, outputStream, null);
+    public ChunkedOutputStream(final SessionOutputBuffer buffer, final OutputStream outputStream, final int chunkSizeHint) {
+        this(buffer, outputStream, chunkSizeHint, null);
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java Sun Dec 11 14:51:19 2016
@@ -70,12 +70,11 @@ public class DefaultBHttpClientConnectio
      * Creates new instance of DefaultBHttpClientConnection.
      *
      * @param buffersize buffer size. Must be a positive number.
-     * @param fragmentSizeHint fragment size hint.
      * @param chardecoder decoder to be used for decoding HTTP protocol elements.
      *   If {@code null} simple type cast will be used for byte to char conversion.
      * @param charencoder encoder to be used for encoding HTTP protocol elements.
      *   If {@code null} simple type cast will be used for char to byte conversion.
-     * @param constraints Message constraints. If {@code null}
+     * @param h1Config Message h1Config. If {@code null}
      *   {@link H1Config#DEFAULT} will be used.
      * @param incomingContentStrategy incoming content length strategy. If {@code null}
      *   {@link DefaultContentLengthStrategy#INSTANCE} will be used.
@@ -88,19 +87,18 @@ public class DefaultBHttpClientConnectio
      */
     public DefaultBHttpClientConnection(
             final int buffersize,
-            final int fragmentSizeHint,
             final CharsetDecoder chardecoder,
             final CharsetEncoder charencoder,
-            final H1Config constraints,
+            final H1Config h1Config,
             final ContentLengthStrategy incomingContentStrategy,
             final ContentLengthStrategy outgoingContentStrategy,
             final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
             final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
-        super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints);
+        super(buffersize, chardecoder, charencoder, h1Config);
         this.requestWriter = (requestWriterFactory != null ? requestWriterFactory :
             DefaultHttpRequestWriterFactory.INSTANCE).create();
         this.responseParser = (responseParserFactory != null ? responseParserFactory :
-            DefaultHttpResponseParserFactory.INSTANCE).create(constraints);
+            DefaultHttpResponseParserFactory.INSTANCE).create(h1Config);
         this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
                 DefaultContentLengthStrategy.INSTANCE;
         this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
@@ -112,12 +110,12 @@ public class DefaultBHttpClientConnectio
             final int buffersize,
             final CharsetDecoder chardecoder,
             final CharsetEncoder charencoder,
-            final H1Config constraints) {
-        this(buffersize, buffersize, chardecoder, charencoder, constraints, null, null, null, null);
+            final H1Config h1Config) {
+        this(buffersize, chardecoder, charencoder, h1Config, null, null, null, null);
     }
 
     public DefaultBHttpClientConnection(final int buffersize) {
-        this(buffersize, buffersize, null, null, null, null, null, null, null);
+        this(buffersize, null, null, null, null, null, null, null);
     }
 
     protected void onResponseReceived(final ClassicHttpResponse response) {

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnectionFactory.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnectionFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnectionFactory.java Sun Dec 11 14:51:19 2016
@@ -53,6 +53,7 @@ public class DefaultBHttpClientConnectio
 
     public static final DefaultBHttpClientConnectionFactory INSTANCE = new DefaultBHttpClientConnectionFactory();
 
+    private final H1Config h1Config;
     private final ConnectionConfig cconfig;
     private final ContentLengthStrategy incomingContentStrategy;
     private final ContentLengthStrategy outgoingContentStrategy;
@@ -60,12 +61,14 @@ public class DefaultBHttpClientConnectio
     private final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory;
 
     public DefaultBHttpClientConnectionFactory(
+            final H1Config h1Config,
             final ConnectionConfig cconfig,
             final ContentLengthStrategy incomingContentStrategy,
             final ContentLengthStrategy outgoingContentStrategy,
             final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
             final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
         super();
+        this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
         this.cconfig = cconfig != null ? cconfig : ConnectionConfig.DEFAULT;
         this.incomingContentStrategy = incomingContentStrategy;
         this.outgoingContentStrategy = outgoingContentStrategy;
@@ -74,28 +77,28 @@ public class DefaultBHttpClientConnectio
     }
 
     public DefaultBHttpClientConnectionFactory(
+            final H1Config h1Config,
             final ConnectionConfig cconfig,
             final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
             final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
-        this(cconfig, null, null, requestWriterFactory, responseParserFactory);
+        this(h1Config, cconfig, null, null, requestWriterFactory, responseParserFactory);
     }
 
     public DefaultBHttpClientConnectionFactory(final ConnectionConfig cconfig) {
-        this(cconfig, null, null, null, null);
+        this(null, cconfig, null, null, null, null);
     }
 
     public DefaultBHttpClientConnectionFactory() {
-        this(null, null, null, null, null);
+        this(null, null, null, null, null, null);
     }
 
     @Override
     public DefaultBHttpClientConnection createConnection(final Socket socket) throws IOException {
         final DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(
                 this.cconfig.getBufferSize(),
-                this.cconfig.getFragmentSizeHint(),
                 ConnSupport.createDecoder(this.cconfig),
                 ConnSupport.createEncoder(this.cconfig),
-                H1Config.DEFAULT,
+                this.h1Config,
                 this.incomingContentStrategy,
                 this.outgoingContentStrategy,
                 this.requestWriterFactory,

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java Sun Dec 11 14:51:19 2016
@@ -67,12 +67,11 @@ public class DefaultBHttpServerConnectio
      * Creates new instance of DefaultBHttpServerConnection.
      *
      * @param buffersize buffer size. Must be a positive number.
-     * @param fragmentSizeHint fragment size hint.
      * @param chardecoder decoder to be used for decoding HTTP protocol elements.
      *   If {@code null} simple type cast will be used for byte to char conversion.
      * @param charencoder encoder to be used for encoding HTTP protocol elements.
      *   If {@code null} simple type cast will be used for char to byte conversion.
-     * @param constraints Message constraints. If {@code null}
+     * @param h1Config Message h1Config. If {@code null}
      *   {@link H1Config#DEFAULT} will be used.
      * @param incomingContentStrategy incoming content length strategy. If {@code null}
      *   {@link DefaultContentLengthStrategy#INSTANCE} will be used.
@@ -85,17 +84,16 @@ public class DefaultBHttpServerConnectio
      */
     public DefaultBHttpServerConnection(
             final int buffersize,
-            final int fragmentSizeHint,
             final CharsetDecoder chardecoder,
             final CharsetEncoder charencoder,
-            final H1Config constraints,
+            final H1Config h1Config,
             final ContentLengthStrategy incomingContentStrategy,
             final ContentLengthStrategy outgoingContentStrategy,
             final HttpMessageParserFactory<ClassicHttpRequest> requestParserFactory,
             final HttpMessageWriterFactory<ClassicHttpResponse> responseWriterFactory) {
-        super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints);
+        super(buffersize, chardecoder, charencoder, h1Config);
         this.requestParser = (requestParserFactory != null ? requestParserFactory :
-            DefaultHttpRequestParserFactory.INSTANCE).create(constraints);
+            DefaultHttpRequestParserFactory.INSTANCE).create(h1Config);
         this.responseWriter = (responseWriterFactory != null ? responseWriterFactory :
             DefaultHttpResponseWriterFactory.INSTANCE).create();
         this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
@@ -108,12 +106,12 @@ public class DefaultBHttpServerConnectio
             final int buffersize,
             final CharsetDecoder chardecoder,
             final CharsetEncoder charencoder,
-            final H1Config constraints) {
-        this(buffersize, buffersize, chardecoder, charencoder, constraints, null, null, null, null);
+            final H1Config h1Config) {
+        this(buffersize, chardecoder, charencoder, h1Config, null, null, null, null);
     }
 
     public DefaultBHttpServerConnection(final int buffersize) {
-        this(buffersize, buffersize, null, null, null, null, null, null, null);
+        this(buffersize,null, null, null, null, null, null, null);
     }
 
     protected void onRequestReceived(final ClassicHttpRequest request) {

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnectionFactory.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnectionFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnectionFactory.java Sun Dec 11 14:51:19 2016
@@ -53,6 +53,7 @@ public class DefaultBHttpServerConnectio
 
     public static final DefaultBHttpServerConnectionFactory INSTANCE = new DefaultBHttpServerConnectionFactory();
 
+    private final H1Config h1Config;
     private final ConnectionConfig cconfig;
     private final ContentLengthStrategy incomingContentStrategy;
     private final ContentLengthStrategy outgoingContentStrategy;
@@ -60,12 +61,14 @@ public class DefaultBHttpServerConnectio
     private final HttpMessageWriterFactory<ClassicHttpResponse> responseWriterFactory;
 
     public DefaultBHttpServerConnectionFactory(
+            final H1Config h1Config,
             final ConnectionConfig cconfig,
             final ContentLengthStrategy incomingContentStrategy,
             final ContentLengthStrategy outgoingContentStrategy,
             final HttpMessageParserFactory<ClassicHttpRequest> requestParserFactory,
             final HttpMessageWriterFactory<ClassicHttpResponse> responseWriterFactory) {
         super();
+        this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
         this.cconfig = cconfig != null ? cconfig : ConnectionConfig.DEFAULT;
         this.incomingContentStrategy = incomingContentStrategy;
         this.outgoingContentStrategy = outgoingContentStrategy;
@@ -74,28 +77,28 @@ public class DefaultBHttpServerConnectio
     }
 
     public DefaultBHttpServerConnectionFactory(
+            final H1Config h1Config,
             final ConnectionConfig cconfig,
             final HttpMessageParserFactory<ClassicHttpRequest> requestParserFactory,
             final HttpMessageWriterFactory<ClassicHttpResponse> responseWriterFactory) {
-        this(cconfig, null, null, requestParserFactory, responseWriterFactory);
+        this(h1Config, cconfig, null, null, requestParserFactory, responseWriterFactory);
     }
 
     public DefaultBHttpServerConnectionFactory(final ConnectionConfig cconfig) {
-        this(cconfig, null, null, null, null);
+        this(null, cconfig, null, null, null, null);
     }
 
     public DefaultBHttpServerConnectionFactory() {
-        this(null, null, null, null, null);
+        this(null, null, null, null, null, null);
     }
 
     @Override
     public DefaultBHttpServerConnection createConnection(final Socket socket) throws IOException {
         final DefaultBHttpServerConnection conn = new DefaultBHttpServerConnection(
                 this.cconfig.getBufferSize(),
-                this.cconfig.getFragmentSizeHint(),
                 ConnSupport.createDecoder(this.cconfig),
                 ConnSupport.createEncoder(this.cconfig),
-                H1Config.DEFAULT,
+                h1Config,
                 this.incomingContentStrategy,
                 this.outgoingContentStrategy,
                 this.requestParserFactory,

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParser.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParser.java Sun Dec 11 14:51:19 2016
@@ -55,7 +55,7 @@ public class DefaultHttpRequestParser ex
      *   {@link org.apache.hc.core5.http.message.LazyLineParser#INSTANCE} will be used.
      * @param requestFactory the response factory. If {@code null}
      *   {@link DefaultClassicHttpRequestFactory#INSTANCE} will be used.
-     * @param constraints the message constraints. If {@code null}
+     * @param h1Config the message h1Config. If {@code null}
      *   {@link H1Config#DEFAULT} will be used.
      *
      * @since 4.3
@@ -63,16 +63,16 @@ public class DefaultHttpRequestParser ex
     public DefaultHttpRequestParser(
             final LineParser lineParser,
             final HttpRequestFactory<ClassicHttpRequest> requestFactory,
-            final H1Config constraints) {
-        super(lineParser, constraints);
+            final H1Config h1Config) {
+        super(lineParser, h1Config);
         this.requestFactory = requestFactory != null ? requestFactory : DefaultClassicHttpRequestFactory.INSTANCE;
     }
 
     /**
      * @since 4.3
      */
-    public DefaultHttpRequestParser(final H1Config constraints) {
-        this(null, null, constraints);
+    public DefaultHttpRequestParser(final H1Config h1Config) {
+        this(null, null, h1Config);
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParserFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParserFactory.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParserFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParserFactory.java Sun Dec 11 14:51:19 2016
@@ -62,8 +62,8 @@ public class DefaultHttpRequestParserFac
     }
 
     @Override
-    public HttpMessageParser<ClassicHttpRequest> create(final H1Config constraints) {
-        return new DefaultHttpRequestParser(this.lineParser, this.requestFactory, constraints);
+    public HttpMessageParser<ClassicHttpRequest> create(final H1Config h1Config) {
+        return new DefaultHttpRequestParser(this.lineParser, this.requestFactory, h1Config);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParser.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParser.java Sun Dec 11 14:51:19 2016
@@ -55,7 +55,7 @@ public class DefaultHttpResponseParser e
      *   {@link org.apache.hc.core5.http.message.LazyLineParser#INSTANCE} will be used
      * @param responseFactory the response factory. If {@code null}
      *   {@link DefaultClassicHttpResponseFactory#INSTANCE} will be used.
-     * @param constraints the message constraints. If {@code null}
+     * @param h1Config the message h1Config. If {@code null}
      *   {@link H1Config#DEFAULT} will be used.
      *
      * @since 4.3
@@ -63,16 +63,16 @@ public class DefaultHttpResponseParser e
     public DefaultHttpResponseParser(
             final LineParser lineParser,
             final HttpResponseFactory<ClassicHttpResponse> responseFactory,
-            final H1Config constraints) {
-        super(lineParser, constraints);
+            final H1Config h1Config) {
+        super(lineParser, h1Config);
         this.responseFactory = responseFactory != null ? responseFactory : DefaultClassicHttpResponseFactory.INSTANCE;
     }
 
     /**
      * @since 4.3
      */
-    public DefaultHttpResponseParser(final H1Config constraints) {
-        this(null, null, constraints);
+    public DefaultHttpResponseParser(final H1Config h1Config) {
+        this(null, null, h1Config);
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParserFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParserFactory.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParserFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParserFactory.java Sun Dec 11 14:51:19 2016
@@ -62,8 +62,8 @@ public class DefaultHttpResponseParserFa
     }
 
     @Override
-    public HttpMessageParser<ClassicHttpResponse> create(final H1Config constraints) {
-        return new DefaultHttpResponseParser(this.lineParser, this.responseFactory, constraints);
+    public HttpMessageParser<ClassicHttpResponse> create(final H1Config h1Config) {
+        return new DefaultHttpResponseParser(this.lineParser, this.responseFactory, h1Config);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java Sun Dec 11 14:51:19 2016
@@ -36,7 +36,6 @@ import java.nio.charset.CoderResult;
 
 import org.apache.hc.core5.http.Chars;
 import org.apache.hc.core5.http.MessageConstraintException;
-import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
 import org.apache.hc.core5.http.io.HttpTransportMetrics;
 import org.apache.hc.core5.http.io.SessionInputBuffer;
@@ -61,7 +60,7 @@ public class SessionInputBufferImpl impl
     private final byte[] buffer;
     private final ByteArrayBuffer linebuffer;
     private final int minChunkLimit;
-    private final H1Config constraints;
+    private final int maxLineLen;
     private final CharsetDecoder decoder;
 
     private int bufferpos;
@@ -78,8 +77,7 @@ public class SessionInputBufferImpl impl
      *   The optimal value of this parameter can be platform specific and defines a trade-off
      *   between performance of memory copy operations and that of native method invocation.
      *   If negative default chunk limited will be used.
-     * @param constraints Message constraints. If {@code null}
-     *   {@link H1Config#DEFAULT} will be used.
+     * @param maxLineLen maximum line length.
      * @param chardecoder chardecoder to be used for decoding HTTP protocol elements.
      *   If {@code null} simple type cast will be used for byte to char conversion.
      */
@@ -87,7 +85,7 @@ public class SessionInputBufferImpl impl
             final BasicHttpTransportMetrics metrics,
             final int buffersize,
             final int minChunkLimit,
-            final H1Config constraints,
+            final int maxLineLen,
             final CharsetDecoder chardecoder) {
         Args.notNull(metrics, "HTTP transport metrcis");
         Args.positive(buffersize, "Buffer size");
@@ -96,7 +94,7 @@ public class SessionInputBufferImpl impl
         this.bufferpos = 0;
         this.bufferlen = 0;
         this.minChunkLimit = minChunkLimit >= 0 ? minChunkLimit : 512;
-        this.constraints = constraints != null ? constraints : H1Config.DEFAULT;
+        this.maxLineLen = maxLineLen > 0 ? maxLineLen : 0;
         this.linebuffer = new ByteArrayBuffer(buffersize);
         this.decoder = chardecoder;
     }
@@ -104,19 +102,19 @@ public class SessionInputBufferImpl impl
     public SessionInputBufferImpl(
             final BasicHttpTransportMetrics metrics,
             final int buffersize) {
-        this(metrics, buffersize, buffersize, null, null);
+        this(metrics, buffersize, buffersize, 0, null);
     }
 
-    public SessionInputBufferImpl(final int buffersize, final H1Config constraints) {
-        this(new BasicHttpTransportMetrics(), buffersize, buffersize, constraints, null);
+    public SessionInputBufferImpl(final int buffersize, final int maxLineLen) {
+        this(new BasicHttpTransportMetrics(), buffersize, buffersize, maxLineLen, null);
     }
 
     public SessionInputBufferImpl(final int buffersize, final CharsetDecoder decoder) {
-        this(new BasicHttpTransportMetrics(), buffersize, buffersize, null, decoder);
+        this(new BasicHttpTransportMetrics(), buffersize, buffersize, 0, decoder);
     }
 
     public SessionInputBufferImpl(final int buffersize) {
-        this(new BasicHttpTransportMetrics(), buffersize, buffersize, null, null);
+        this(new BasicHttpTransportMetrics(), buffersize, buffersize, 0, null);
     }
 
     @Override
@@ -240,7 +238,6 @@ public class SessionInputBufferImpl impl
     public int readLine(final CharArrayBuffer charbuffer, final InputStream inputStream) throws IOException {
         Args.notNull(charbuffer, "Char array buffer");
         Args.notNull(inputStream, "Input stream");
-        final int maxLineLen = this.constraints.getMaxLineLength();
         int noRead = 0;
         boolean retry = true;
         while (retry) {
@@ -253,10 +250,10 @@ public class SessionInputBufferImpl impl
                 }
             }
 
-            if (maxLineLen > 0) {
+            if (this.maxLineLen > 0) {
                 final int currentLen = this.linebuffer.length()
                         + (pos > 0 ? pos : this.bufferlen) - this.bufferpos;
-                if (currentLen >= maxLineLen) {
+                if (currentLen >= this.maxLineLen) {
                     throw new MessageConstraintException("Maximum line length limit exceeded");
                 }
             }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionOutputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionOutputBufferImpl.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionOutputBufferImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionOutputBufferImpl.java Sun Dec 11 14:51:19 2016
@@ -84,7 +84,7 @@ public class SessionOutputBufferImpl imp
         Args.notNull(metrics, "HTTP transport metrcis");
         this.metrics = metrics;
         this.buffer = new ByteArrayBuffer(buffersize);
-        this.fragementSizeHint = fragementSizeHint >= 0 ? fragementSizeHint : 0;
+        this.fragementSizeHint = fragementSizeHint >= 0 ? fragementSizeHint : buffersize;
         this.encoder = charencoder;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java Sun Dec 11 14:51:19 2016
@@ -101,17 +101,17 @@ abstract class AbstractHttp1StreamDuplex
 
     AbstractHttp1StreamDuplexer(
             final IOSession ioSession,
+            final H1Config h1Config,
             final ConnectionConfig connectionConfig,
             final NHttpMessageParser<IncomingMessage> incomingMessageParser,
             final NHttpMessageWriter<OutgoingMessage> outgoingMessageWriter,
             final ConnectionListener connectionListener) {
         this.ioSession = Args.notNull(ioSession, "I/O session");
         final int bufferSize = connectionConfig.getBufferSize();
-        this.inbuf = new SessionInputBufferImpl(bufferSize,
-                bufferSize < 512 ? bufferSize : 512, H1Config.DEFAULT,
+        this.inbuf = new SessionInputBufferImpl(bufferSize, bufferSize < 512 ? bufferSize : 512,
+                (h1Config != null ? h1Config : H1Config.DEFAULT).getMaxLineLength(),
                 ConnSupport.createDecoder(connectionConfig));
-        this.outbuf = new SessionOutputBufferImpl(bufferSize,
-                bufferSize < 512 ? bufferSize : 512,
+        this.outbuf = new SessionOutputBufferImpl(bufferSize, bufferSize < 512 ? bufferSize : 512,
                 ConnSupport.createEncoder(connectionConfig));
         this.inTransportMetrics = new BasicHttpTransportMetrics();
         this.outTransportMetrics = new BasicHttpTransportMetrics();

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkDecoder.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkDecoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkDecoder.java Sun Dec 11 14:51:19 2016
@@ -66,7 +66,7 @@ public class ChunkDecoder extends Abstra
     private long chunkSize;
     private long pos;
 
-    private final H1Config constraints;
+    private final H1Config h1Config;
     private final List<CharArrayBuffer> trailerBufs;
     private final List<Header> trailers;
 
@@ -76,7 +76,7 @@ public class ChunkDecoder extends Abstra
     public ChunkDecoder(
             final ReadableByteChannel channel,
             final SessionInputBuffer buffer,
-            final H1Config constraints,
+            final H1Config h1Config,
             final BasicHttpTransportMetrics metrics) {
         super(channel, buffer, metrics);
         this.state = READ_CONTENT;
@@ -84,7 +84,7 @@ public class ChunkDecoder extends Abstra
         this.pos = 0L;
         this.endOfChunk = false;
         this.endOfStream = false;
-        this.constraints = constraints != null ? constraints : H1Config.DEFAULT;
+        this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
         this.trailerBufs = new ArrayList<>();
         this.trailers = new ArrayList<>();
     }
@@ -116,7 +116,7 @@ public class ChunkDecoder extends Abstra
             this.endOfChunk = false;
         }
         final boolean lineComplete = this.buffer.readLine(this.lineBuf, this.endOfStream);
-        final int maxLineLen = this.constraints.getMaxLineLength();
+        final int maxLineLen = this.h1Config.getMaxLineLength();
         if (maxLineLen > 0 &&
                 (this.lineBuf.length() > maxLineLen ||
                         (!lineComplete && this.buffer.length() > maxLineLen))) {
@@ -154,7 +154,7 @@ public class ChunkDecoder extends Abstra
                 }
                 i++;
             }
-            final int maxLineLen = this.constraints.getMaxLineLength();
+            final int maxLineLen = this.h1Config.getMaxLineLength();
             if (maxLineLen > 0 && previous.length() + 1 + current.length() - i > maxLineLen) {
                 throw new MessageConstraintException("Maximum line length limit exceeded");
             }
@@ -252,7 +252,7 @@ public class ChunkDecoder extends Abstra
                     return totalRead;
                 }
                 if (this.lineBuf.length() > 0) {
-                    final int maxHeaderCount = this.constraints.getMaxHeaderCount();
+                    final int maxHeaderCount = this.h1Config.getMaxHeaderCount();
                     if (maxHeaderCount > 0 && trailerBufs.size() >= maxHeaderCount) {
                         throw new MessageConstraintException("Maximum header count exceeded");
                     }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkEncoder.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkEncoder.java Sun Dec 11 14:51:19 2016
@@ -47,16 +47,13 @@ import org.apache.hc.core5.util.CharArra
  */
 public class ChunkEncoder extends AbstractContentEncoder {
 
-    private final int fragHint;
+    private final int chunkSizeHint;
     private final CharArrayBuffer lineBuffer;
 
     /**
      * @param channel underlying channel.
      * @param buffer  session buffer.
      * @param metrics transport metrics.
-     * @param fragementSizeHint fragment size hint defining an minimal size of a fragment
-     *   that should be written out directly to the channel bypassing the session buffer.
-     *   Value {@code 0} disables fragment buffering.
      *
      * @since 5.0
      */
@@ -64,9 +61,9 @@ public class ChunkEncoder extends Abstra
             final WritableByteChannel channel,
             final SessionOutputBuffer buffer,
             final BasicHttpTransportMetrics metrics,
-            final int fragementSizeHint) {
+            final int chunkSizeHint) {
         super(channel, buffer, metrics);
-        this.fragHint = fragementSizeHint > 0 ? fragementSizeHint : 0;
+        this.chunkSizeHint = chunkSizeHint > 0 ? chunkSizeHint : 0;
         this.lineBuffer = new CharArrayBuffer(16);
     }
 
@@ -116,7 +113,7 @@ public class ChunkEncoder extends Abstra
                 this.buffer.writeLine(this.lineBuffer);
                 total += chunk;
             }
-            if (this.buffer.length() >= this.fragHint || src.hasRemaining()) {
+            if (this.buffer.length() >= this.chunkSizeHint || src.hasRemaining()) {
                 final int bytesWritten = flushToChannel();
                 if (bytesWritten == 0) {
                     break;

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java Sun Dec 11 14:51:19 2016
@@ -69,7 +69,6 @@ public class ClientHttp1StreamDuplexer e
 
     private final HttpProcessor httpProcessor;
     private final ConnectionReuseStrategy connectionReuseStrategy;
-    private final int fragmentSizeHint;
     private final H1Config h1Config;
     private final ContentLengthStrategy incomingContentStrategy;
     private final ContentLengthStrategy outgoingContentStrategy;
@@ -94,11 +93,8 @@ public class ClientHttp1StreamDuplexer e
             final ContentLengthStrategy outgoingContentStrategy,
             final ConnectionListener connectionListener,
             final Http1StreamListener streamListener) {
-        super(ioSession, connectionConfig, incomingMessageParser, outgoingMessageWriter, connectionListener);
+        super(ioSession, h1Config, connectionConfig, incomingMessageParser, outgoingMessageWriter, connectionListener);
         this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
-        final int bufferSize = connectionConfig.getBufferSize();
-        final int fragmentSizeHint = connectionConfig.getFragmentSizeHint();
-        this.fragmentSizeHint = fragmentSizeHint >= 0 ? fragmentSizeHint : bufferSize;
         this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
         this.connectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy :
                 DefaultConnectionReuseStrategy.INSTANCE;
@@ -107,7 +103,7 @@ public class ClientHttp1StreamDuplexer e
         this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
                 DefaultContentLengthStrategy.INSTANCE;
         this.streamListener = streamListener;
-        this.contentBuffer = ByteBuffer.allocate(connectionConfig.getBufferSize());
+        this.contentBuffer = ByteBuffer.allocate((connectionConfig != null ? connectionConfig : ConnectionConfig.DEFAULT).getBufferSize());
         this.pipeline = new ConcurrentLinkedQueue<>();
         this.outputChannel = new Http1StreamChannel<HttpRequest>() {
 
@@ -268,9 +264,10 @@ public class ClientHttp1StreamDuplexer e
             final BasicHttpTransportMetrics metrics) throws HttpException {
         final long len = outgoingContentStrategy.determineLength(request);
         if (len >= 0) {
-            return new LengthDelimitedEncoder(channel, buffer, metrics, len, fragmentSizeHint);
+            return new LengthDelimitedEncoder(channel, buffer, metrics, len, h1Config.getChunkSizeHint());
         } else if (len == ContentLengthStrategy.CHUNKED) {
-            return new ChunkEncoder(channel, buffer, metrics, fragmentSizeHint);
+            final int chunkSizeHint = h1Config.getChunkSizeHint() >= 0 ? h1Config.getChunkSizeHint() : 2048;
+            return new ChunkEncoder(channel, buffer, metrics, chunkSizeHint);
         } else {
             throw new LengthRequiredException("Length required");
         }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParser.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParser.java Sun Dec 11 14:51:19 2016
@@ -51,7 +51,7 @@ public class DefaultHttpRequestParser<T
      * @param requestFactory the request factory.
      * @param parser the line parser. If {@code null}
      *   {@link org.apache.hc.core5.http.message.LazyLineParser#INSTANCE} will be used.
-     * @param constraints Message constraints. If {@code null}
+     * @param h1Config Message h1Config. If {@code null}
      *   {@link H1Config#DEFAULT} will be used.
      *
      * @since 4.3
@@ -59,16 +59,16 @@ public class DefaultHttpRequestParser<T
     public DefaultHttpRequestParser(
             final HttpRequestFactory<T> requestFactory,
             final LineParser parser,
-            final H1Config constraints) {
-        super(parser, constraints);
+            final H1Config h1Config) {
+        super(parser, h1Config);
         this.requestFactory = Args.notNull(requestFactory, "Request factory");
     }
 
     /**
     * @since 4.3
     */
-    public DefaultHttpRequestParser(final HttpRequestFactory<T> requestFactory, final H1Config constraints) {
-        this(requestFactory, null, constraints);
+    public DefaultHttpRequestParser(final HttpRequestFactory<T> requestFactory, final H1Config h1Config) {
+        this(requestFactory, null, h1Config);
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParserFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParserFactory.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParserFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParserFactory.java Sun Dec 11 14:51:19 2016
@@ -65,8 +65,8 @@ public class DefaultHttpRequestParserFac
     }
 
     @Override
-    public NHttpMessageParser<HttpRequest> create(final H1Config constraints) {
-        return new DefaultHttpRequestParser<>(requestFactory, lineParser, constraints);
+    public NHttpMessageParser<HttpRequest> create(final H1Config h1Config) {
+        return new DefaultHttpRequestParser<>(requestFactory, lineParser, h1Config);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParser.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParser.java Sun Dec 11 14:51:19 2016
@@ -51,7 +51,7 @@ public class DefaultHttpResponseParser<T
      * @param responseFactory the response factory.
      * @param parser the line parser. If {@code null}
      *   {@link org.apache.hc.core5.http.message.LazyLineParser#INSTANCE} will be used.
-     * @param constraints Message constraints. If {@code null}
+     * @param h1Config Message h1Config. If {@code null}
      *   {@link H1Config#DEFAULT} will be used.
      *
      * @since 4.3
@@ -59,16 +59,16 @@ public class DefaultHttpResponseParser<T
     public DefaultHttpResponseParser(
             final HttpResponseFactory<T> responseFactory,
             final LineParser parser,
-            final H1Config constraints) {
-        super(parser, constraints);
+            final H1Config h1Config) {
+        super(parser, h1Config);
         this.responseFactory = Args.notNull(responseFactory, "Response factory");
     }
 
     /**
      * @since 4.3
      */
-    public DefaultHttpResponseParser(final HttpResponseFactory<T> responseFactory, final H1Config constraints) {
-        this(responseFactory, null, constraints);
+    public DefaultHttpResponseParser(final HttpResponseFactory<T> responseFactory, final H1Config h1Config) {
+        this(responseFactory, null, h1Config);
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParserFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParserFactory.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParserFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParserFactory.java Sun Dec 11 14:51:19 2016
@@ -65,8 +65,8 @@ public class DefaultHttpResponseParserFa
     }
 
     @Override
-    public NHttpMessageParser<HttpResponse> create(final H1Config constraints) {
-        return new DefaultHttpResponseParser<>(this.responseFactory, this.lineParser, constraints);
+    public NHttpMessageParser<HttpResponse> create(final H1Config h1Config) {
+        return new DefaultHttpResponseParser<>(this.responseFactory, this.lineParser, h1Config);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/IdentityEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/IdentityEncoder.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/IdentityEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/IdentityEncoder.java Sun Dec 11 14:51:19 2016
@@ -58,7 +58,7 @@ public class IdentityEncoder extends Abs
      * @param channel underlying channel.
      * @param buffer  session buffer.
      * @param metrics transport metrics.
-     * @param fragementSizeHint fragment size hint defining an minimal size of a fragment
+     * @param chunkSizeHint fragment size hint defining an minimal size of a fragment
      *   that should be written out directly to the channel bypassing the session buffer.
      *   Value {@code 0} disables fragment buffering.
      */
@@ -66,9 +66,9 @@ public class IdentityEncoder extends Abs
             final WritableByteChannel channel,
             final SessionOutputBuffer buffer,
             final BasicHttpTransportMetrics metrics,
-            final int fragementSizeHint) {
+            final int chunkSizeHint) {
         super(channel, buffer, metrics);
-        this.fragHint = fragementSizeHint > 0 ? fragementSizeHint : 0;
+        this.fragHint = chunkSizeHint > 0 ? chunkSizeHint : 0;
     }
 
     public IdentityEncoder(

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/LengthDelimitedEncoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/LengthDelimitedEncoder.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/LengthDelimitedEncoder.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/LengthDelimitedEncoder.java Sun Dec 11 14:51:19 2016
@@ -64,7 +64,7 @@ public class LengthDelimitedEncoder exte
      * @param buffer  session buffer.
      * @param metrics transport metrics.
      * @param contentLength content length.
-     * @param fragementSizeHint fragment size hint defining an minimal size of a fragment
+     * @param chunkSizeHint fragment size hint defining an minimal size of a fragment
      *   that should be written out directly to the channel bypassing the session buffer.
      *   Value {@code 0} disables fragment buffering.
      */
@@ -73,11 +73,11 @@ public class LengthDelimitedEncoder exte
             final SessionOutputBuffer buffer,
             final BasicHttpTransportMetrics metrics,
             final long contentLength,
-            final int fragementSizeHint) {
+            final int chunkSizeHint) {
         super(channel, buffer, metrics);
         Args.notNegative(contentLength, "Content length");
         this.contentLength = contentLength;
-        this.fragHint = fragementSizeHint > 0 ? fragementSizeHint : 0;
+        this.fragHint = chunkSizeHint > 0 ? chunkSizeHint : 0;
         this.remaining = contentLength;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java Sun Dec 11 14:51:19 2016
@@ -69,7 +69,6 @@ public class ServerHttp1StreamDuplexer e
 
     private final HttpProcessor httpProcessor;
     private final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory;
-    private final int fragmentSizeHint;
     private final H1Config h1Config;
     private final ConnectionReuseStrategy connectionReuseStrategy;
     private final ContentLengthStrategy incomingContentStrategy;
@@ -96,12 +95,9 @@ public class ServerHttp1StreamDuplexer e
             final ContentLengthStrategy outgoingContentStrategy,
             final ConnectionListener connectionListener,
             final Http1StreamListener streamListener) {
-        super(ioSession, connectionConfig, incomingMessageParser, outgoingMessageWriter, connectionListener);
+        super(ioSession, h1Config, connectionConfig, incomingMessageParser, outgoingMessageWriter, connectionListener);
         this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
         this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange handler factory");
-        final int fragmentSizeHint = connectionConfig.getFragmentSizeHint();
-        final int bufferSize = connectionConfig.getBufferSize();
-        this.fragmentSizeHint = fragmentSizeHint >= 0 ? fragmentSizeHint : bufferSize;
         this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
         this.connectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy :
                 DefaultConnectionReuseStrategy.INSTANCE;
@@ -255,11 +251,12 @@ public class ServerHttp1StreamDuplexer e
             final BasicHttpTransportMetrics metrics) throws HttpException {
         final long len = outgoingContentStrategy.determineLength(response);
         if (len >= 0) {
-            return new LengthDelimitedEncoder(channel, buffer, metrics, len, fragmentSizeHint);
+            return new LengthDelimitedEncoder(channel, buffer, metrics, len, h1Config.getChunkSizeHint());
         } else if (len == ContentLengthStrategy.CHUNKED) {
-            return new ChunkEncoder(channel, buffer, metrics, fragmentSizeHint);
+            final int chunkSizeHint = h1Config.getChunkSizeHint() >= 0 ? h1Config.getChunkSizeHint() : 2048;
+            return new ChunkEncoder(channel, buffer, metrics, chunkSizeHint);
         } else {
-            return new IdentityEncoder(channel, buffer, metrics, fragmentSizeHint);
+            return new IdentityEncoder(channel, buffer, metrics, h1Config.getChunkSizeHint());
         }
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionInputBufferImpl.java Sun Dec 11 14:51:19 2016
@@ -38,7 +38,6 @@ import java.nio.charset.CoderResult;
 
 import org.apache.hc.core5.http.Chars;
 import org.apache.hc.core5.http.MessageConstraintException;
-import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.nio.SessionInputBuffer;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.CharArrayBuffer;
@@ -52,8 +51,8 @@ import org.apache.hc.core5.util.CharArra
 public class SessionInputBufferImpl extends ExpandableBuffer implements SessionInputBuffer {
 
     private final CharsetDecoder chardecoder;
-    private final H1Config h1Config;
     private final int lineBuffersize;
+    private final int maxLineLen;
 
     private CharBuffer charbuffer;
 
@@ -65,19 +64,18 @@ public class SessionInputBufferImpl exte
      *   {@code chardecoder} is not {@code null}.
      * @param chardecoder chardecoder to be used for decoding HTTP protocol elements.
      *   If {@code null} simple type cast will be used for byte to char conversion.
-     * @param h1Config Message h1Config. If {@code null}
-     *   {@link H1Config#DEFAULT} will be used.
+     * @param maxLineLen maximum line length.
      *
      * @since 4.4
      */
     public SessionInputBufferImpl(
             final int buffersize,
             final int lineBuffersize,
-            final H1Config h1Config,
+            final int maxLineLen,
             final CharsetDecoder chardecoder) {
         super(buffersize);
         this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
-        this.h1Config = h1Config != null ? h1Config : H1Config.DEFAULT;
+        this.maxLineLen = maxLineLen > 0 ? maxLineLen : 0;
         this.chardecoder = chardecoder;
     }
 
@@ -87,9 +85,9 @@ public class SessionInputBufferImpl exte
     public SessionInputBufferImpl(
             final int buffersize,
             final int lineBuffersize,
-            final H1Config h1Config,
+            final int maxLineLen,
             final Charset charset) {
-        this(buffersize, lineBuffersize, h1Config, charset != null ? charset.newDecoder() : null);
+        this(buffersize, lineBuffersize, maxLineLen, charset != null ? charset.newDecoder() : null);
     }
 
     /**
@@ -98,8 +96,8 @@ public class SessionInputBufferImpl exte
     public SessionInputBufferImpl(
             final int buffersize,
             final int lineBuffersize,
-            final H1Config h1Config) {
-        this(buffersize, lineBuffersize, h1Config, (CharsetDecoder) null);
+            final int maxLineLen) {
+        this(buffersize, lineBuffersize, maxLineLen, (CharsetDecoder) null);
     }
 
     /**
@@ -108,7 +106,7 @@ public class SessionInputBufferImpl exte
     public SessionInputBufferImpl(
             final int buffersize,
             final int lineBuffersize) {
-        this(buffersize, lineBuffersize, null, (CharsetDecoder) null);
+        this(buffersize, lineBuffersize, 0, (CharsetDecoder) null);
     }
 
     /**
@@ -206,10 +204,9 @@ public class SessionInputBufferImpl exte
             }
         }
 
-        final int maxLineLen = this.h1Config.getMaxLineLength();
-        if (maxLineLen > 0) {
+        if (this.maxLineLen > 0) {
             final int currentLen = (pos > 0 ? pos : buffer().limit()) - buffer().position();
-            if (currentLen >= maxLineLen) {
+            if (currentLen >= this.maxLineLen) {
                 throw new MessageConstraintException("Maximum line length limit exceeded");
             }
         }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/HttpMessageParserFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/HttpMessageParserFactory.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/HttpMessageParserFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/HttpMessageParserFactory.java Sun Dec 11 14:51:19 2016
@@ -37,6 +37,6 @@ import org.apache.hc.core5.http.config.H
  */
 public interface HttpMessageParserFactory<T extends MessageHeaders> {
 
-    HttpMessageParser<T> create(H1Config constraints);
+    HttpMessageParser<T> create(H1Config h1Config);
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/NHttpMessageParserFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/NHttpMessageParserFactory.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/NHttpMessageParserFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/nio/NHttpMessageParserFactory.java Sun Dec 11 14:51:19 2016
@@ -37,6 +37,6 @@ import org.apache.hc.core5.http.config.H
  */
 public interface NHttpMessageParserFactory<T extends MessageHeaders> {
 
-    NHttpMessageParser<T> create(H1Config constraints);
+    NHttpMessageParser<T> create(H1Config h1Config);
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java?rev=1773574&r1=1773573&r2=1773574&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java Sun Dec 11 14:51:19 2016
@@ -35,9 +35,9 @@ import java.net.Socket;
 import java.net.SocketException;
 import java.net.SocketTimeoutException;
 
+import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.ContentLengthStrategy;
 import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
 import org.junit.Assert;
@@ -57,7 +57,7 @@ public class TestBHttpConnectionBase {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        conn = new BHttpConnectionBase(1024, 1024, null, null, H1Config.DEFAULT);
+        conn = new BHttpConnectionBase(1024,null, null, H1Config.DEFAULT);
     }
 
     @Test