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.io.HttpMessageParserFactory;
|
||||
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.StatusLine;
|
||||
import org.apache.hc.core5.io.CloseMode;
|
||||
|
@ -74,13 +75,43 @@ final class DefaultManagedHttpClientConnection
|
|||
final Http1Config h1Config,
|
||||
final ContentLengthStrategy incomingContentStrategy,
|
||||
final ContentLengthStrategy outgoingContentStrategy,
|
||||
final ResponseOutOfOrderStrategy responseOutOfOrderStrategy,
|
||||
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
|
||||
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.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) {
|
||||
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.impl.DefaultContentLengthStrategy;
|
||||
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.HttpMessageParserFactory;
|
||||
import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
|
||||
import org.apache.hc.core5.http.io.ResponseOutOfOrderStrategy;
|
||||
|
||||
/**
|
||||
* Factory for {@link ManagedHttpClientConnection} instances.
|
||||
|
@ -66,15 +68,16 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
|||
private final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory;
|
||||
private final ContentLengthStrategy incomingContentStrategy;
|
||||
private final ContentLengthStrategy outgoingContentStrategy;
|
||||
private final ResponseOutOfOrderStrategy responseOutOfOrderStrategy;
|
||||
|
||||
public ManagedHttpClientConnectionFactory(
|
||||
private ManagedHttpClientConnectionFactory(
|
||||
final Http1Config h1Config,
|
||||
final CharCodingConfig charCodingConfig,
|
||||
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory,
|
||||
final HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory,
|
||||
final ContentLengthStrategy incomingContentStrategy,
|
||||
final ContentLengthStrategy outgoingContentStrategy) {
|
||||
super();
|
||||
final ContentLengthStrategy outgoingContentStrategy,
|
||||
final ResponseOutOfOrderStrategy responseOutOfOrderStrategy) {
|
||||
this.h1Config = h1Config != null ? h1Config : Http1Config.DEFAULT;
|
||||
this.charCodingConfig = charCodingConfig != null ? charCodingConfig : CharCodingConfig.DEFAULT;
|
||||
this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory :
|
||||
|
@ -85,6 +88,25 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
|||
DefaultContentLengthStrategy.INSTANCE;
|
||||
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
|
||||
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(
|
||||
|
@ -131,6 +153,7 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
|||
h1Config,
|
||||
incomingContentStrategy,
|
||||
outgoingContentStrategy,
|
||||
responseOutOfOrderStrategy,
|
||||
requestWriterFactory,
|
||||
responseParserFactory);
|
||||
if (socket != null) {
|
||||
|
@ -159,6 +182,7 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
|||
private CharCodingConfig charCodingConfig;
|
||||
private ContentLengthStrategy incomingContentLengthStrategy;
|
||||
private ContentLengthStrategy outgoingContentLengthStrategy;
|
||||
private ResponseOutOfOrderStrategy responseOutOfOrderStrategy;
|
||||
private HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory;
|
||||
private HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory;
|
||||
|
||||
|
@ -184,6 +208,11 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder responseOutOfOrderStrategy(final ResponseOutOfOrderStrategy responseOutOfOrderStrategy) {
|
||||
this.responseOutOfOrderStrategy = responseOutOfOrderStrategy;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder requestWriterFactory(
|
||||
final HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory) {
|
||||
this.requestWriterFactory = requestWriterFactory;
|
||||
|
@ -203,7 +232,8 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
|
|||
requestWriterFactory,
|
||||
responseParserFactory,
|
||||
incomingContentLengthStrategy,
|
||||
outgoingContentLengthStrategy);
|
||||
outgoingContentLengthStrategy,
|
||||
responseOutOfOrderStrategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue