HTTPCLIENT-2104: ManagedHttpClientConnectionFactory supports ResponseOutOfOrderStrategy configuration
This commit is contained in:
parent
22cf9671b1
commit
8d5cfd326e
|
@ -47,6 +47,7 @@ import org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection;
|
||||||
import org.apache.hc.core5.http.impl.io.SocketHolder;
|
import org.apache.hc.core5.http.impl.io.SocketHolder;
|
||||||
import org.apache.hc.core5.http.io.HttpMessageParserFactory;
|
import org.apache.hc.core5.http.io.HttpMessageParserFactory;
|
||||||
import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
|
import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
|
||||||
|
import org.apache.hc.core5.http.io.ResponseOutOfOrderStrategy;
|
||||||
import org.apache.hc.core5.http.message.RequestLine;
|
import org.apache.hc.core5.http.message.RequestLine;
|
||||||
import org.apache.hc.core5.http.message.StatusLine;
|
import org.apache.hc.core5.http.message.StatusLine;
|
||||||
import org.apache.hc.core5.io.CloseMode;
|
import org.apache.hc.core5.io.CloseMode;
|
||||||
|
@ -74,13 +75,43 @@ final class DefaultManagedHttpClientConnection
|
||||||
final Http1Config h1Config,
|
final Http1Config h1Config,
|
||||||
final ContentLengthStrategy incomingContentStrategy,
|
final ContentLengthStrategy incomingContentStrategy,
|
||||||
final ContentLengthStrategy outgoingContentStrategy,
|
final ContentLengthStrategy outgoingContentStrategy,
|
||||||
|
final ResponseOutOfOrderStrategy responseOutOfOrderStrategy,
|
||||||
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
|
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
|
||||||
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
|
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
|
||||||
super(h1Config, charDecoder, charEncoder, incomingContentStrategy, outgoingContentStrategy, requestWriterFactory, responseParserFactory);
|
super(
|
||||||
|
h1Config,
|
||||||
|
charDecoder,
|
||||||
|
charEncoder,
|
||||||
|
incomingContentStrategy,
|
||||||
|
outgoingContentStrategy,
|
||||||
|
responseOutOfOrderStrategy,
|
||||||
|
requestWriterFactory,
|
||||||
|
responseParserFactory);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.closed = new AtomicBoolean();
|
this.closed = new AtomicBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DefaultManagedHttpClientConnection(
|
||||||
|
final String id,
|
||||||
|
final CharsetDecoder charDecoder,
|
||||||
|
final CharsetEncoder charEncoder,
|
||||||
|
final Http1Config h1Config,
|
||||||
|
final ContentLengthStrategy incomingContentStrategy,
|
||||||
|
final ContentLengthStrategy outgoingContentStrategy,
|
||||||
|
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
|
||||||
|
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory) {
|
||||||
|
this(
|
||||||
|
id,
|
||||||
|
charDecoder,
|
||||||
|
charEncoder,
|
||||||
|
h1Config,
|
||||||
|
incomingContentStrategy,
|
||||||
|
outgoingContentStrategy,
|
||||||
|
null,
|
||||||
|
requestWriterFactory,
|
||||||
|
responseParserFactory);
|
||||||
|
}
|
||||||
|
|
||||||
public DefaultManagedHttpClientConnection(final String id) {
|
public DefaultManagedHttpClientConnection(final String id) {
|
||||||
this(id, null, null, null, null, null, null, null);
|
this(id, null, null, null, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,11 @@ import org.apache.hc.core5.http.config.CharCodingConfig;
|
||||||
import org.apache.hc.core5.http.config.Http1Config;
|
import org.apache.hc.core5.http.config.Http1Config;
|
||||||
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
|
import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
|
||||||
import org.apache.hc.core5.http.impl.io.DefaultHttpRequestWriterFactory;
|
import org.apache.hc.core5.http.impl.io.DefaultHttpRequestWriterFactory;
|
||||||
|
import org.apache.hc.core5.http.impl.io.NoResponseOutOfOrderStrategy;
|
||||||
import org.apache.hc.core5.http.io.HttpConnectionFactory;
|
import org.apache.hc.core5.http.io.HttpConnectionFactory;
|
||||||
import org.apache.hc.core5.http.io.HttpMessageParserFactory;
|
import org.apache.hc.core5.http.io.HttpMessageParserFactory;
|
||||||
import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
|
import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
|
||||||
|
import org.apache.hc.core5.http.io.ResponseOutOfOrderStrategy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory for {@link ManagedHttpClientConnection} instances.
|
* Factory for {@link ManagedHttpClientConnection} instances.
|
||||||
|
@ -66,15 +68,16 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
||||||
private final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory;
|
private final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory;
|
||||||
private final ContentLengthStrategy incomingContentStrategy;
|
private final ContentLengthStrategy incomingContentStrategy;
|
||||||
private final ContentLengthStrategy outgoingContentStrategy;
|
private final ContentLengthStrategy outgoingContentStrategy;
|
||||||
|
private final ResponseOutOfOrderStrategy responseOutOfOrderStrategy;
|
||||||
|
|
||||||
public ManagedHttpClientConnectionFactory(
|
private ManagedHttpClientConnectionFactory(
|
||||||
final Http1Config h1Config,
|
final Http1Config h1Config,
|
||||||
final CharCodingConfig charCodingConfig,
|
final CharCodingConfig charCodingConfig,
|
||||||
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
|
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
|
||||||
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory,
|
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory,
|
||||||
final ContentLengthStrategy incomingContentStrategy,
|
final ContentLengthStrategy incomingContentStrategy,
|
||||||
final ContentLengthStrategy outgoingContentStrategy) {
|
final ContentLengthStrategy outgoingContentStrategy,
|
||||||
super();
|
final ResponseOutOfOrderStrategy responseOutOfOrderStrategy) {
|
||||||
this.h1Config = h1Config != null ? h1Config : Http1Config.DEFAULT;
|
this.h1Config = h1Config != null ? h1Config : Http1Config.DEFAULT;
|
||||||
this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT;
|
this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT;
|
||||||
this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory :
|
this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory :
|
||||||
|
@ -85,6 +88,25 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
||||||
DefaultContentLengthStrategy.INSTANCE;
|
DefaultContentLengthStrategy.INSTANCE;
|
||||||
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
|
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
|
||||||
DefaultContentLengthStrategy.INSTANCE;
|
DefaultContentLengthStrategy.INSTANCE;
|
||||||
|
this.responseOutOfOrderStrategy = responseOutOfOrderStrategy != null ? responseOutOfOrderStrategy :
|
||||||
|
NoResponseOutOfOrderStrategy.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ManagedHttpClientConnectionFactory(
|
||||||
|
final Http1Config h1Config,
|
||||||
|
final CharCodingConfig charCodingConfig,
|
||||||
|
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
|
||||||
|
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory,
|
||||||
|
final ContentLengthStrategy incomingContentStrategy,
|
||||||
|
final ContentLengthStrategy outgoingContentStrategy) {
|
||||||
|
this(
|
||||||
|
h1Config,
|
||||||
|
charCodingConfig,
|
||||||
|
requestWriterFactory,
|
||||||
|
responseParserFactory,
|
||||||
|
incomingContentStrategy,
|
||||||
|
outgoingContentStrategy,
|
||||||
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManagedHttpClientConnectionFactory(
|
public ManagedHttpClientConnectionFactory(
|
||||||
|
@ -131,6 +153,7 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
||||||
h1Config,
|
h1Config,
|
||||||
incomingContentStrategy,
|
incomingContentStrategy,
|
||||||
outgoingContentStrategy,
|
outgoingContentStrategy,
|
||||||
|
responseOutOfOrderStrategy,
|
||||||
requestWriterFactory,
|
requestWriterFactory,
|
||||||
responseParserFactory);
|
responseParserFactory);
|
||||||
if (socket != null) {
|
if (socket != null) {
|
||||||
|
@ -159,6 +182,7 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
||||||
private CharCodingConfig charCodingConfig;
|
private CharCodingConfig charCodingConfig;
|
||||||
private ContentLengthStrategy incomingContentLengthStrategy;
|
private ContentLengthStrategy incomingContentLengthStrategy;
|
||||||
private ContentLengthStrategy outgoingContentLengthStrategy;
|
private ContentLengthStrategy outgoingContentLengthStrategy;
|
||||||
|
private ResponseOutOfOrderStrategy responseOutOfOrderStrategy;
|
||||||
private HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory;
|
private HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory;
|
||||||
private HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory;
|
private HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory;
|
||||||
|
|
||||||
|
@ -184,6 +208,11 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder responseOutOfOrderStrategy(final ResponseOutOfOrderStrategy responseOutOfOrderStrategy) {
|
||||||
|
this.responseOutOfOrderStrategy = responseOutOfOrderStrategy;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder requestWriterFactory(
|
public Builder requestWriterFactory(
|
||||||
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory) {
|
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory) {
|
||||||
this.requestWriterFactory = requestWriterFactory;
|
this.requestWriterFactory = requestWriterFactory;
|
||||||
|
@ -203,7 +232,8 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
||||||
requestWriterFactory,
|
requestWriterFactory,
|
||||||
responseParserFactory,
|
responseParserFactory,
|
||||||
incomingContentLengthStrategy,
|
incomingContentLengthStrategy,
|
||||||
outgoingContentLengthStrategy);
|
outgoingContentLengthStrategy,
|
||||||
|
responseOutOfOrderStrategy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue