hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1627507 - /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
Date Thu, 25 Sep 2014 10:50:48 GMT
Author: olegk
Date: Thu Sep 25 10:50:48 2014
New Revision: 1627507

URL: http://svn.apache.org/r1627507
Log:
Added optional parameters for content length strategies

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java?rev=1627507&r1=1627506&r2=1627507&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
Thu Sep 25 10:50:48 2014
@@ -42,6 +42,9 @@ import org.apache.http.config.Connection
 import org.apache.http.conn.HttpConnectionFactory;
 import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.entity.ContentLengthStrategy;
+import org.apache.http.impl.entity.LaxContentLengthStrategy;
+import org.apache.http.impl.entity.StrictContentLengthStrategy;
 import org.apache.http.impl.io.DefaultHttpRequestWriterFactory;
 import org.apache.http.io.HttpMessageParserFactory;
 import org.apache.http.io.HttpMessageWriterFactory;
@@ -64,15 +67,32 @@ public class ManagedHttpClientConnection
 
     private final HttpMessageWriterFactory<HttpRequest> requestWriterFactory;
     private final HttpMessageParserFactory<HttpResponse> responseParserFactory;
+    private final ContentLengthStrategy incomingContentStrategy;
+    private final ContentLengthStrategy outgoingContentStrategy;
 
+    /**
+     * @since 4.4
+     */
     public ManagedHttpClientConnectionFactory(
             final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
-            final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
+            final HttpMessageParserFactory<HttpResponse> responseParserFactory,
+            final ContentLengthStrategy incomingContentStrategy,
+            final ContentLengthStrategy outgoingContentStrategy) {
         super();
         this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory :
-            DefaultHttpRequestWriterFactory.INSTANCE;
+                DefaultHttpRequestWriterFactory.INSTANCE;
         this.responseParserFactory = responseParserFactory != null ? responseParserFactory
:
-            DefaultHttpResponseParserFactory.INSTANCE;
+                DefaultHttpResponseParserFactory.INSTANCE;
+        this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy
:
+                LaxContentLengthStrategy.INSTANCE;
+        this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy
:
+                StrictContentLengthStrategy.INSTANCE;
+    }
+
+    public ManagedHttpClientConnectionFactory(
+            final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
+            final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
+        this(requestWriterFactory, responseParserFactory, null, null);
     }
 
     public ManagedHttpClientConnectionFactory(
@@ -113,8 +133,8 @@ public class ManagedHttpClientConnection
                 chardecoder,
                 charencoder,
                 cconfig.getMessageConstraints(),
-                null,
-                null,
+                incomingContentStrategy,
+                outgoingContentStrategy,
                 requestWriterFactory,
                 responseParserFactory);
     }



Mime
View raw message