Upgraded HttpCore to version 5.0-beta5
This commit is contained in:
parent
674df3aa9e
commit
ab7be3fd53
|
@ -163,7 +163,7 @@ public class HttpCacheEntry implements MessageHeaders, Serializable {
|
||||||
* Returns all the headers that were on the origin response.
|
* Returns all the headers that were on the origin response.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Header[] getAllHeaders() {
|
public Header[] getHeaders() {
|
||||||
final HeaderGroup filteredHeaders = new HeaderGroup();
|
final HeaderGroup filteredHeaders = new HeaderGroup();
|
||||||
for (final Iterator<Header> iterator = responseHeaders.headerIterator(); iterator.hasNext();) {
|
for (final Iterator<Header> iterator = responseHeaders.headerIterator(); iterator.hasNext();) {
|
||||||
final Header header = iterator.next();
|
final Header header = iterator.next();
|
||||||
|
@ -171,7 +171,16 @@ public class HttpCacheEntry implements MessageHeaders, Serializable {
|
||||||
filteredHeaders.addHeader(header);
|
filteredHeaders.addHeader(header);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return filteredHeaders.getAllHeaders();
|
return filteredHeaders.getHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getHeaders()}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public Header[] getAllHeaders() {
|
||||||
|
return getHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,16 +227,34 @@ public class HttpCacheEntry implements MessageHeaders, Serializable {
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
public int countHeaders(final String name) {
|
||||||
|
return responseHeaders.countHeaders(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #countHeaders(String)}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
public int containsHeaders(final String name) {
|
public int containsHeaders(final String name) {
|
||||||
return responseHeaders.containsHeaders(name);
|
return countHeaders(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
public Header getHeader(final String name) throws ProtocolException {
|
||||||
|
return responseHeaders.getHeader(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getHeader(String)}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
public Header getSingleHeader(final String name) throws ProtocolException {
|
public Header getSingleHeader(final String name) throws ProtocolException {
|
||||||
return responseHeaders.getSingleHeader(name);
|
return getHeader(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -454,7 +454,7 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
|
||||||
requestSent,
|
requestSent,
|
||||||
responseReceived,
|
responseReceived,
|
||||||
originResponse.getCode(),
|
originResponse.getCode(),
|
||||||
originResponse.getAllHeaders(),
|
originResponse.getHeaders(),
|
||||||
content != null ? HeapResourceFactory.INSTANCE.generate(null, content.array(), 0, content.length()) : null));
|
content != null ? HeapResourceFactory.INSTANCE.generate(null, content.array(), 0, content.length()) : null));
|
||||||
return Operations.nonCancellable();
|
return Operations.nonCancellable();
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,7 +296,7 @@ class BasicHttpCache implements HttpCache {
|
||||||
requestSent,
|
requestSent,
|
||||||
responseReceived,
|
responseReceived,
|
||||||
originResponse.getCode(),
|
originResponse.getCode(),
|
||||||
originResponse.getAllHeaders(),
|
originResponse.getHeaders(),
|
||||||
content != null ? HeapResourceFactory.INSTANCE.generate(null, content.array(), 0, content.length()) : null);
|
content != null ? HeapResourceFactory.INSTANCE.generate(null, content.array(), 0, content.length()) : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ class CacheUpdateHandler {
|
||||||
requestSent,
|
requestSent,
|
||||||
responseReceived,
|
responseReceived,
|
||||||
originResponse.getCode(),
|
originResponse.getCode(),
|
||||||
originResponse.getAllHeaders(),
|
originResponse.getHeaders(),
|
||||||
content != null ? resourceFactory.generate(request.getRequestUri(), content.array(), 0, content.length()) : null);
|
content != null ? resourceFactory.generate(request.getRequestUri(), content.array(), 0, content.length()) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,17 +126,17 @@ class CacheUpdateHandler {
|
||||||
src.getRequestDate(),
|
src.getRequestDate(),
|
||||||
src.getResponseDate(),
|
src.getResponseDate(),
|
||||||
src.getStatus(),
|
src.getStatus(),
|
||||||
src.getAllHeaders(),
|
src.getHeaders(),
|
||||||
resource,
|
resource,
|
||||||
variantMap);
|
variantMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Header[] mergeHeaders(final HttpCacheEntry entry, final HttpResponse response) {
|
private Header[] mergeHeaders(final HttpCacheEntry entry, final HttpResponse response) {
|
||||||
if (DateUtils.isAfter(entry, response, HttpHeaders.DATE)) {
|
if (DateUtils.isAfter(entry, response, HttpHeaders.DATE)) {
|
||||||
return entry.getAllHeaders();
|
return entry.getHeaders();
|
||||||
}
|
}
|
||||||
final HeaderGroup headerGroup = new HeaderGroup();
|
final HeaderGroup headerGroup = new HeaderGroup();
|
||||||
headerGroup.setHeaders(entry.getAllHeaders());
|
headerGroup.setHeaders(entry.getHeaders());
|
||||||
// Remove cache headers that match response
|
// Remove cache headers that match response
|
||||||
for (final Iterator<Header> it = response.headerIterator(); it.hasNext(); ) {
|
for (final Iterator<Header> it = response.headerIterator(); it.hasNext(); ) {
|
||||||
final Header responseHeader = it.next();
|
final Header responseHeader = it.next();
|
||||||
|
@ -164,7 +164,7 @@ class CacheUpdateHandler {
|
||||||
}
|
}
|
||||||
headerGroup.addHeader(responseHeader);
|
headerGroup.addHeader(responseHeader);
|
||||||
}
|
}
|
||||||
return headerGroup.getAllHeaders();
|
return headerGroup.getHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ class CacheableRequestPolicy {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.containsHeaders(HeaderConstants.PRAGMA) > 0) {
|
if (request.countHeaders(HeaderConstants.PRAGMA) > 0) {
|
||||||
log.debug("request with Pragma header is not serveable from cache");
|
log.debug("request with Pragma header is not serveable from cache");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ class CachedHttpResponseGenerator {
|
||||||
final SimpleHttpResponse response = new SimpleHttpResponse(entry.getStatus());
|
final SimpleHttpResponse response = new SimpleHttpResponse(entry.getStatus());
|
||||||
response.setVersion(HttpVersion.DEFAULT);
|
response.setVersion(HttpVersion.DEFAULT);
|
||||||
|
|
||||||
response.setHeaders(entry.getAllHeaders());
|
response.setHeaders(entry.getHeaders());
|
||||||
|
|
||||||
if (responseShouldContainEntity(request, entry)) {
|
if (responseShouldContainEntity(request, entry)) {
|
||||||
final Resource resource = entry.getResource();
|
final Resource resource = entry.getResource();
|
||||||
|
|
|
@ -57,7 +57,7 @@ class ConditionalRequestBuilder<T extends HttpRequest> {
|
||||||
*/
|
*/
|
||||||
public T buildConditionalRequest(final T request, final HttpCacheEntry cacheEntry) {
|
public T buildConditionalRequest(final T request, final HttpCacheEntry cacheEntry) {
|
||||||
final T newRequest = messageCopier.copy(request);
|
final T newRequest = messageCopier.copy(request);
|
||||||
newRequest.setHeaders(request.getAllHeaders());
|
newRequest.setHeaders(request.getHeaders());
|
||||||
final Header eTag = cacheEntry.getFirstHeader(HeaderConstants.ETAG);
|
final Header eTag = cacheEntry.getFirstHeader(HeaderConstants.ETAG);
|
||||||
if (eTag != null) {
|
if (eTag != null) {
|
||||||
newRequest.setHeader(HeaderConstants.IF_NONE_MATCH, eTag.getValue());
|
newRequest.setHeader(HeaderConstants.IF_NONE_MATCH, eTag.getValue());
|
||||||
|
@ -96,7 +96,7 @@ class ConditionalRequestBuilder<T extends HttpRequest> {
|
||||||
*/
|
*/
|
||||||
public T buildConditionalRequestFromVariants(final T request, final Map<String, Variant> variants) {
|
public T buildConditionalRequestFromVariants(final T request, final Map<String, Variant> variants) {
|
||||||
final T newRequest = messageCopier.copy(request);
|
final T newRequest = messageCopier.copy(request);
|
||||||
newRequest.setHeaders(request.getAllHeaders());
|
newRequest.setHeaders(request.getHeaders());
|
||||||
|
|
||||||
// we do not support partial content so all etags are used
|
// we do not support partial content so all etags are used
|
||||||
final StringBuilder etags = new StringBuilder();
|
final StringBuilder etags = new StringBuilder();
|
||||||
|
|
|
@ -138,17 +138,17 @@ class ResponseCachingPolicy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.containsHeaders(HeaderConstants.AGE) > 1) {
|
if (response.countHeaders(HeaderConstants.AGE) > 1) {
|
||||||
log.debug("Multiple Age headers");
|
log.debug("Multiple Age headers");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.containsHeaders(HeaderConstants.EXPIRES) > 1) {
|
if (response.countHeaders(HeaderConstants.EXPIRES) > 1) {
|
||||||
log.debug("Multiple Expires headers");
|
log.debug("Multiple Expires headers");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.containsHeaders(HttpHeaders.DATE) > 1) {
|
if (response.countHeaders(HttpHeaders.DATE) > 1) {
|
||||||
log.debug("Multiple Date headers");
|
log.debug("Multiple Date headers");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ class ResponseCachingPolicy {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sharedCache) {
|
if (sharedCache) {
|
||||||
if (request.containsHeaders(HeaderConstants.AUTHORIZATION) > 0
|
if (request.countHeaders(HeaderConstants.AUTHORIZATION) > 0
|
||||||
&& !hasCacheControlParameterFrom(response, AUTH_CACHEABLE_PARAMS)) {
|
&& !hasCacheControlParameterFrom(response, AUTH_CACHEABLE_PARAMS)) {
|
||||||
log.debug("Request contains private credentials");
|
log.debug("Request contains private credentials");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -199,7 +199,7 @@ public class TestHttpCacheEntry {
|
||||||
new BasicHeader("Date", DateUtils.formatDate(now))
|
new BasicHeader("Date", DateUtils.formatDate(now))
|
||||||
};
|
};
|
||||||
entry = new HttpCacheEntry(new Date(), new Date(), HttpStatus.SC_OK, headers, mockResource);
|
entry = new HttpCacheEntry(new Date(), new Date(), HttpStatus.SC_OK, headers, mockResource);
|
||||||
final Header[] result = entry.getAllHeaders();
|
final Header[] result = entry.getHeaders();
|
||||||
assertEquals(headers.length, result.length);
|
assertEquals(headers.length, result.length);
|
||||||
for(int i=0; i<headers.length; i++) {
|
for(int i=0; i<headers.length; i++) {
|
||||||
assertEquals(headers[i], result[i]);
|
assertEquals(headers[i], result[i]);
|
||||||
|
|
|
@ -68,8 +68,8 @@ public class HttpCacheEntryMatcher extends BaseMatcher<HttpCacheEntry> {
|
||||||
if (!LangUtils.equals(expectedResponseDate, otherResponseDate)) {
|
if (!LangUtils.equals(expectedResponseDate, otherResponseDate)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Header[] expectedHeaders = expectedValue.getAllHeaders();
|
final Header[] expectedHeaders = expectedValue.getHeaders();
|
||||||
final Header[] otherHeaders = otherValue.getAllHeaders();
|
final Header[] otherHeaders = otherValue.getHeaders();
|
||||||
if (expectedHeaders.length != otherHeaders.length) {
|
if (expectedHeaders.length != otherHeaders.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class HttpTestUtils {
|
||||||
* with the same canonical header values.
|
* with the same canonical header values.
|
||||||
*/
|
*/
|
||||||
public static boolean isEndToEndHeaderSubset(final HttpMessage r1, final HttpMessage r2) {
|
public static boolean isEndToEndHeaderSubset(final HttpMessage r1, final HttpMessage r2) {
|
||||||
for (final Header h : r1.getAllHeaders()) {
|
for (final Header h : r1.getHeaders()) {
|
||||||
if (!isHopByHopHeader(h.getName())) {
|
if (!isHopByHopHeader(h.getName())) {
|
||||||
final String r1val = getCanonicalHeaderValue(r1, h.getName());
|
final String r1val = getCanonicalHeaderValue(r1, h.getName());
|
||||||
final String r2val = getCanonicalHeaderValue(r2, h.getName());
|
final String r2val = getCanonicalHeaderValue(r2, h.getName());
|
||||||
|
|
|
@ -261,7 +261,7 @@ public class TestCacheUpdateHandler {
|
||||||
final HttpCacheEntry updatedEntry = impl.updateCacheEntry(null, entry,
|
final HttpCacheEntry updatedEntry = impl.updateCacheEntry(null, entry,
|
||||||
new Date(), new Date(), response);
|
new Date(), new Date(), response);
|
||||||
|
|
||||||
final Header[] updatedHeaders = updatedEntry.getAllHeaders();
|
final Header[] updatedHeaders = updatedEntry.getHeaders();
|
||||||
headersContain(updatedHeaders, "Content-Encoding", "identity");
|
headersContain(updatedHeaders, "Content-Encoding", "identity");
|
||||||
headersNotContain(updatedHeaders, "Content-Encoding", "gzip");
|
headersNotContain(updatedHeaders, "Content-Encoding", "gzip");
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,13 +77,13 @@ public class TestConditionalRequestBuilder {
|
||||||
|
|
||||||
Assert.assertEquals(theMethod, newRequest.getMethod());
|
Assert.assertEquals(theMethod, newRequest.getMethod());
|
||||||
Assert.assertEquals(theUri, newRequest.getRequestUri());
|
Assert.assertEquals(theUri, newRequest.getRequestUri());
|
||||||
Assert.assertEquals(2, newRequest.getAllHeaders().length);
|
Assert.assertEquals(2, newRequest.getHeaders().length);
|
||||||
|
|
||||||
Assert.assertEquals("Accept-Encoding", newRequest.getAllHeaders()[0].getName());
|
Assert.assertEquals("Accept-Encoding", newRequest.getHeaders()[0].getName());
|
||||||
Assert.assertEquals("gzip", newRequest.getAllHeaders()[0].getValue());
|
Assert.assertEquals("gzip", newRequest.getHeaders()[0].getValue());
|
||||||
|
|
||||||
Assert.assertEquals("If-Modified-Since", newRequest.getAllHeaders()[1].getName());
|
Assert.assertEquals("If-Modified-Since", newRequest.getHeaders()[1].getName());
|
||||||
Assert.assertEquals(lastModified, newRequest.getAllHeaders()[1].getValue());
|
Assert.assertEquals(lastModified, newRequest.getHeaders()[1].getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -133,13 +133,13 @@ public class TestConditionalRequestBuilder {
|
||||||
Assert.assertEquals(theMethod, newRequest.getMethod());
|
Assert.assertEquals(theMethod, newRequest.getMethod());
|
||||||
Assert.assertEquals(theUri, newRequest.getRequestUri());
|
Assert.assertEquals(theUri, newRequest.getRequestUri());
|
||||||
|
|
||||||
Assert.assertEquals(3, newRequest.getAllHeaders().length);
|
Assert.assertEquals(3, newRequest.getHeaders().length);
|
||||||
|
|
||||||
Assert.assertEquals("Accept-Encoding", newRequest.getAllHeaders()[0].getName());
|
Assert.assertEquals("Accept-Encoding", newRequest.getHeaders()[0].getName());
|
||||||
Assert.assertEquals("gzip", newRequest.getAllHeaders()[0].getValue());
|
Assert.assertEquals("gzip", newRequest.getHeaders()[0].getValue());
|
||||||
|
|
||||||
Assert.assertEquals("If-None-Match", newRequest.getAllHeaders()[1].getName());
|
Assert.assertEquals("If-None-Match", newRequest.getHeaders()[1].getName());
|
||||||
Assert.assertEquals(theETag, newRequest.getAllHeaders()[1].getValue());
|
Assert.assertEquals(theETag, newRequest.getHeaders()[1].getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class TestMinimalClientRequestExecution extends LocalServerTestBase {
|
||||||
final HttpRequest reqWrapper = context.getRequest();
|
final HttpRequest reqWrapper = context.getRequest();
|
||||||
Assert.assertNotNull(reqWrapper);
|
Assert.assertNotNull(reqWrapper);
|
||||||
|
|
||||||
final Header[] headers = reqWrapper.getAllHeaders();
|
final Header[] headers = reqWrapper.getHeaders();
|
||||||
final Set<String> headerSet = new HashSet<>();
|
final Set<String> headerSet = new HashSet<>();
|
||||||
for (final Header header: headers) {
|
for (final Header header: headers) {
|
||||||
headerSet.add(header.getName().toLowerCase(Locale.ROOT));
|
headerSet.add(header.getName().toLowerCase(Locale.ROOT));
|
||||||
|
|
|
@ -88,7 +88,12 @@ public class AsyncClientHttp2ServerPush {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int capacity() {
|
protected int remainingCapacity() {
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int capacityIncrement() {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +133,12 @@ public class AsyncClientHttp2ServerPush {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int capacity() {
|
protected int remainingCapacity() {
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int capacityIncrement() {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,12 @@ public class AsyncClientHttpExchangeStreaming {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int capacity() {
|
protected int remainingCapacity() {
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int capacityIncrement() {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,12 @@ public class AsyncQuickStart {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int capacity() {
|
protected int remainingCapacity() {
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int capacityIncrement() {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -434,7 +434,7 @@ public class AsyncRequestBuilder {
|
||||||
new ConfigurableHttpRequest(method, host, !TextUtils.isBlank(path) ? path : "/") :
|
new ConfigurableHttpRequest(method, host, !TextUtils.isBlank(path) ? path : "/") :
|
||||||
new ConfigurableHttpRequest(method, uri != null ? uri : URI.create("/"));
|
new ConfigurableHttpRequest(method, uri != null ? uri : URI.create("/"));
|
||||||
if (this.headergroup != null) {
|
if (this.headergroup != null) {
|
||||||
request.setHeaders(this.headergroup.getAllHeaders());
|
request.setHeaders(this.headergroup.getHeaders());
|
||||||
}
|
}
|
||||||
if (version != null) {
|
if (version != null) {
|
||||||
request.setVersion(version);
|
request.setVersion(version);
|
||||||
|
|
|
@ -280,7 +280,7 @@ public class RequestBuilder {
|
||||||
headerGroup = new HeaderGroup();
|
headerGroup = new HeaderGroup();
|
||||||
}
|
}
|
||||||
headerGroup.clear();
|
headerGroup.clear();
|
||||||
headerGroup.setHeaders(request.getAllHeaders());
|
headerGroup.setHeaders(request.getHeaders());
|
||||||
|
|
||||||
parameters = null;
|
parameters = null;
|
||||||
entity = null;
|
entity = null;
|
||||||
|
@ -483,7 +483,7 @@ public class RequestBuilder {
|
||||||
final HttpUriRequestBase result = new HttpUriRequestBase(method, uriNotNull);
|
final HttpUriRequestBase result = new HttpUriRequestBase(method, uriNotNull);
|
||||||
result.setVersion(this.version != null ? this.version : HttpVersion.HTTP_1_1);
|
result.setVersion(this.version != null ? this.version : HttpVersion.HTTP_1_1);
|
||||||
if (this.headerGroup != null) {
|
if (this.headerGroup != null) {
|
||||||
result.setHeaders(this.headerGroup.getAllHeaders());
|
result.setHeaders(this.headerGroup.getHeaders());
|
||||||
}
|
}
|
||||||
result.setEntity(entityCopy);
|
result.setEntity(entityCopy);
|
||||||
result.setConfig(this.config);
|
result.setConfig(this.config);
|
||||||
|
|
|
@ -143,7 +143,7 @@ public final class AsyncRedirectExec implements AsyncExecChainHandler {
|
||||||
case HttpStatus.SC_SEE_OTHER:
|
case HttpStatus.SC_SEE_OTHER:
|
||||||
if (!StandardMethods.isSafe(request.getMethod())) {
|
if (!StandardMethods.isSafe(request.getMethod())) {
|
||||||
final HttpRequest httpGet = new BasicHttpRequest(StandardMethods.GET.name(), redirectUri);
|
final HttpRequest httpGet = new BasicHttpRequest(StandardMethods.GET.name(), redirectUri);
|
||||||
httpGet.setHeaders(scope.originalRequest.getAllHeaders());
|
httpGet.setHeaders(scope.originalRequest.getHeaders());
|
||||||
state.currentRequest = httpGet;
|
state.currentRequest = httpGet;
|
||||||
state.currentEntityProducer = null;
|
state.currentEntityProducer = null;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.apache.hc.core5.http2.HttpVersionPolicy;
|
||||||
import org.apache.hc.core5.io.CloseMode;
|
import org.apache.hc.core5.io.CloseMode;
|
||||||
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
||||||
import org.apache.hc.core5.util.TimeValue;
|
import org.apache.hc.core5.util.TimeValue;
|
||||||
|
import org.apache.hc.core5.util.Timeout;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
class InternalHttpAsyncExecRuntime implements AsyncExecRuntime {
|
class InternalHttpAsyncExecRuntime implements AsyncExecRuntime {
|
||||||
|
@ -190,7 +191,7 @@ class InternalHttpAsyncExecRuntime implements AsyncExecRuntime {
|
||||||
return Operations.nonCancellable();
|
return Operations.nonCancellable();
|
||||||
}
|
}
|
||||||
final RequestConfig requestConfig = context.getRequestConfig();
|
final RequestConfig requestConfig = context.getRequestConfig();
|
||||||
final TimeValue timeout = requestConfig.getConnectionTimeout();
|
final Timeout timeout = requestConfig.getConnectionTimeout();
|
||||||
return Operations.cancellable(manager.connect(
|
return Operations.cancellable(manager.connect(
|
||||||
endpoint,
|
endpoint,
|
||||||
connectionInitiator,
|
connectionInitiator,
|
||||||
|
@ -202,7 +203,7 @@ class InternalHttpAsyncExecRuntime implements AsyncExecRuntime {
|
||||||
@Override
|
@Override
|
||||||
public void completed(final AsyncConnectionEndpoint endpoint) {
|
public void completed(final AsyncConnectionEndpoint endpoint) {
|
||||||
if (TimeValue.isPositive(timeout)) {
|
if (TimeValue.isPositive(timeout)) {
|
||||||
endpoint.setSocketTimeout(timeout.toMillisIntBound());
|
endpoint.setSocketTimeout(timeout);
|
||||||
}
|
}
|
||||||
callback.completed(InternalHttpAsyncExecRuntime.this);
|
callback.completed(InternalHttpAsyncExecRuntime.this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
|
||||||
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
|
import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
|
||||||
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
|
import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
|
||||||
import org.apache.hc.core5.reactor.ssl.TlsDetails;
|
import org.apache.hc.core5.reactor.ssl.TlsDetails;
|
||||||
|
import org.apache.hc.core5.util.Timeout;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
class LoggingIOSession implements ProtocolIOSession {
|
class LoggingIOSession implements ProtocolIOSession {
|
||||||
|
@ -184,21 +185,21 @@ class LoggingIOSession implements ProtocolIOSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSocketTimeoutMillis() {
|
public Timeout getSocketTimeout() {
|
||||||
return this.session.getSocketTimeoutMillis();
|
return this.session.getSocketTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSocketTimeoutMillis(final int timeout) {
|
public void setSocketTimeout(final Timeout timeout) {
|
||||||
if (this.log.isDebugEnabled()) {
|
if (this.log.isDebugEnabled()) {
|
||||||
this.log.debug(this.id + " " + this.session + ": Set timeout " + timeout);
|
this.log.debug(this.id + " " + this.session + ": Set timeout " + timeout);
|
||||||
}
|
}
|
||||||
this.session.setSocketTimeoutMillis(timeout);
|
this.session.setSocketTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getLastReadTimeMillis() {
|
public long getLastReadTime() {
|
||||||
return this.session.getLastReadTimeMillis();
|
return this.session.getLastReadTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -424,6 +424,11 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
|
||||||
return released.get();
|
return released.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConnected() {
|
||||||
|
return !isReleased() && connectionEndpoint.isConnected();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(
|
public void execute(
|
||||||
final AsyncClientExchangeHandler exchangeHandler,
|
final AsyncClientExchangeHandler exchangeHandler,
|
||||||
|
|
|
@ -93,9 +93,18 @@ public final class CloseableHttpResponse implements ClassicHttpResponse {
|
||||||
return response.getReasonPhrase();
|
return response.getReasonPhrase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #countHeaders(String)}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public int containsHeaders(final String name) {
|
public int containsHeaders(final String name) {
|
||||||
return response.containsHeaders(name);
|
return countHeaders(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countHeaders(final String name) {
|
||||||
|
return response.countHeaders(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -138,9 +147,18 @@ public final class CloseableHttpResponse implements ClassicHttpResponse {
|
||||||
response.setLocale(loc);
|
response.setLocale(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getHeader(String)}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public Header getSingleHeader(final String name) throws ProtocolException {
|
public Header getSingleHeader(final String name) throws ProtocolException {
|
||||||
return response.getSingleHeader(name);
|
return getHeader(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Header getHeader(final String name) throws ProtocolException {
|
||||||
|
return response.getHeader(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -178,9 +196,18 @@ public final class CloseableHttpResponse implements ClassicHttpResponse {
|
||||||
return response.getLastHeader(name);
|
return response.getLastHeader(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getHeaders()}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public Header[] getAllHeaders() {
|
public Header[] getAllHeaders() {
|
||||||
return response.getAllHeaders();
|
return getHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Header[] getHeaders() {
|
||||||
|
return response.getHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -149,10 +149,10 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final RequestConfig requestConfig = context.getRequestConfig();
|
final RequestConfig requestConfig = context.getRequestConfig();
|
||||||
final TimeValue timeout = requestConfig.getConnectionTimeout();
|
final Timeout timeout = requestConfig.getConnectionTimeout();
|
||||||
manager.connect(endpoint, timeout, context);
|
manager.connect(endpoint, timeout, context);
|
||||||
if (TimeValue.isPositive(timeout)) {
|
if (TimeValue.isPositive(timeout)) {
|
||||||
endpoint.setSocketTimeout(timeout.toMillisIntBound());
|
endpoint.setSocketTimeout(timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ public final class RedirectExec implements ExecChainHandler {
|
||||||
case HttpStatus.SC_SEE_OTHER:
|
case HttpStatus.SC_SEE_OTHER:
|
||||||
if (!StandardMethods.isSafe(request.getMethod())) {
|
if (!StandardMethods.isSafe(request.getMethod())) {
|
||||||
final HttpGet httpGet = new HttpGet(redirectUri);
|
final HttpGet httpGet = new HttpGet(redirectUri);
|
||||||
httpGet.setHeaders(originalRequest.getAllHeaders());
|
httpGet.setHeaders(originalRequest.getHeaders());
|
||||||
redirect = httpGet;
|
redirect = httpGet;
|
||||||
} else {
|
} else {
|
||||||
redirect = null;
|
redirect = null;
|
||||||
|
|
|
@ -413,8 +413,8 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSocketTimeout(final int timeout) {
|
public void setSocketTimeout(final Timeout timeout) {
|
||||||
getValidatedConnection().setSocketTimeoutMillis(timeout);
|
getValidatedConnection().setSocketTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -51,6 +51,7 @@ 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;
|
||||||
import org.apache.hc.core5.util.Identifiable;
|
import org.apache.hc.core5.util.Identifiable;
|
||||||
|
import org.apache.hc.core5.util.Timeout;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ final class DefaultManagedHttpClientConnection
|
||||||
private final String id;
|
private final String id;
|
||||||
private final AtomicBoolean closed;
|
private final AtomicBoolean closed;
|
||||||
|
|
||||||
private int socketTimeout;
|
private Timeout socketTimeout;
|
||||||
|
|
||||||
public DefaultManagedHttpClientConnection(
|
public DefaultManagedHttpClientConnection(
|
||||||
final String id,
|
final String id,
|
||||||
|
@ -98,7 +99,7 @@ final class DefaultManagedHttpClientConnection
|
||||||
throw new InterruptedIOException("Connection already shutdown");
|
throw new InterruptedIOException("Connection already shutdown");
|
||||||
}
|
}
|
||||||
super.bind(socketHolder);
|
super.bind(socketHolder);
|
||||||
socketTimeout = socketHolder.getSocket().getSoTimeout();
|
socketTimeout = Timeout.ofMillis(socketHolder.getSocket().getSoTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -128,11 +129,11 @@ final class DefaultManagedHttpClientConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSocketTimeoutMillis(final int timeout) {
|
public void setSocketTimeout(final Timeout timeout) {
|
||||||
if (this.log.isDebugEnabled()) {
|
if (this.log.isDebugEnabled()) {
|
||||||
this.log.debug(this.id + ": set socket timeout to " + timeout);
|
this.log.debug(this.id + ": set socket timeout to " + timeout);
|
||||||
}
|
}
|
||||||
super.setSocketTimeoutMillis(timeout);
|
super.setSocketTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -148,14 +149,14 @@ final class DefaultManagedHttpClientConnection
|
||||||
@Override
|
@Override
|
||||||
public void bind(final Socket socket) throws IOException {
|
public void bind(final Socket socket) throws IOException {
|
||||||
super.bind(this.wireLog.isDebugEnabled() ? new LoggingSocketHolder(socket, this.id, this.wireLog) : new SocketHolder(socket));
|
super.bind(this.wireLog.isDebugEnabled() ? new LoggingSocketHolder(socket, this.id, this.wireLog) : new SocketHolder(socket));
|
||||||
socketTimeout = socket.getSoTimeout();
|
socketTimeout = Timeout.ofMillis(socket.getSoTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResponseReceived(final ClassicHttpResponse response) {
|
protected void onResponseReceived(final ClassicHttpResponse response) {
|
||||||
if (response != null && this.headerLog.isDebugEnabled()) {
|
if (response != null && this.headerLog.isDebugEnabled()) {
|
||||||
this.headerLog.debug(this.id + " << " + new StatusLine(response));
|
this.headerLog.debug(this.id + " << " + new StatusLine(response));
|
||||||
final Header[] headers = response.getAllHeaders();
|
final Header[] headers = response.getHeaders();
|
||||||
for (final Header header : headers) {
|
for (final Header header : headers) {
|
||||||
this.headerLog.debug(this.id + " << " + header.toString());
|
this.headerLog.debug(this.id + " << " + header.toString());
|
||||||
}
|
}
|
||||||
|
@ -166,7 +167,7 @@ final class DefaultManagedHttpClientConnection
|
||||||
protected void onRequestSubmitted(final ClassicHttpRequest request) {
|
protected void onRequestSubmitted(final ClassicHttpRequest request) {
|
||||||
if (request != null && this.headerLog.isDebugEnabled()) {
|
if (request != null && this.headerLog.isDebugEnabled()) {
|
||||||
this.headerLog.debug(this.id + " >> " + new RequestLine(request));
|
this.headerLog.debug(this.id + " >> " + new RequestLine(request));
|
||||||
final Header[] headers = request.getAllHeaders();
|
final Header[] headers = request.getHeaders();
|
||||||
for (final Header header : headers) {
|
for (final Header header : headers) {
|
||||||
this.headerLog.debug(this.id + " >> " + header.toString());
|
this.headerLog.debug(this.id + " >> " + header.toString());
|
||||||
}
|
}
|
||||||
|
@ -175,12 +176,12 @@ final class DefaultManagedHttpClientConnection
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void passivate() {
|
public void passivate() {
|
||||||
super.setSocketTimeoutMillis(0);
|
super.setSocketTimeout(Timeout.ZERO_MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void activate() {
|
public void activate() {
|
||||||
super.setSocketTimeoutMillis(socketTimeout);
|
super.setSocketTimeout(socketTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -547,8 +547,8 @@ public class PoolingHttpClientConnectionManager
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSocketTimeout(final int timeout) {
|
public void setSocketTimeout(final Timeout timeout) {
|
||||||
getValidatedPoolEntry().getConnection().setSocketTimeoutMillis(timeout);
|
getValidatedPoolEntry().getConnection().setSocketTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,7 +46,7 @@ import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
||||||
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
||||||
import org.apache.hc.core5.reactor.IOSession;
|
import org.apache.hc.core5.reactor.IOSession;
|
||||||
import org.apache.hc.core5.util.Args;
|
import org.apache.hc.core5.util.Args;
|
||||||
import org.apache.hc.core5.util.TimeValue;
|
import org.apache.hc.core5.util.Timeout;
|
||||||
|
|
||||||
final class DefaultAsyncClientConnectionOperator implements AsyncClientConnectionOperator {
|
final class DefaultAsyncClientConnectionOperator implements AsyncClientConnectionOperator {
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ final class DefaultAsyncClientConnectionOperator implements AsyncClientConnectio
|
||||||
final ConnectionInitiator connectionInitiator,
|
final ConnectionInitiator connectionInitiator,
|
||||||
final HttpHost host,
|
final HttpHost host,
|
||||||
final SocketAddress localAddress,
|
final SocketAddress localAddress,
|
||||||
final TimeValue connectTimeout,
|
final Timeout connectTimeout,
|
||||||
final Object attachment,
|
final Object attachment,
|
||||||
final FutureCallback<ManagedAsyncClientConnection> callback) {
|
final FutureCallback<ManagedAsyncClientConnection> callback) {
|
||||||
Args.notNull(connectionInitiator, "Connection initiator");
|
Args.notNull(connectionInitiator, "Connection initiator");
|
||||||
|
|
|
@ -53,6 +53,7 @@ import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
|
||||||
import org.apache.hc.core5.reactor.ssl.TlsDetails;
|
import org.apache.hc.core5.reactor.ssl.TlsDetails;
|
||||||
import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
|
import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
|
||||||
import org.apache.hc.core5.util.Identifiable;
|
import org.apache.hc.core5.util.Identifiable;
|
||||||
|
import org.apache.hc.core5.util.Timeout;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -61,12 +62,12 @@ final class DefaultManagedAsyncClientConnection implements ManagedAsyncClientCon
|
||||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
private final IOSession ioSession;
|
private final IOSession ioSession;
|
||||||
private final int socketTimeout;
|
private final Timeout socketTimeout;
|
||||||
private final AtomicBoolean closed;
|
private final AtomicBoolean closed;
|
||||||
|
|
||||||
public DefaultManagedAsyncClientConnection(final IOSession ioSession) {
|
public DefaultManagedAsyncClientConnection(final IOSession ioSession) {
|
||||||
this.ioSession = ioSession;
|
this.ioSession = ioSession;
|
||||||
this.socketTimeout = ioSession.getSocketTimeoutMillis();
|
this.socketTimeout = ioSession.getSocketTimeout();
|
||||||
this.closed = new AtomicBoolean();
|
this.closed = new AtomicBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,13 +102,13 @@ final class DefaultManagedAsyncClientConnection implements ManagedAsyncClientCon
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSocketTimeoutMillis(final int timeout) {
|
public void setSocketTimeout(final Timeout timeout) {
|
||||||
ioSession.setSocketTimeoutMillis(timeout);
|
ioSession.setSocketTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSocketTimeoutMillis() {
|
public Timeout getSocketTimeout() {
|
||||||
return ioSession.getSocketTimeoutMillis();
|
return ioSession.getSocketTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -180,12 +181,12 @@ final class DefaultManagedAsyncClientConnection implements ManagedAsyncClientCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void passivate() {
|
public void passivate() {
|
||||||
ioSession.setSocketTimeoutMillis(0);
|
ioSession.setSocketTimeout(Timeout.ZERO_MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void activate() {
|
public void activate() {
|
||||||
ioSession.setSocketTimeoutMillis(socketTimeout);
|
ioSession.setSocketTimeout(socketTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.apache.hc.core5.concurrent.FutureCallback;
|
||||||
import org.apache.hc.core5.net.NamedEndpoint;
|
import org.apache.hc.core5.net.NamedEndpoint;
|
||||||
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
||||||
import org.apache.hc.core5.reactor.IOSession;
|
import org.apache.hc.core5.reactor.IOSession;
|
||||||
import org.apache.hc.core5.util.TimeValue;
|
import org.apache.hc.core5.util.Timeout;
|
||||||
|
|
||||||
final class MultihomeIOSessionRequester {
|
final class MultihomeIOSessionRequester {
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ final class MultihomeIOSessionRequester {
|
||||||
final NamedEndpoint remoteEndpoint,
|
final NamedEndpoint remoteEndpoint,
|
||||||
final SocketAddress remoteAddress,
|
final SocketAddress remoteAddress,
|
||||||
final SocketAddress localAddress,
|
final SocketAddress localAddress,
|
||||||
final TimeValue connectTimeout,
|
final Timeout connectTimeout,
|
||||||
final Object attachment,
|
final Object attachment,
|
||||||
final FutureCallback<IOSession> callback) {
|
final FutureCallback<IOSession> callback) {
|
||||||
if (remoteAddress != null) {
|
if (remoteAddress != null) {
|
||||||
|
@ -128,7 +128,7 @@ final class MultihomeIOSessionRequester {
|
||||||
final ConnectionInitiator connectionInitiator,
|
final ConnectionInitiator connectionInitiator,
|
||||||
final NamedEndpoint remoteEndpoint,
|
final NamedEndpoint remoteEndpoint,
|
||||||
final SocketAddress localAddress,
|
final SocketAddress localAddress,
|
||||||
final TimeValue connectTimeout,
|
final Timeout connectTimeout,
|
||||||
final Object attachment,
|
final Object attachment,
|
||||||
final FutureCallback<IOSession> callback) {
|
final FutureCallback<IOSession> callback) {
|
||||||
return connect(connectionInitiator, remoteEndpoint, null, localAddress, connectTimeout, attachment, callback);
|
return connect(connectionInitiator, remoteEndpoint, null, localAddress, connectTimeout, attachment, callback);
|
||||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.hc.core5.net.NamedEndpoint;
|
||||||
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
||||||
import org.apache.hc.core5.reactor.IOSession;
|
import org.apache.hc.core5.reactor.IOSession;
|
||||||
import org.apache.hc.core5.util.Args;
|
import org.apache.hc.core5.util.Args;
|
||||||
import org.apache.hc.core5.util.TimeValue;
|
import org.apache.hc.core5.util.Timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multi-home DNS aware implementation of {@link ConnectionInitiator}.
|
* Multi-home DNS aware implementation of {@link ConnectionInitiator}.
|
||||||
|
@ -63,7 +63,7 @@ public final class MultuhomeConnectionInitiator implements ConnectionInitiator {
|
||||||
final NamedEndpoint remoteEndpoint,
|
final NamedEndpoint remoteEndpoint,
|
||||||
final SocketAddress remoteAddress,
|
final SocketAddress remoteAddress,
|
||||||
final SocketAddress localAddress,
|
final SocketAddress localAddress,
|
||||||
final TimeValue connectTimeout,
|
final Timeout connectTimeout,
|
||||||
final Object attachment,
|
final Object attachment,
|
||||||
final FutureCallback<IOSession> callback) {
|
final FutureCallback<IOSession> callback) {
|
||||||
Args.notNull(remoteEndpoint, "Remote endpoint");
|
Args.notNull(remoteEndpoint, "Remote endpoint");
|
||||||
|
@ -73,7 +73,7 @@ public final class MultuhomeConnectionInitiator implements ConnectionInitiator {
|
||||||
public Future<IOSession> connect(
|
public Future<IOSession> connect(
|
||||||
final NamedEndpoint remoteEndpoint,
|
final NamedEndpoint remoteEndpoint,
|
||||||
final SocketAddress localAddress,
|
final SocketAddress localAddress,
|
||||||
final TimeValue connectTimeout,
|
final Timeout connectTimeout,
|
||||||
final Object attachment,
|
final Object attachment,
|
||||||
final FutureCallback<IOSession> callback) {
|
final FutureCallback<IOSession> callback) {
|
||||||
Args.notNull(remoteEndpoint, "Remote endpoint");
|
Args.notNull(remoteEndpoint, "Remote endpoint");
|
||||||
|
|
|
@ -335,7 +335,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
|
||||||
public Future<AsyncConnectionEndpoint> connect(
|
public Future<AsyncConnectionEndpoint> connect(
|
||||||
final AsyncConnectionEndpoint endpoint,
|
final AsyncConnectionEndpoint endpoint,
|
||||||
final ConnectionInitiator connectionInitiator,
|
final ConnectionInitiator connectionInitiator,
|
||||||
final TimeValue timeout,
|
final Timeout timeout,
|
||||||
final Object attachment,
|
final Object attachment,
|
||||||
final HttpContext context,
|
final HttpContext context,
|
||||||
final FutureCallback<AsyncConnectionEndpoint> callback) {
|
final FutureCallback<AsyncConnectionEndpoint> callback) {
|
||||||
|
@ -539,8 +539,8 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSocketTimeout(final int timeout) {
|
public void setSocketTimeout(final Timeout timeout) {
|
||||||
getValidatedPoolEntry().getConnection().setSocketTimeoutMillis(timeout);
|
getValidatedPoolEntry().getConnection().setSocketTimeout(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.hc.core5.http.HttpException;
|
||||||
import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
|
import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
|
||||||
import org.apache.hc.core5.http.protocol.HttpContext;
|
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||||
import org.apache.hc.core5.io.ModalCloseable;
|
import org.apache.hc.core5.io.ModalCloseable;
|
||||||
|
import org.apache.hc.core5.util.Timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client endpoint leased from a connection manager. Client points can be used
|
* Client endpoint leased from a connection manager. Client points can be used
|
||||||
|
@ -75,6 +76,6 @@ public abstract class ConnectionEndpoint implements ModalCloseable {
|
||||||
*
|
*
|
||||||
* @param timeout timeout value
|
* @param timeout timeout value
|
||||||
*/
|
*/
|
||||||
public abstract void setSocketTimeout(int timeout);
|
public abstract void setSocketTimeout(Timeout timeout);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public interface AsyncClientConnectionManager extends ModalCloseable {
|
||||||
* {@link AsyncConnectionEndpoint#isConnected() disconnected}. The consumer
|
* {@link AsyncConnectionEndpoint#isConnected() disconnected}. The consumer
|
||||||
* of the endpoint is responsible for fully establishing the route to
|
* of the endpoint is responsible for fully establishing the route to
|
||||||
* the endpoint target by calling {@link #connect(AsyncConnectionEndpoint,
|
* the endpoint target by calling {@link #connect(AsyncConnectionEndpoint,
|
||||||
* ConnectionInitiator, TimeValue, Object, HttpContext, FutureCallback)}
|
* ConnectionInitiator, Timeout, Object, HttpContext, FutureCallback)}
|
||||||
* in order to connect directly to the target or to the first proxy hop,
|
* in order to connect directly to the target or to the first proxy hop,
|
||||||
* and optionally calling {@link #upgrade(AsyncConnectionEndpoint, Object, HttpContext)}
|
* and optionally calling {@link #upgrade(AsyncConnectionEndpoint, Object, HttpContext)}
|
||||||
* method to upgrade the underlying transport to Transport Layer Security
|
* method to upgrade the underlying transport to Transport Layer Security
|
||||||
|
@ -112,7 +112,7 @@ public interface AsyncClientConnectionManager extends ModalCloseable {
|
||||||
Future<AsyncConnectionEndpoint> connect(
|
Future<AsyncConnectionEndpoint> connect(
|
||||||
AsyncConnectionEndpoint endpoint,
|
AsyncConnectionEndpoint endpoint,
|
||||||
ConnectionInitiator connectionInitiator,
|
ConnectionInitiator connectionInitiator,
|
||||||
TimeValue connectTimeout,
|
Timeout connectTimeout,
|
||||||
Object attachment,
|
Object attachment,
|
||||||
HttpContext context,
|
HttpContext context,
|
||||||
FutureCallback<AsyncConnectionEndpoint> callback);
|
FutureCallback<AsyncConnectionEndpoint> callback);
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
|
||||||
import org.apache.hc.core5.concurrent.FutureCallback;
|
import org.apache.hc.core5.concurrent.FutureCallback;
|
||||||
import org.apache.hc.core5.http.HttpHost;
|
import org.apache.hc.core5.http.HttpHost;
|
||||||
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
import org.apache.hc.core5.reactor.ConnectionInitiator;
|
||||||
import org.apache.hc.core5.util.TimeValue;
|
import org.apache.hc.core5.util.Timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connection operator that performs connection connect and upgrade operations.
|
* Connection operator that performs connection connect and upgrade operations.
|
||||||
|
@ -63,7 +63,7 @@ public interface AsyncClientConnectionOperator {
|
||||||
ConnectionInitiator connectionInitiator,
|
ConnectionInitiator connectionInitiator,
|
||||||
HttpHost host,
|
HttpHost host,
|
||||||
SocketAddress localAddress,
|
SocketAddress localAddress,
|
||||||
TimeValue connectTimeout,
|
Timeout connectTimeout,
|
||||||
Object attachment,
|
Object attachment,
|
||||||
FutureCallback<ManagedAsyncClientConnection> callback);
|
FutureCallback<ManagedAsyncClientConnection> callback);
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.apache.hc.core5.http.protocol.HttpContext;
|
||||||
import org.apache.hc.core5.http.protocol.HttpCoreContext;
|
import org.apache.hc.core5.http.protocol.HttpCoreContext;
|
||||||
import org.apache.hc.core5.io.CloseMode;
|
import org.apache.hc.core5.io.CloseMode;
|
||||||
import org.apache.hc.core5.io.ModalCloseable;
|
import org.apache.hc.core5.io.ModalCloseable;
|
||||||
|
import org.apache.hc.core5.util.Timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client connection endpoint that can be used to execute message exchanges.
|
* Client connection endpoint that can be used to execute message exchanges.
|
||||||
|
@ -75,7 +76,7 @@ public abstract class AsyncConnectionEndpoint implements ModalCloseable {
|
||||||
*
|
*
|
||||||
* @param timeout the socket timeout.
|
* @param timeout the socket timeout.
|
||||||
*/
|
*/
|
||||||
public abstract void setSocketTimeout(int timeout);
|
public abstract void setSocketTimeout(Timeout timeout);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void close() throws IOException {
|
public final void close() throws IOException {
|
||||||
|
|
|
@ -273,8 +273,8 @@ public class TestInternalExecRuntime {
|
||||||
|
|
||||||
execRuntime.connectEndpoint(context);
|
execRuntime.connectEndpoint(context);
|
||||||
|
|
||||||
Mockito.verify(mgr).connect(connectionEndpoint, TimeValue.ofMillis(123), context);
|
Mockito.verify(mgr).connect(connectionEndpoint, Timeout.ofMillis(123), context);
|
||||||
Mockito.verify(connectionEndpoint).setSocketTimeout(123);
|
Mockito.verify(connectionEndpoint).setSocketTimeout(Timeout.ofMillis(123));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class TestRetryExec {
|
||||||
public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
|
public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
|
||||||
final Object[] args = invocationOnMock.getArguments();
|
final Object[] args = invocationOnMock.getArguments();
|
||||||
final ClassicHttpRequest wrapper = (ClassicHttpRequest) args[0];
|
final ClassicHttpRequest wrapper = (ClassicHttpRequest) args[0];
|
||||||
final Header[] headers = wrapper.getAllHeaders();
|
final Header[] headers = wrapper.getHeaders();
|
||||||
Assert.assertEquals(2, headers.length);
|
Assert.assertEquals(2, headers.length);
|
||||||
Assert.assertEquals("this", headers[0].getValue());
|
Assert.assertEquals("this", headers[0].getValue());
|
||||||
Assert.assertEquals("that", headers[1].getValue());
|
Assert.assertEquals("that", headers[1].getValue());
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class TestRequestExpectContinue {
|
||||||
final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/");
|
final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/");
|
||||||
final RequestExpectContinue interceptor = new RequestExpectContinue();
|
final RequestExpectContinue interceptor = new RequestExpectContinue();
|
||||||
interceptor.process(request, null, context);
|
interceptor.process(request, null, context);
|
||||||
Assert.assertEquals(0, request.getAllHeaders().length);
|
Assert.assertEquals(0, request.getHeaders().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
7
pom.xml
7
pom.xml
|
@ -68,7 +68,7 @@
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.7</maven.compiler.source>
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
<maven.compiler.target>1.7</maven.compiler.target>
|
<maven.compiler.target>1.7</maven.compiler.target>
|
||||||
<httpcore.version>5.0-beta3</httpcore.version>
|
<httpcore.version>5.0-beta5</httpcore.version>
|
||||||
<log4j.version>2.9.1</log4j.version>
|
<log4j.version>2.9.1</log4j.version>
|
||||||
<commons-codec.version>1.11</commons-codec.version>
|
<commons-codec.version>1.11</commons-codec.version>
|
||||||
<ehcache.version>3.4.0</ehcache.version>
|
<ehcache.version>3.4.0</ehcache.version>
|
||||||
|
@ -98,6 +98,11 @@
|
||||||
<artifactId>httpcore5-testing</artifactId>
|
<artifactId>httpcore5-testing</artifactId>
|
||||||
<version>${httpcore.version}</version>
|
<version>${httpcore.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents.core5</groupId>
|
||||||
|
<artifactId>httpcore5-reactive</artifactId>
|
||||||
|
<version>${httpcore.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue