Added optional parameters for content length strategies
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1627507 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1d09a8308f
commit
0f227fa940
|
@ -42,6 +42,9 @@ import org.apache.http.config.ConnectionConfig;
|
||||||
import org.apache.http.conn.HttpConnectionFactory;
|
import org.apache.http.conn.HttpConnectionFactory;
|
||||||
import org.apache.http.conn.ManagedHttpClientConnection;
|
import org.apache.http.conn.ManagedHttpClientConnection;
|
||||||
import org.apache.http.conn.routing.HttpRoute;
|
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.impl.io.DefaultHttpRequestWriterFactory;
|
||||||
import org.apache.http.io.HttpMessageParserFactory;
|
import org.apache.http.io.HttpMessageParserFactory;
|
||||||
import org.apache.http.io.HttpMessageWriterFactory;
|
import org.apache.http.io.HttpMessageWriterFactory;
|
||||||
|
@ -64,15 +67,32 @@ public class ManagedHttpClientConnectionFactory
|
||||||
|
|
||||||
private final HttpMessageWriterFactory<HttpRequest> requestWriterFactory;
|
private final HttpMessageWriterFactory<HttpRequest> requestWriterFactory;
|
||||||
private final HttpMessageParserFactory<HttpResponse> responseParserFactory;
|
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 ContentLengthStrategy incomingContentStrategy,
|
||||||
|
final ContentLengthStrategy outgoingContentStrategy) {
|
||||||
|
super();
|
||||||
|
this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory :
|
||||||
|
DefaultHttpRequestWriterFactory.INSTANCE;
|
||||||
|
this.responseParserFactory = responseParserFactory != null ? responseParserFactory :
|
||||||
|
DefaultHttpResponseParserFactory.INSTANCE;
|
||||||
|
this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
|
||||||
|
LaxContentLengthStrategy.INSTANCE;
|
||||||
|
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
|
||||||
|
StrictContentLengthStrategy.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
public ManagedHttpClientConnectionFactory(
|
public ManagedHttpClientConnectionFactory(
|
||||||
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
|
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
|
||||||
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
|
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
|
||||||
super();
|
this(requestWriterFactory, responseParserFactory, null, null);
|
||||||
this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory :
|
|
||||||
DefaultHttpRequestWriterFactory.INSTANCE;
|
|
||||||
this.responseParserFactory = responseParserFactory != null ? responseParserFactory :
|
|
||||||
DefaultHttpResponseParserFactory.INSTANCE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManagedHttpClientConnectionFactory(
|
public ManagedHttpClientConnectionFactory(
|
||||||
|
@ -113,8 +133,8 @@ public class ManagedHttpClientConnectionFactory
|
||||||
chardecoder,
|
chardecoder,
|
||||||
charencoder,
|
charencoder,
|
||||||
cconfig.getMessageConstraints(),
|
cconfig.getMessageConstraints(),
|
||||||
null,
|
incomingContentStrategy,
|
||||||
null,
|
outgoingContentStrategy,
|
||||||
requestWriterFactory,
|
requestWriterFactory,
|
||||||
responseParserFactory);
|
responseParserFactory);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue