safeRequestMethods = new HashSet<>(
@@ -199,7 +199,7 @@ class BasicHttpCache implements HttpCache {
&& status != HttpStatus.SC_PARTIAL_CONTENT) {
return false;
}
- final Header hdr = resp.getFirstHeader(HTTP.CONTENT_LEN);
+ final Header hdr = resp.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
if (hdr == null) {
return false;
}
@@ -217,7 +217,7 @@ class BasicHttpCache implements HttpCache {
CloseableHttpResponse generateIncompleteResponseError(
final HttpResponse response, final Resource resource) {
- final Integer contentLength = Integer.valueOf(response.getFirstHeader(HTTP.CONTENT_LEN).getValue());
+ final Integer contentLength = Integer.valueOf(response.getFirstHeader(HttpHeaders.CONTENT_LENGTH).getValue());
final HttpResponse error =
new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_BAD_GATEWAY, "Bad Gateway");
error.setHeader("Content-Type","text/plain;charset=UTF-8");
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java
index 76a525c42..0f65a039b 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCacheStorage.java
@@ -28,7 +28,7 @@ package org.apache.http.impl.client.cache;
import java.io.IOException;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheStorage;
import org.apache.http.client.cache.HttpCacheUpdateCallback;
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicIdGenerator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicIdGenerator.java
index 04236abdc..2a3b67b92 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicIdGenerator.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicIdGenerator.java
@@ -33,8 +33,8 @@ import java.security.SecureRandom;
import java.util.Formatter;
import java.util.Locale;
-import org.apache.http.annotation.GuardedBy;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.GuardedBy;
+import org.apache.hc.core5.annotation.ThreadSafe;
/**
* Should produce reasonably unique tokens.
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java
index 1d436b0ea..1cf2d0e0e 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheConfig.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.client.cache;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.util.Args;
/**
* Java Beans-style configuration for caching {@link org.apache.http.client.HttpClient}.
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java
index 881cb7ae7..5d607c195 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntity.java
@@ -30,13 +30,15 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
+import java.util.Set;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.TrailerSupplier;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.cache.HttpCacheEntry;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.Args;
@Immutable
class CacheEntity implements HttpEntity, Serializable {
@@ -51,13 +53,15 @@ class CacheEntity implements HttpEntity, Serializable {
}
@Override
- public Header getContentType() {
- return this.cacheEntry.getFirstHeader(HTTP.CONTENT_TYPE);
+ public String getContentType() {
+ final Header header = this.cacheEntry.getFirstHeader(HttpHeaders.CONTENT_TYPE);
+ return header != null ? header.getValue() : null;
}
@Override
- public Header getContentEncoding() {
- return this.cacheEntry.getFirstHeader(HTTP.CONTENT_ENCODING);
+ public String getContentEncoding() {
+ final Header header = this.cacheEntry.getFirstHeader(HttpHeaders.CONTENT_ENCODING);
+ return header != null ? header.getValue() : null;
}
@Override
@@ -94,7 +98,13 @@ class CacheEntity implements HttpEntity, Serializable {
}
@Override
- public void consumeContent() throws IOException {
+ public TrailerSupplier getTrailers() {
+ return null;
+ }
+
+ @Override
+ public Set getTrailerNames() {
+ return null;
}
}
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java
index 926fbce91..6991b776d 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheEntryUpdater.java
@@ -33,17 +33,17 @@ import java.util.Date;
import java.util.List;
import java.util.ListIterator;
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.Resource;
import org.apache.http.client.cache.ResourceFactory;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.Args;
/**
* Update a {@link HttpCacheEntry} with new or updated information based on the latest
@@ -149,9 +149,9 @@ class CacheEntryUpdater {
}
private boolean entryDateHeaderNewerThenResponse(final HttpCacheEntry entry, final HttpResponse response) {
- final Date entryDate = DateUtils.parseDate(entry.getFirstHeader(HTTP.DATE_HEADER)
+ final Date entryDate = DateUtils.parseDate(entry.getFirstHeader(HttpHeaders.DATE)
.getValue());
- final Date responseDate = DateUtils.parseDate(response.getFirstHeader(HTTP.DATE_HEADER)
+ final Date responseDate = DateUtils.parseDate(response.getFirstHeader(HttpHeaders.DATE)
.getValue());
if (entryDate == null || responseDate == null) {
return false;
@@ -163,8 +163,8 @@ class CacheEntryUpdater {
}
private boolean entryAndResponseHaveDateHeader(final HttpCacheEntry entry, final HttpResponse response) {
- if (entry.getFirstHeader(HTTP.DATE_HEADER) != null
- && response.getFirstHeader(HTTP.DATE_HEADER) != null) {
+ if (entry.getFirstHeader(HttpHeaders.DATE) != null
+ && response.getFirstHeader(HttpHeaders.DATE) != null) {
return true;
}
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java
index 57c2d913b..54665887c 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java
@@ -33,17 +33,17 @@ import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheInvalidator;
import org.apache.http.client.cache.HttpCacheStorage;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.protocol.HTTP;
/**
* Given a particular HttpRequest, flush any cache entries that this request
@@ -282,8 +282,8 @@ class CacheInvalidator implements HttpCacheInvalidator {
private boolean responseDateOlderThanEntryDate(final HttpResponse response,
final HttpCacheEntry entry) {
- final Header entryDateHeader = entry.getFirstHeader(HTTP.DATE_HEADER);
- final Header responseDateHeader = response.getFirstHeader(HTTP.DATE_HEADER);
+ final Header entryDateHeader = entry.getFirstHeader(HttpHeaders.DATE);
+ final Header responseDateHeader = response.getFirstHeader(HttpHeaders.DATE);
if (entryDateHeader == null || responseDateHeader == null) {
/* be conservative; should probably flush */
return false;
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java
index 9244a3bf8..4b4b98ac7 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java
@@ -31,16 +31,16 @@ import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.apache.http.Consts;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.utils.URIUtils;
@@ -162,10 +162,10 @@ class CacheKeyGenerator {
if (!first) {
buf.append("&");
}
- buf.append(URLEncoder.encode(headerName, Consts.UTF_8.name()));
+ buf.append(URLEncoder.encode(headerName, StandardCharsets.UTF_8.name()));
buf.append("=");
buf.append(URLEncoder.encode(getFullHeaderValue(req.getHeaders(headerName)),
- Consts.UTF_8.name()));
+ StandardCharsets.UTF_8.name()));
first = false;
}
buf.append("}");
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java
index 0116a77b7..bf7263f53 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java
@@ -28,14 +28,14 @@ package org.apache.http.impl.client.cache;
import java.util.Date;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpRequest;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.protocol.HTTP;
/**
* @since 4.1
@@ -180,7 +180,7 @@ class CacheValidityPolicy {
}
protected long getContentLengthValue(final HttpCacheEntry entry) {
- final Header cl = entry.getFirstHeader(HTTP.CONTENT_LEN);
+ final Header cl = entry.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
if (cl == null) {
return -1;
}
@@ -193,7 +193,7 @@ class CacheValidityPolicy {
}
protected boolean hasContentLengthHeader(final HttpCacheEntry entry) {
- return null != entry.getFirstHeader(HTTP.CONTENT_LEN);
+ return null != entry.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
}
/**
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheableRequestPolicy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheableRequestPolicy.java
index d7877034e..7906f89c5 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheableRequestPolicy.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheableRequestPolicy.java
@@ -28,12 +28,12 @@ package org.apache.http.impl.client.cache;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
import org.apache.http.client.cache.HeaderConstants;
/**
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java
index f74a2e42c..4bd48d68f 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java
@@ -28,20 +28,20 @@ package org.apache.http.impl.client.cache;
import java.util.Date;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.protocol.HTTP;
/**
* Rebuilds an {@link HttpResponse} from a {@link net.sf.ehcache.CacheEntry}
@@ -63,7 +63,7 @@ class CachedHttpResponseGenerator {
}
/**
- * If I was able to use a {@link CacheEntity} to response to the {@link org.apache.http.HttpRequest} then
+ * If I was able to use a {@link CacheEntity} to response to the {@link org.apache.hc.core5.http.HttpRequest} then
* generate an {@link HttpResponse} based on the cache entry.
* @param request {@link HttpRequestWrapper} to generate the response for
* @param entry {@link CacheEntity} to transform into an {@link HttpResponse}
@@ -107,9 +107,9 @@ class CachedHttpResponseGenerator {
// (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)
// - Date, unless its omission is required by section 14.8.1
- Header dateHeader = entry.getFirstHeader(HTTP.DATE_HEADER);
+ Header dateHeader = entry.getFirstHeader(HttpHeaders.DATE);
if (dateHeader == null) {
- dateHeader = new BasicHeader(HTTP.DATE_HEADER, DateUtils.formatDate(new Date()));
+ dateHeader = new BasicHeader(HttpHeaders.DATE, DateUtils.formatDate(new Date()));
}
response.addHeader(dateHeader);
@@ -151,16 +151,16 @@ class CachedHttpResponseGenerator {
return;
}
- Header contentLength = response.getFirstHeader(HTTP.CONTENT_LEN);
+ Header contentLength = response.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
if (contentLength == null) {
- contentLength = new BasicHeader(HTTP.CONTENT_LEN, Long.toString(entity
+ contentLength = new BasicHeader(HttpHeaders.CONTENT_LENGTH, Long.toString(entity
.getContentLength()));
response.setHeader(contentLength);
}
}
private boolean transferEncodingIsPresent(final HttpResponse response) {
- final Header hdr = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
+ final Header hdr = response.getFirstHeader(HttpHeaders.TRANSFER_ENCODING);
return hdr != null;
}
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java
index e7c940c6e..ad05c81cb 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java
@@ -30,12 +30,12 @@ import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpStatus;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpStatus;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.utils.DateUtils;
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java
index 4182859cb..84f28a8e6 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java
@@ -37,19 +37,25 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpMessage;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolException;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.RequestLine;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpMessage;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.RequestLine;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.VersionInfo;
import org.apache.http.client.cache.CacheResponseStatus;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheContext;
@@ -64,12 +70,6 @@ import org.apache.http.client.utils.DateUtils;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.execchain.ClientExecChain;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpCoreContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.VersionInfo;
/**
*
@@ -306,7 +306,6 @@ public class CachingExec implements ClientExecChain {
context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, target);
context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
context.setAttribute(HttpCoreContext.HTTP_RESPONSE, out);
- context.setAttribute(HttpCoreContext.HTTP_REQ_SENT, Boolean.TRUE);
return out;
}
@@ -602,8 +601,8 @@ public class CachingExec implements ClientExecChain {
private boolean revalidationResponseIsTooOld(final HttpResponse backendResponse,
final HttpCacheEntry cacheEntry) {
- final Header entryDateHeader = cacheEntry.getFirstHeader(HTTP.DATE_HEADER);
- final Header responseDateHeader = backendResponse.getFirstHeader(HTTP.DATE_HEADER);
+ final Header entryDateHeader = cacheEntry.getFirstHeader(HttpHeaders.DATE);
+ final Header responseDateHeader = backendResponse.getFirstHeader(HttpHeaders.DATE);
if (entryDateHeader != null && responseDateHeader != null) {
final Date entryDate = DateUtils.parseDate(entryDateHeader.getValue());
final Date respDate = DateUtils.parseDate(responseDateHeader.getValue());
@@ -866,11 +865,11 @@ public class CachingExec implements ClientExecChain {
if (existing == null) {
return false;
}
- final Header entryDateHeader = existing.getFirstHeader(HTTP.DATE_HEADER);
+ final Header entryDateHeader = existing.getFirstHeader(HttpHeaders.DATE);
if (entryDateHeader == null) {
return false;
}
- final Header responseDateHeader = backendResponse.getFirstHeader(HTTP.DATE_HEADER);
+ final Header responseDateHeader = backendResponse.getFirstHeader(HttpHeaders.DATE);
if (responseDateHeader == null) {
return false;
}
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClients.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClients.java
index 35beb6dde..c73012cbe 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClients.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClients.java
@@ -29,7 +29,7 @@ package org.apache.http.impl.client.cache;
import java.io.File;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
import org.apache.http.impl.client.CloseableHttpClient;
/**
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java
index 5a895339e..e2e7a72dc 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CombinedEntity.java
@@ -32,10 +32,10 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.SequenceInputStream;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.entity.AbstractHttpEntity;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.cache.Resource;
-import org.apache.http.entity.AbstractHttpEntity;
-import org.apache.http.util.Args;
@NotThreadSafe
class CombinedEntity extends AbstractHttpEntity {
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ConditionalRequestBuilder.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ConditionalRequestBuilder.java
index 0f4bd0962..c1cd72917 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ConditionalRequestBuilder.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ConditionalRequestBuilder.java
@@ -28,10 +28,10 @@ package org.apache.http.impl.client.cache;
import java.util.Map;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.ProtocolException;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.methods.HttpRequestWrapper;
@@ -44,8 +44,8 @@ class ConditionalRequestBuilder {
/**
* When a {@link HttpCacheEntry} is stale but 'might' be used as a response
- * to an {@link org.apache.http.HttpRequest} we will attempt to revalidate
- * the entry with the origin. Build the origin {@link org.apache.http.HttpRequest}
+ * to an {@link org.apache.hc.core5.http.HttpRequest} we will attempt to revalidate
+ * the entry with the origin. Build the origin {@link org.apache.hc.core5.http.HttpRequest}
* here and return it.
*
* @param request the original request from the caller
@@ -55,7 +55,7 @@ class ConditionalRequestBuilder {
*/
public HttpRequestWrapper buildConditionalRequest(final HttpRequestWrapper request, final HttpCacheEntry cacheEntry)
throws ProtocolException {
- final HttpRequestWrapper newRequest = HttpRequestWrapper.wrap(request.getOriginal());
+ final HttpRequestWrapper newRequest = HttpRequestWrapper.wrap(request.getOriginal(), request.getTarget());
newRequest.setHeaders(request.getAllHeaders());
final Header eTag = cacheEntry.getFirstHeader(HeaderConstants.ETAG);
if (eTag != null) {
@@ -84,9 +84,9 @@ class ConditionalRequestBuilder {
/**
* When a {@link HttpCacheEntry} does not exist for a specific
- * {@link org.apache.http.HttpRequest} we attempt to see if an existing
+ * {@link org.apache.hc.core5.http.HttpRequest} we attempt to see if an existing
* {@link HttpCacheEntry} is appropriate by building a conditional
- * {@link org.apache.http.HttpRequest} using the variants' ETag values.
+ * {@link org.apache.hc.core5.http.HttpRequest} using the variants' ETag values.
* If no such values exist, the request is unmodified
*
* @param request the original request from the caller
@@ -95,7 +95,7 @@ class ConditionalRequestBuilder {
*/
public HttpRequestWrapper buildConditionalRequestFromVariants(final HttpRequestWrapper request,
final Map variants) {
- final HttpRequestWrapper newRequest = HttpRequestWrapper.wrap(request.getOriginal());
+ final HttpRequestWrapper newRequest = HttpRequestWrapper.wrap(request.getOriginal(), request.getTarget());
newRequest.setHeaders(request.getAllHeaders());
// we do not support partial content so all etags are used
@@ -125,7 +125,7 @@ class ConditionalRequestBuilder {
* @return an unconditional validation request
*/
public HttpRequestWrapper buildUnconditionalRequest(final HttpRequestWrapper request, final HttpCacheEntry entry) {
- final HttpRequestWrapper newRequest = HttpRequestWrapper.wrap(request.getOriginal());
+ final HttpRequestWrapper newRequest = HttpRequestWrapper.wrap(request.getOriginal(), request.getTarget());
newRequest.setHeaders(request.getAllHeaders());
newRequest.addHeader(HeaderConstants.CACHE_CONTROL,HeaderConstants.CACHE_CONTROL_NO_CACHE);
newRequest.addHeader(HeaderConstants.PRAGMA,HeaderConstants.CACHE_CONTROL_NO_CACHE);
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java
index c0c0cf973..e2f04528f 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java
@@ -26,12 +26,12 @@
*/
package org.apache.http.impl.client.cache;
-import org.apache.http.annotation.ThreadSafe;
-
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import org.apache.hc.core5.annotation.ThreadSafe;
+
/**
* Implements a bounded failure cache. The oldest entries are discarded when
* the maximum size is exceeded.
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultHttpCacheEntrySerializer.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultHttpCacheEntrySerializer.java
index 843bcb78f..45846d369 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultHttpCacheEntrySerializer.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultHttpCacheEntrySerializer.java
@@ -32,7 +32,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheEntrySerializationException;
import org.apache.http.client.cache.HttpCacheEntrySerializer;
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java
index 8fb471b07..dabb92928 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java
@@ -26,13 +26,13 @@
*/
package org.apache.http.impl.client.cache;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.util.Args;
-
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.util.Args;
+
/**
* An implementation that backs off exponentially based on the number of
* consecutive failed attempts stored in the
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java
index 98137aea1..bf3238683 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.client.cache;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* The error count with a creation timestamp and its associated key.
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResource.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResource.java
index eef9c9ab9..36a66d23e 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResource.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResource.java
@@ -31,7 +31,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
import org.apache.http.client.cache.Resource;
/**
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java
index 275b2e473..e10f66e98 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FileResourceFactory.java
@@ -31,7 +31,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
import org.apache.http.client.cache.InputLimit;
import org.apache.http.client.cache.Resource;
import org.apache.http.client.cache.ResourceFactory;
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResource.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResource.java
index edf6b0f2f..b97be0c60 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResource.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResource.java
@@ -29,7 +29,7 @@ package org.apache.http.impl.client.cache;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
import org.apache.http.client.cache.Resource;
/**
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java
index 87a1b2a1d..0d5d5df6a 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java
@@ -30,7 +30,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
import org.apache.http.client.cache.InputLimit;
import org.apache.http.client.cache.Resource;
import org.apache.http.client.cache.ResourceFactory;
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HttpCache.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HttpCache.java
index b40ef2e6b..96198d69e 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HttpCache.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HttpCache.java
@@ -30,9 +30,9 @@ import java.io.IOException;
import java.util.Date;
import java.util.Map;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.methods.CloseableHttpResponse;
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java
index b255d0f47..ad90bd75e 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java
@@ -34,8 +34,8 @@ import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
-import org.apache.http.HttpEntity;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpEntity;
@Immutable
class IOUtils {
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java
index 263c6b31a..ae4b4f153 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java
@@ -26,14 +26,14 @@
*/
package org.apache.http.impl.client.cache;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.util.Args;
-
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.util.Args;
+
/**
* Immediately schedules any incoming validation request. Relies on
* {@link CacheConfig} to configure the used {@link java.util.concurrent.ThreadPoolExecutor}.
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java
index 703909170..48d68ea22 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java
@@ -33,12 +33,12 @@ import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheStorage;
import org.apache.http.client.cache.HttpCacheUpdateCallback;
import org.apache.http.client.cache.Resource;
-import org.apache.http.util.Args;
/**
*
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/OptionsHttp11Response.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/OptionsHttp11Response.java
index 221b6563c..4cab97a02 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/OptionsHttp11Response.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/OptionsHttp11Response.java
@@ -26,21 +26,19 @@
*/
package org.apache.http.impl.client.cache;
+import java.util.Iterator;
import java.util.Locale;
-import org.apache.http.Header;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.StatusLine;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.message.AbstractHttpMessage;
-import org.apache.http.message.BasicStatusLine;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.StatusLine;
+import org.apache.hc.core5.http.message.AbstractHttpMessage;
+import org.apache.hc.core5.http.message.BasicStatusLine;
/**
* @since 4.1
@@ -57,6 +55,11 @@ final class OptionsHttp11Response extends AbstractHttpMessage implements HttpRes
return statusLine;
}
+ @Override
+ public int getCode() {
+ return statusLine.getStatusCode();
+ }
+
@Override
public void setStatusLine(final StatusLine statusline) {
// No-op on purpose, this class is not going to be doing any work.
@@ -109,27 +112,27 @@ final class OptionsHttp11Response extends AbstractHttpMessage implements HttpRes
@Override
public boolean containsHeader(final String name) {
- return this.headergroup.containsHeader(name);
+ return super.containsHeader(name);
}
@Override
public Header[] getHeaders(final String name) {
- return this.headergroup.getHeaders(name);
+ return super.getHeaders(name);
}
@Override
public Header getFirstHeader(final String name) {
- return this.headergroup.getFirstHeader(name);
+ return super.getFirstHeader(name);
}
@Override
public Header getLastHeader(final String name) {
- return this.headergroup.getLastHeader(name);
+ return super.getLastHeader(name);
}
@Override
public Header[] getAllHeaders() {
- return this.headergroup.getAllHeaders();
+ return super.getAllHeaders();
}
@Override
@@ -138,7 +141,7 @@ final class OptionsHttp11Response extends AbstractHttpMessage implements HttpRes
}
@Override
- public void addHeader(final String name, final String value) {
+ public void addHeader(final String name, final Object value) {
// No-op on purpose, this class is not going to be doing any work.
}
@@ -148,7 +151,7 @@ final class OptionsHttp11Response extends AbstractHttpMessage implements HttpRes
}
@Override
- public void setHeader(final String name, final String value) {
+ public void setHeader(final String name, final Object value) {
// No-op on purpose, this class is not going to be doing any work.
}
@@ -168,25 +171,14 @@ final class OptionsHttp11Response extends AbstractHttpMessage implements HttpRes
}
@Override
- public HeaderIterator headerIterator() {
- return this.headergroup.iterator();
+ public Iterator headerIterator() {
+ return super.headerIterator();
}
@Override
- public HeaderIterator headerIterator(final String name) {
- return this.headergroup.iterator(name);
+ public Iterator headerIterator(final String name) {
+ return super.headerIterator(name);
}
- @Override
- public HttpParams getParams() {
- if (this.params == null) {
- this.params = new BasicHttpParams();
- }
- return this.params;
- }
- @Override
- public void setParams(final HttpParams params) {
- // No-op on purpose, this class is not going to be doing any work.
- }
}
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/Proxies.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/Proxies.java
index c86a03916..0220973f9 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/Proxies.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/Proxies.java
@@ -28,10 +28,10 @@ package org.apache.http.impl.client.cache;
import java.lang.reflect.Proxy;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.util.Args;
/**
* Proxies for HTTP message objects.
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java
index 4febcae93..d5b81bb31 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java
@@ -30,24 +30,25 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.entity.AbstractHttpEntity;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.message.BasicStatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.methods.HttpRequestWrapper;
-import org.apache.http.entity.AbstractHttpEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.message.BasicStatusLine;
-import org.apache.http.protocol.HTTP;
/**
* @since 4.1
@@ -110,7 +111,7 @@ class RequestProtocolCompliance {
throws ClientProtocolException {
if (requestMustNotHaveEntity(request)) {
- ((HttpEntityEnclosingRequest) request).setEntity(null);
+ request.setEntity(null);
}
verifyRequestWithExpectContinueFlagHas100continueHeader(request);
@@ -159,8 +160,7 @@ class RequestProtocolCompliance {
}
private boolean requestMustNotHaveEntity(final HttpRequest request) {
- return HeaderConstants.TRACE_METHOD.equals(request.getRequestLine().getMethod())
- && request instanceof HttpEntityEnclosingRequest;
+ return HeaderConstants.TRACE_METHOD.equals(request.getRequestLine().getMethod());
}
private void decrementOPTIONSMaxForwardsIfGreaterThen0(final HttpRequest request) {
@@ -184,29 +184,19 @@ class RequestProtocolCompliance {
return;
}
- if (!(request instanceof HttpEntityEnclosingRequest)) {
- return;
- }
-
- addContentTypeHeaderIfMissing((HttpEntityEnclosingRequest) request);
+ addContentTypeHeaderIfMissing(request);
}
- private void addContentTypeHeaderIfMissing(final HttpEntityEnclosingRequest request) {
- if (request.getEntity().getContentType() == null) {
- ((AbstractHttpEntity) request.getEntity()).setContentType(
- ContentType.APPLICATION_OCTET_STREAM.getMimeType());
+ private void addContentTypeHeaderIfMissing(final HttpRequest request) {
+ final HttpEntity entity = request.getEntity();
+ if (entity != null && entity.getContentType() == null) {
+ ((AbstractHttpEntity) entity).setContentType(ContentType.APPLICATION_OCTET_STREAM.getMimeType());
}
}
private void verifyRequestWithExpectContinueFlagHas100continueHeader(final HttpRequest request) {
- if (request instanceof HttpEntityEnclosingRequest) {
-
- if (((HttpEntityEnclosingRequest) request).expectContinue()
- && ((HttpEntityEnclosingRequest) request).getEntity() != null) {
- add100ContinueHeaderIfMissing(request);
- } else {
- remove100ContinueHeaderIfExists(request);
- }
+ if (request.containsHeader(HttpHeaders.EXPECT) && request.getEntity() != null) {
+ add100ContinueHeaderIfMissing(request);
} else {
remove100ContinueHeaderIfExists(request);
}
@@ -215,12 +205,12 @@ class RequestProtocolCompliance {
private void remove100ContinueHeaderIfExists(final HttpRequest request) {
boolean hasHeader = false;
- final Header[] expectHeaders = request.getHeaders(HTTP.EXPECT_DIRECTIVE);
+ final Header[] expectHeaders = request.getHeaders(HttpHeaders.EXPECT);
List expectElementsThatAreNot100Continue = new ArrayList<>();
for (final Header h : expectHeaders) {
for (final HeaderElement elt : h.getElements()) {
- if (!(HTTP.EXPECT_CONTINUE.equalsIgnoreCase(elt.getName()))) {
+ if (!(HeaderElements.CONTINUE.equalsIgnoreCase(elt.getName()))) {
expectElementsThatAreNot100Continue.add(elt);
} else {
hasHeader = true;
@@ -230,7 +220,7 @@ class RequestProtocolCompliance {
if (hasHeader) {
request.removeHeader(h);
for (final HeaderElement elt : expectElementsThatAreNot100Continue) {
- final BasicHeader newHeader = new BasicHeader(HTTP.EXPECT_DIRECTIVE, elt.getName());
+ final BasicHeader newHeader = new BasicHeader(HeaderElements.CONTINUE, elt.getName());
request.addHeader(newHeader);
}
return;
@@ -243,16 +233,16 @@ class RequestProtocolCompliance {
private void add100ContinueHeaderIfMissing(final HttpRequest request) {
boolean hasHeader = false;
- for (final Header h : request.getHeaders(HTTP.EXPECT_DIRECTIVE)) {
+ for (final Header h : request.getHeaders(HttpHeaders.EXPECT)) {
for (final HeaderElement elt : h.getElements()) {
- if (HTTP.EXPECT_CONTINUE.equalsIgnoreCase(elt.getName())) {
+ if (HeaderElements.CONTINUE.equalsIgnoreCase(elt.getName())) {
hasHeader = true;
}
}
}
if (!hasHeader) {
- request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
+ request.addHeader(HttpHeaders.EXPECT, HeaderElements.CONTINUE);
}
}
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java
index 4f9ac4420..d765d2592 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResourceReference.java
@@ -29,10 +29,10 @@ package org.apache.http.impl.client.cache;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.Resource;
-import org.apache.http.util.Args;
@Immutable
class ResourceReference extends PhantomReference {
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java
index e063ea6b7..113cb2ffc 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java
@@ -33,17 +33,17 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpMessage;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpMessage;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.protocol.HTTP;
/**
* Determines if an HttpResponse can be cached.
@@ -123,7 +123,7 @@ class ResponseCachingPolicy {
return false;
}
- final Header contentLength = response.getFirstHeader(HTTP.CONTENT_LEN);
+ final Header contentLength = response.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
if (contentLength != null) {
final int contentLengthValue = Integer.parseInt(contentLength.getValue());
if (contentLengthValue > this.maxObjectSizeBytes) {
@@ -143,7 +143,7 @@ class ResponseCachingPolicy {
return false;
}
- final Header[] dateHeaders = response.getHeaders(HTTP.DATE_HEADER);
+ final Header[] dateHeaders = response.getHeaders(HttpHeaders.DATE);
if (dateHeaders.length != 1) {
return false;
@@ -279,7 +279,7 @@ class ResponseCachingPolicy {
return false;
}
final Header expiresHdr = response.getFirstHeader(HeaderConstants.EXPIRES);
- final Header dateHdr = response.getFirstHeader(HTTP.DATE_HEADER);
+ final Header dateHdr = response.getFirstHeader(HttpHeaders.DATE);
if (expiresHdr == null || dateHdr == null) {
return false;
}
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java
index 42b897ceb..47143abd9 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java
@@ -31,21 +31,21 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HTTP;
/**
* @since 4.1
@@ -99,7 +99,7 @@ class ResponseProtocolCompliance {
private void warningsWithNonMatchingWarnDatesAreRemoved(
final HttpResponse response) {
- final Date responseDate = DateUtils.parseDate(response.getFirstHeader(HTTP.DATE_HEADER).getValue());
+ final Date responseDate = DateUtils.parseDate(response.getFirstHeader(HttpHeaders.DATE).getValue());
if (responseDate == null) {
return;
}
@@ -131,7 +131,7 @@ class ResponseProtocolCompliance {
}
private void identityIsNotUsedInContentEncoding(final HttpResponse response) {
- final Header[] hdrs = response.getHeaders(HTTP.CONTENT_ENCODING);
+ final Header[] hdrs = response.getHeaders(HttpHeaders.CONTENT_ENCODING);
if (hdrs == null || hdrs.length == 0) {
return;
}
@@ -153,21 +153,21 @@ class ResponseProtocolCompliance {
}
final String newHeaderValue = buf.toString();
if (!"".equals(newHeaderValue)) {
- newHeaders.add(new BasicHeader(HTTP.CONTENT_ENCODING, newHeaderValue));
+ newHeaders.add(new BasicHeader(HttpHeaders.CONTENT_ENCODING, newHeaderValue));
}
}
if (!modified) {
return;
}
- response.removeHeaders(HTTP.CONTENT_ENCODING);
+ response.removeHeaders(HttpHeaders.CONTENT_ENCODING);
for (final Header h : newHeaders) {
response.addHeader(h);
}
}
private void ensure206ContainsDateHeader(final HttpResponse response) {
- if (response.getFirstHeader(HTTP.DATE_HEADER) == null) {
- response.addHeader(HTTP.DATE_HEADER, DateUtils.formatDate(new Date()));
+ if (response.getFirstHeader(HttpHeaders.DATE) == null) {
+ response.addHeader(HttpHeaders.DATE, DateUtils.formatDate(new Date()));
}
}
@@ -193,15 +193,15 @@ class ResponseProtocolCompliance {
return;
}
- if (response.getFirstHeader(HTTP.CONTENT_LEN) == null) {
- response.addHeader(HTTP.CONTENT_LEN, "0");
+ if (response.getFirstHeader(HttpHeaders.CONTENT_LENGTH) == null) {
+ response.addHeader(HttpHeaders.CONTENT_LENGTH, "0");
}
}
private void ensure304DoesNotContainExtraEntityHeaders(final HttpResponse response) {
- final String[] disallowedEntityHeaders = { HeaderConstants.ALLOW, HTTP.CONTENT_ENCODING,
- "Content-Language", HTTP.CONTENT_LEN, "Content-MD5",
- "Content-Range", HTTP.CONTENT_TYPE, HeaderConstants.LAST_MODIFIED
+ final String[] disallowedEntityHeaders = { HeaderConstants.ALLOW, HttpHeaders.CONTENT_ENCODING,
+ "Content-Language", HttpHeaders.CONTENT_LENGTH, "Content-MD5",
+ "Content-Range", HttpHeaders.CONTENT_TYPE, HeaderConstants.LAST_MODIFIED
};
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_MODIFIED) {
for(final String hdr : disallowedEntityHeaders) {
@@ -224,10 +224,9 @@ class ResponseProtocolCompliance {
}
final HttpRequest originalRequest = request.getOriginal();
- if (originalRequest instanceof HttpEntityEnclosingRequest) {
- if (((HttpEntityEnclosingRequest)originalRequest).expectContinue()) {
- return;
- }
+ final Header header = originalRequest.getFirstHeader(HttpHeaders.EXPECT);
+ if (header != null && header.getValue().equalsIgnoreCase(HeaderElements.CONTINUE)) {
+ return;
}
consumeBody(response);
throw new ClientProtocolException(UNEXPECTED_100_CONTINUE);
@@ -245,7 +244,7 @@ class ResponseProtocolCompliance {
private void removeResponseTransferEncoding(final HttpResponse response) {
response.removeHeaders("TE");
- response.removeHeaders(HTTP.TRANSFER_ENCODING);
+ response.removeHeaders(HttpHeaders.TRANSFER_ENCODING);
}
}
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java
index 26f3c9da3..96a9c882b 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java
@@ -33,8 +33,8 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpResponse;
/**
* A proxy class that can enhance an arbitrary {@link HttpResponse} with
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java
index 4cb520a9b..127a9809d 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/SizeLimitedResponseReader.java
@@ -30,15 +30,15 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Proxy;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.cache.InputLimit;
import org.apache.http.client.cache.Resource;
import org.apache.http.client.cache.ResourceFactory;
import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.message.BasicHttpResponse;
/**
* @since 4.1
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/WarningValue.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/WarningValue.java
index d650c4e13..b1560f427 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/WarningValue.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/WarningValue.java
@@ -32,7 +32,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.http.Header;
+import org.apache.hc.core5.http.Header;
import org.apache.http.client.utils.DateUtils;
/** This class provides for parsing and understanding Warning headers. As
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ehcache/EhcacheHttpCacheStorage.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ehcache/EhcacheHttpCacheStorage.java
index 3fcda21a2..15c039d13 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ehcache/EhcacheHttpCacheStorage.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ehcache/EhcacheHttpCacheStorage.java
@@ -30,9 +30,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheEntrySerializer;
import org.apache.http.client.cache.HttpCacheStorage;
@@ -41,6 +38,9 @@ import org.apache.http.client.cache.HttpCacheUpdateException;
import org.apache.http.impl.client.cache.CacheConfig;
import org.apache.http.impl.client.cache.DefaultHttpCacheEntrySerializer;
+import net.sf.ehcache.Ehcache;
+import net.sf.ehcache.Element;
+
/**
* This class is a storage backend for cache entries that uses the
* popular Ehcache cache implementation.
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/KeyHashingScheme.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/KeyHashingScheme.java
index 12d34cbb4..5373b4fdf 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/KeyHashingScheme.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/KeyHashingScheme.java
@@ -68,5 +68,5 @@ public interface KeyHashingScheme {
* as its key for looking up cache entries
* @return a cache key suitable for use with memcached
*/
- public String hash(String storageKey);
+ String hash(String storageKey);
}
diff --git a/httpclient-cache/src/test/java/org/apache/http/client/cache/TestHttpCacheEntry.java b/httpclient-cache/src/test/java/org/apache/http/client/cache/TestHttpCacheEntry.java
index eb1514267..3027153fa 100644
--- a/httpclient-cache/src/test/java/org/apache/http/client/cache/TestHttpCacheEntry.java
+++ b/httpclient-cache/src/test/java/org/apache/http/client/cache/TestHttpCacheEntry.java
@@ -39,13 +39,13 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import org.apache.http.Header;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.StatusLine;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.StatusLine;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicStatusLine;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicStatusLine;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java
index 9f85fcd24..43e63d2bc 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/AbstractProtocolTest.java
@@ -28,11 +28,12 @@ package org.apache.http.impl.client.cache;
import java.util.HashMap;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpExecutionAware;
@@ -40,9 +41,8 @@ import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.execchain.ClientExecChain;
-import org.apache.http.message.BasicHttpRequest;
-import org.easymock.IExpectationSetters;
import org.easymock.EasyMock;
+import org.easymock.IExpectationSetters;
import org.junit.Before;
public abstract class AbstractProtocolTest {
@@ -85,7 +85,7 @@ public abstract class AbstractProtocolTest {
body = HttpTestUtils.makeBody(entityLength);
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1), host);
context = HttpCacheContext.create();
context.setTargetHost(host);
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DummyBackend.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DummyBackend.java
index 9ea22b1d5..bcc0ff648 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DummyBackend.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/DummyBackend.java
@@ -28,18 +28,18 @@ package org.apache.http.impl.client.cache;
import java.io.IOException;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolVersion;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.execchain.ClientExecChain;
-import org.apache.http.message.BasicHttpResponse;
public class DummyBackend implements ClientExecChain {
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/HttpTestUtils.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/HttpTestUtils.java
index ab8a428d4..32df7ddd3 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/HttpTestUtils.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/HttpTestUtils.java
@@ -32,24 +32,24 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Random;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpMessage;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.RequestLine;
-import org.apache.http.StatusLine;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpMessage;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.RequestLine;
+import org.apache.hc.core5.http.StatusLine;
+import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.message.BasicStatusLine;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.message.BasicStatusLine;
import org.junit.Assert;
public class HttpTestUtils {
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/OKStatus.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/OKStatus.java
index 839045052..0c5a1a449 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/OKStatus.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/OKStatus.java
@@ -26,9 +26,9 @@
*/
package org.apache.http.impl.client.cache;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.message.BasicStatusLine;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicStatusLine;
public class OKStatus extends BasicStatusLine {
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/RequestEquivalent.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/RequestEquivalent.java
index 0ac2ef023..f1f655e62 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/RequestEquivalent.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/RequestEquivalent.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.client.cache;
-import org.apache.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequest;
import org.easymock.IArgumentMatcher;
public class RequestEquivalent implements IArgumentMatcher {
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ResponseEquivalent.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ResponseEquivalent.java
index 843db4327..abe64fec1 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ResponseEquivalent.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ResponseEquivalent.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.client.cache;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponse;
import org.easymock.IArgumentMatcher;
public class ResponseEquivalent implements IArgumentMatcher {
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidationRequest.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidationRequest.java
index c970f51ee..6c23a108c 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidationRequest.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidationRequest.java
@@ -32,10 +32,11 @@ import static org.mockito.Mockito.when;
import java.io.IOException;
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.ProtocolException;
-import org.apache.http.StatusLine;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.StatusLine;
+import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -44,7 +45,6 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.message.BasicHeader;
import org.junit.Before;
import org.junit.Test;
@@ -53,6 +53,7 @@ public class TestAsynchronousValidationRequest {
private AsynchronousValidator mockParent;
private CachingExec mockClient;
+ private HttpHost host;
private HttpRoute route;
private HttpRequestWrapper request;
private HttpClientContext context;
@@ -65,8 +66,9 @@ public class TestAsynchronousValidationRequest {
public void setUp() {
mockParent = mock(AsynchronousValidator.class);
mockClient = mock(CachingExec.class);
- route = new HttpRoute(new HttpHost("foo.example.com", 80));
- request = HttpRequestWrapper.wrap(new HttpGet("/"));
+ host = new HttpHost("foo.example.com", 80);
+ route = new HttpRoute(host);
+ request = HttpRequestWrapper.wrap(new HttpGet("/"), host);
context = HttpClientContext.create();
mockExecAware = mock(HttpExecutionAware.class);
mockCacheEntry = mock(HttpCacheEntry.class);
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java
index 58ecef11f..d415c2613 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestAsynchronousValidator.java
@@ -37,9 +37,10 @@ import java.io.IOException;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.methods.HttpExecutionAware;
@@ -47,7 +48,6 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.message.BasicHeader;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -59,6 +59,7 @@ public class TestAsynchronousValidator {
private AsynchronousValidator impl;
private CachingExec mockClient;
+ private HttpHost host;
private HttpRoute route;
private HttpRequestWrapper request;
private HttpClientContext context;
@@ -70,8 +71,9 @@ public class TestAsynchronousValidator {
@Before
public void setUp() {
mockClient = mock(CachingExec.class);
- route = new HttpRoute(new HttpHost("foo.example.com", 80));
- request = HttpRequestWrapper.wrap(new HttpGet("/"));
+ host = new HttpHost("foo.example.com", 80);
+ route = new HttpRoute(host);
+ request = HttpRequestWrapper.wrap(new HttpGet("/"), host);
context = HttpClientContext.create();
context.setTargetHost(new HttpHost("foo.example.com"));
mockExecAware = mock(HttpExecutionAware.class);
@@ -160,8 +162,8 @@ public class TestAsynchronousValidator {
when(mockCacheEntry.getHeaders(HeaderConstants.VARY)).thenReturn(variantHeaders);
mockSchedulingStrategy.schedule(isA(AsynchronousValidationRequest.class));
- impl.revalidateCacheEntry(mockClient, route, HttpRequestWrapper.wrap(req1), context, mockExecAware, mockCacheEntry);
- impl.revalidateCacheEntry(mockClient, route, HttpRequestWrapper.wrap(req2), context, mockExecAware, mockCacheEntry);
+ impl.revalidateCacheEntry(mockClient, route, HttpRequestWrapper.wrap(req1, host), context, mockExecAware, mockCacheEntry);
+ impl.revalidateCacheEntry(mockClient, route, HttpRequestWrapper.wrap(req2, host), context, mockExecAware, mockCacheEntry);
verify(mockCacheEntry, times(2)).hasVariants();
verify(mockCacheEntry, times(2)).getHeaders(HeaderConstants.VARY);
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java
index 03adbd8ed..af7a35f58 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java
@@ -41,13 +41,17 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.entity.BasicHttpEntity;
+import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.Resource;
@@ -58,10 +62,6 @@ import org.apache.http.client.methods.HttpOptions;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpTrace;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.entity.BasicHttpEntity;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpResponse;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheEntryUpdater.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheEntryUpdater.java
index a745010d7..e8301199d 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheEntryUpdater.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheEntryUpdater.java
@@ -33,14 +33,14 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.Date;
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpResponse;
import org.junit.Before;
import org.junit.Test;
@@ -90,7 +90,7 @@ public class TestCacheEntryUpdater {
new BasicHeader("Date", DateUtils.formatDate(responseDate)),
new BasicHeader("ETag", "\"etag\"")};
entry = HttpTestUtils.makeCacheEntry(headers);
- response.setHeaders(new Header[]{});
+ response.setHeaders();
final HttpCacheEntry updatedEntry = impl.updateCacheEntry(null, entry,
new Date(), new Date(), response);
@@ -112,9 +112,8 @@ public class TestCacheEntryUpdater {
new BasicHeader("Cache-Control", "max-age=0"),};
entry = HttpTestUtils.makeCacheEntry(headers);
- response.setHeaders(new Header[] {
- new BasicHeader("Last-Modified", DateUtils.formatDate(responseDate)),
- new BasicHeader("Cache-Control", "public")});
+ response.setHeaders(new BasicHeader("Last-Modified", DateUtils.formatDate(responseDate)),
+ new BasicHeader("Cache-Control", "public"));
final HttpCacheEntry updatedEntry = impl.updateCacheEntry(null, entry,
new Date(), new Date(), response);
@@ -136,9 +135,8 @@ public class TestCacheEntryUpdater {
new BasicHeader("ETag", "\"etag\"")};
entry = HttpTestUtils.makeCacheEntry(headers);
- response.setHeaders(new Header[]{
- new BasicHeader("Last-Modified", DateUtils.formatDate(responseDate)),
- new BasicHeader("Cache-Control", "public"),});
+ response.setHeaders(new BasicHeader("Last-Modified", DateUtils.formatDate(responseDate)),
+ new BasicHeader("Cache-Control", "public"));
final HttpCacheEntry updatedEntry = impl.updateCacheEntry(null, entry,
new Date(), new Date(), response);
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java
index e6530d64c..9d65a70df 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheInvalidator.java
@@ -36,21 +36,19 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import org.apache.http.Header;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolVersion;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheStorage;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.BasicHttpResponse;
import org.junit.Before;
import org.junit.Test;
@@ -103,7 +101,7 @@ public class TestCacheInvalidator {
@Test
public void testInvalidatesUrisInContentLocationHeadersOnPUTs() throws Exception {
- final HttpEntityEnclosingRequest putRequest = new BasicHttpEntityEnclosingRequest("PUT","/",HTTP_1_1);
+ final HttpRequest putRequest = new BasicHttpRequest("PUT","/",HTTP_1_1);
putRequest.setEntity(HttpTestUtils.makeBody(128));
putRequest.setHeader("Content-Length","128");
@@ -125,7 +123,7 @@ public class TestCacheInvalidator {
@Test
public void testInvalidatesUrisInLocationHeadersOnPUTs() throws Exception {
- final HttpEntityEnclosingRequest putRequest = new BasicHttpEntityEnclosingRequest("PUT","/",HTTP_1_1);
+ final HttpRequest putRequest = new BasicHttpRequest("PUT","/",HTTP_1_1);
putRequest.setEntity(HttpTestUtils.makeBody(128));
putRequest.setHeader("Content-Length","128");
@@ -147,7 +145,7 @@ public class TestCacheInvalidator {
@Test
public void testInvalidatesRelativeUrisInContentLocationHeadersOnPUTs() throws Exception {
- final HttpEntityEnclosingRequest putRequest = new BasicHttpEntityEnclosingRequest("PUT","/",HTTP_1_1);
+ final HttpRequest putRequest = new BasicHttpRequest("PUT","/",HTTP_1_1);
putRequest.setEntity(HttpTestUtils.makeBody(128));
putRequest.setHeader("Content-Length","128");
@@ -169,7 +167,7 @@ public class TestCacheInvalidator {
@Test
public void testDoesNotInvalidateUrisInContentLocationHeadersOnPUTsToDifferentHosts() throws Exception {
- final HttpEntityEnclosingRequest putRequest = new BasicHttpEntityEnclosingRequest("PUT","/",HTTP_1_1);
+ final HttpRequest putRequest = new BasicHttpRequest("PUT","/",HTTP_1_1);
putRequest.setEntity(HttpTestUtils.makeBody(128));
putRequest.setHeader("Content-Length","128");
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheKeyGenerator.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheKeyGenerator.java
index 4d217a901..287f1e5a4 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheKeyGenerator.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheKeyGenerator.java
@@ -30,14 +30,14 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpRequest;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheValidityPolicy.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheValidityPolicy.java
index 5e8e5e1d3..d9870e983 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheValidityPolicy.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheValidityPolicy.java
@@ -34,14 +34,14 @@ import static org.junit.Assert.assertTrue;
import java.util.Date;
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.HTTP;
import org.junit.Before;
import org.junit.Test;
@@ -341,7 +341,7 @@ public class TestCacheValidityPolicy {
@Test
public void testCorrectContentLengthDoesntInvalidateEntry() {
final int contentLength = 128;
- final Header[] headers = { new BasicHeader(HTTP.CONTENT_LEN, Integer.toString(contentLength)) };
+ final Header[] headers = { new BasicHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(contentLength)) };
final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers, HttpTestUtils.getRandomBytes(contentLength));
assertTrue(impl.contentLengthHeaderMatchesActualLength(entry));
}
@@ -349,7 +349,7 @@ public class TestCacheValidityPolicy {
@Test
public void testWrongContentLengthInvalidatesEntry() {
final int contentLength = 128;
- final Header[] headers = {new BasicHeader(HTTP.CONTENT_LEN, Integer.toString(contentLength+1))};
+ final Header[] headers = {new BasicHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(contentLength+1))};
final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers, HttpTestUtils.getRandomBytes(contentLength));
assertFalse(impl.contentLengthHeaderMatchesActualLength(entry));
}
@@ -357,7 +357,7 @@ public class TestCacheValidityPolicy {
@Test
public void testNullResourceInvalidatesEntry() {
final int contentLength = 128;
- final Header[] headers = {new BasicHeader(HTTP.CONTENT_LEN, Integer.toString(contentLength))};
+ final Header[] headers = {new BasicHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(contentLength))};
final HttpCacheEntry entry = HttpTestUtils.makeHeadCacheEntry(headers);
assertFalse(impl.contentLengthHeaderMatchesActualLength(entry));
}
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheableRequestPolicy.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheableRequestPolicy.java
index 8b06ca21b..af65138b0 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheableRequestPolicy.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCacheableRequestPolicy.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.client.cache;
-import org.apache.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedHttpResponseGenerator.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedHttpResponseGenerator.java
index 3fc12f613..f55d7b4cf 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedHttpResponseGenerator.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedHttpResponseGenerator.java
@@ -35,11 +35,12 @@ import static org.mockito.Mockito.when;
import java.util.Date;
import java.util.HashMap;
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.methods.HttpRequestWrapper;
-import org.apache.http.message.BasicHeader;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -47,6 +48,7 @@ import org.junit.Test;
@SuppressWarnings({"boxing","static-access"}) // test code
public class TestCachedHttpResponseGenerator {
+ private HttpHost host;
private HttpCacheEntry entry;
private HttpRequestWrapper request;
private CacheValidityPolicy mockValidityPolicy;
@@ -54,8 +56,9 @@ public class TestCachedHttpResponseGenerator {
@Before
public void setUp() {
+ host = new HttpHost("foo.example.com", 80);
entry = HttpTestUtils.makeCacheEntry(new HashMap());
- request = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ request = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
mockValidityPolicy = mock(CacheValidityPolicy.class);
impl = new CachedHttpResponseGenerator(mockValidityPolicy);
}
@@ -159,7 +162,7 @@ public class TestCachedHttpResponseGenerator {
@Test
public void testResponseDoesNotContainEntityToServeHEADRequestIfEntryContainsResource() throws Exception {
- final HttpRequestWrapper headRequest = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultHEADRequest());
+ final HttpRequestWrapper headRequest = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultHEADRequest(), host);
final HttpResponse response = impl.generateResponse(headRequest, entry);
Assert.assertNull(response.getEntity());
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java
index a5cfffa09..95645e21e 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachedResponseSuitabilityChecker.java
@@ -28,14 +28,14 @@ package org.apache.http.impl.client.cache;
import java.util.Date;
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpRequest;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java
index abda62ae7..c3df210f4 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java
@@ -45,11 +45,17 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.message.BasicStatusLine;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpExecutionAware;
@@ -58,14 +64,9 @@ import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.DateUtils;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.entity.InputStreamEntity;
import org.apache.http.impl.execchain.ClientExecChain;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.message.BasicStatusLine;
-import org.apache.http.protocol.HTTP;
-import org.easymock.IExpectationSetters;
import org.easymock.EasyMock;
+import org.easymock.IExpectationSetters;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -252,7 +253,7 @@ public class TestCachingExec extends TestCachingExecChain {
mockImplMethods(GET_CURRENT_DATE, HANDLE_BACKEND_RESPONSE);
final HttpRequestWrapper validate = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final CloseableHttpResponse originResponse = Proxies.enhanceResponse(
new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_FOUND, "Not Found"));
final CloseableHttpResponse finalResponse = Proxies.enhanceResponse(
@@ -284,7 +285,7 @@ public class TestCachingExec extends TestCachingExecChain {
mockImplMethods(GET_CURRENT_DATE);
final HttpRequestWrapper validate = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse originResponse = Proxies.enhanceResponse(
new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not Modified"));
final HttpCacheEntry updatedEntry = HttpTestUtils.makeCacheEntry();
@@ -318,9 +319,9 @@ public class TestCachingExec extends TestCachingExecChain {
EasyMock.resetToStrict(mockBackend);
final HttpRequestWrapper validate = HttpRequestWrapper.wrap(
- new HttpGet("http://foo.example.com/resource"));
+ new HttpGet("http://foo.example.com/resource"), host);
final HttpRequestWrapper relativeValidate = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/resource", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/resource", HttpVersion.HTTP_1_1), host);
final CloseableHttpResponse originResponse = Proxies.enhanceResponse(
new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "Okay"));
@@ -346,7 +347,7 @@ public class TestCachingExec extends TestCachingExecChain {
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
resp1.setHeader("Date", DateUtils.formatDate(new Date()));
resp1.setHeader("Server", "MockOrigin/1.0");
- resp1.setHeader(HTTP.TRANSFER_ENCODING, HTTP.CHUNK_CODING);
+ resp1.setHeader(HttpHeaders.TRANSFER_ENCODING, HeaderElements.CHUNKED_ENCODING);
final AtomicInteger size = new AtomicInteger();
final AtomicInteger maxlength = new AtomicInteger(Integer.MAX_VALUE);
@@ -380,7 +381,7 @@ public class TestCachingExec extends TestCachingExecChain {
EasyMock.isNull());
EasyMock.expect(resp).andReturn(Proxies.enhanceResponse(resp1));
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
replayMocks();
final CloseableHttpResponse resp2 = impl.execute(route, req1, context, null);
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExecChain.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExecChain.java
index b605d655a..e9e6948aa 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExecChain.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExecChain.java
@@ -48,15 +48,18 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import junit.framework.AssertionFailedError;
-
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.StatusLine;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.StatusLine;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.cache.CacheResponseStatus;
@@ -72,19 +75,16 @@ import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.DateUtils;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.entity.InputStreamEntity;
import org.apache.http.impl.execchain.ClientExecChain;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.util.EntityUtils;
import org.easymock.Capture;
-import org.easymock.IExpectationSetters;
import org.easymock.EasyMock;
+import org.easymock.IExpectationSetters;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import junit.framework.AssertionFailedError;
+
@SuppressWarnings("boxing") // test code
public abstract class TestCachingExecChain {
@@ -142,7 +142,7 @@ public abstract class TestCachingExecChain {
host = new HttpHost("foo.example.com", 80);
route = new HttpRoute(host);
request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/stuff",
- HttpVersion.HTTP_1_1));
+ HttpVersion.HTTP_1_1), host);
context = HttpCacheContext.create();
context.setTargetHost(host);
entry = HttpTestUtils.makeCacheEntry();
@@ -218,13 +218,13 @@ public abstract class TestCachingExecChain {
public void testCacheableResponsesGoIntoCache() throws Exception {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control", "max-age=3600");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
replayMocks();
impl.execute(route, req1, context, null);
@@ -238,7 +238,7 @@ public abstract class TestCachingExecChain {
final Date now = new Date();
final Date fiveSecondsAgo = new Date(now.getTime() - 5 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(now));
resp1.setHeader("Cache-Control", "max-age=3600");
@@ -246,7 +246,7 @@ public abstract class TestCachingExecChain {
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control", "no-cache");
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("ETag", "\"old-etag\"");
@@ -255,7 +255,7 @@ public abstract class TestCachingExecChain {
backendExpectsAnyRequestAndReturn(resp2);
- final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
replayMocks();
impl.execute(route, req1, context, null);
@@ -272,7 +272,7 @@ public abstract class TestCachingExecChain {
final Date now = new Date();
final Date fiveSecondsAgo = new Date(now.getTime() - 5 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(fiveSecondsAgo));
resp1.setHeader("Cache-Control", "max-age=3600");
@@ -280,7 +280,7 @@ public abstract class TestCachingExecChain {
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control", "max-age=0");
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("ETag", "\"new-etag\"");
@@ -289,7 +289,7 @@ public abstract class TestCachingExecChain {
backendExpectsAnyRequestAndReturn(resp2);
- final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
replayMocks();
impl.execute(route, req1, context, null);
@@ -332,7 +332,7 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(new HeapResourceFactory(),
mockStorage, configDefault), configDefault);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control", "no-cache");
@@ -389,7 +389,7 @@ public abstract class TestCachingExecChain {
public void testSetsModuleGeneratedResponseContextForCacheOptionsResponse() throws Exception {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req = HttpRequestWrapper.wrap(new BasicHttpRequest("OPTIONS", "*",
- HttpVersion.HTTP_1_1));
+ HttpVersion.HTTP_1_1), host);
req.setHeader("Max-Forwards", "0");
impl.execute(route, req, context, null);
@@ -402,7 +402,7 @@ public abstract class TestCachingExecChain {
throws Exception {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req.setHeader("Range", "bytes=0-50");
req.setHeader("If-Range", "W/\"weak-etag\"");
@@ -416,7 +416,7 @@ public abstract class TestCachingExecChain {
throws Exception {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/",
- HttpVersion.HTTP_1_0));
+ HttpVersion.HTTP_1_0), host);
req.setHeader("Cache-Control", "no-cache");
final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1,
HttpStatus.SC_NO_CONTENT, "No Content");
@@ -438,7 +438,7 @@ public abstract class TestCachingExecChain {
public void testSetsCacheMissContextIfRequestNotServableFromCache() throws Exception {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req.setHeader("Cache-Control", "no-cache");
final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1,
HttpStatus.SC_NO_CONTENT, "No Content");
@@ -455,7 +455,7 @@ public abstract class TestCachingExecChain {
public void testSetsViaHeaderOnResponseIfRequestNotServableFromCache() throws Exception {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req.setHeader("Cache-Control", "no-cache");
final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1,
HttpStatus.SC_NO_CONTENT, "No Content");
@@ -472,7 +472,7 @@ public abstract class TestCachingExecChain {
public void testSetsViaHeaderOnResponseForCacheMiss() throws Exception {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
resp1.setEntity(HttpTestUtils.makeBody(128));
@@ -493,9 +493,9 @@ public abstract class TestCachingExecChain {
public void testSetsCacheHitContextIfRequestServedFromCache() throws Exception {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
resp1.setEntity(HttpTestUtils.makeBody(128));
@@ -517,9 +517,9 @@ public abstract class TestCachingExecChain {
public void testSetsViaHeaderOnResponseIfRequestServedFromCache() throws Exception {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
resp1.setEntity(HttpTestUtils.makeBody(128));
@@ -543,9 +543,9 @@ public abstract class TestCachingExecChain {
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req2.addHeader("If-Modified-Since", DateUtils.formatDate(now));
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -573,10 +573,10 @@ public abstract class TestCachingExecChain {
final Date inTenMinutes = new Date(now.getTime() + 600 * 1000L);
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req1.addHeader("If-Modified-Since", DateUtils.formatDate(oneHourAgo));
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req2.addHeader("If-Modified-Since", DateUtils.formatDate(oneHourAgo));
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
@@ -609,9 +609,9 @@ public abstract class TestCachingExecChain {
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -644,9 +644,9 @@ public abstract class TestCachingExecChain {
final Date tenSecondsAfter = new Date(now.getTime() + 10 * 1000L);
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -674,9 +674,9 @@ public abstract class TestCachingExecChain {
public void testReturns304ForIfNoneMatchHeaderIfRequestServedFromCache() throws Exception {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req2.addHeader("If-None-Match", "*");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -700,9 +700,9 @@ public abstract class TestCachingExecChain {
public void testReturns200ForIfNoneMatchHeaderFails() throws Exception {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -734,9 +734,9 @@ public abstract class TestCachingExecChain {
final Date now = new Date();
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -766,9 +766,9 @@ public abstract class TestCachingExecChain {
final Date now = new Date();
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req2.addHeader("If-None-Match", "\"abc\"");
req2.addHeader("If-Modified-Since", DateUtils.formatDate(now));
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
@@ -798,10 +798,10 @@ public abstract class TestCachingExecChain {
.setSharedCache(true).build());
final Date now = new Date();
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpOptions(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req1.setHeader("Authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req2.setHeader("Authorization", "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
HttpStatus.SC_NO_CONTENT, "No Content");
@@ -836,9 +836,9 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -873,9 +873,9 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -910,9 +910,9 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -940,9 +940,9 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -969,9 +969,9 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -999,9 +999,9 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -1036,9 +1036,9 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -1076,9 +1076,9 @@ public abstract class TestCachingExecChain {
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -1115,9 +1115,9 @@ public abstract class TestCachingExecChain {
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -1155,7 +1155,7 @@ public abstract class TestCachingExecChain {
final Date now = new Date();
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com"));
+ "http://foo.example.com"), host);
req1.addHeader("Accept-Encoding", "gzip");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
@@ -1168,11 +1168,11 @@ public abstract class TestCachingExecChain {
resp1.setHeader("Cache-Control", "public, max-age=3600");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com"));
+ "http://foo.example.com"), host);
req2.addHeader("Accept-Encoding", "deflate");
final HttpRequestWrapper req2Server = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com"));
+ "http://foo.example.com"), host);
req2Server.addHeader("Accept-Encoding", "deflate");
req2Server.addHeader("If-None-Match", "\"gzip_etag\"");
@@ -1186,11 +1186,11 @@ public abstract class TestCachingExecChain {
resp2.setHeader("Cache-Control", "public, max-age=3600");
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com"));
+ "http://foo.example.com"), host);
req3.addHeader("Accept-Encoding", "gzip,deflate");
final HttpRequestWrapper req3Server = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com"));
+ "http://foo.example.com"), host);
req3Server.addHeader("Accept-Encoding", "gzip,deflate");
req3Server.addHeader("If-None-Match", "\"gzip_etag\",\"deflate_etag\"");
@@ -1226,7 +1226,7 @@ public abstract class TestCachingExecChain {
final Date now = new Date();
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com"));
+ "http://foo.example.com"), host);
req1.addHeader("Accept-Encoding", "gzip");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
@@ -1239,11 +1239,11 @@ public abstract class TestCachingExecChain {
resp1.setHeader("Cache-Control", "public, max-age=3600");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com"));
+ "http://foo.example.com"), host);
req2.addHeader("Accept-Encoding", "deflate");
final HttpRequestWrapper req2Server = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com"));
+ "http://foo.example.com"), host);
req2Server.addHeader("Accept-Encoding", "deflate");
req2Server.addHeader("If-None-Match", "\"gzip_etag\"");
@@ -1257,12 +1257,12 @@ public abstract class TestCachingExecChain {
resp2.setHeader("Cache-Control", "public, max-age=3600");
final HttpRequestWrapper req4 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com"));
+ "http://foo.example.com"), host);
req4.addHeader("Accept-Encoding", "gzip,identity");
req4.addHeader("If-None-Match", "\"gzip_etag\"");
final HttpRequestWrapper req4Server = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com"));
+ "http://foo.example.com"), host);
req4Server.addHeader("Accept-Encoding", "gzip,identity");
req4Server.addHeader("If-None-Match", "\"gzip_etag\"");
@@ -1296,7 +1296,7 @@ public abstract class TestCachingExecChain {
final Date now = new Date();
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com"));
+ "http://foo.example.com"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"OK");
@@ -1502,7 +1502,6 @@ public abstract class TestCachingExecChain {
ctx.setTargetHost(host);
impl.execute(route, request, context, null);
impl.execute(route, request, ctx, null);
- assertTrue(ctx.isRequestSent());
}
@Test
@@ -1527,7 +1526,7 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req1.addHeader("If-None-Match", "\"etag\"");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
@@ -1554,11 +1553,11 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req1.addHeader("If-None-Match", "etag");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req2.addHeader("If-None-Match", "etag");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
@@ -1594,11 +1593,11 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req1.addHeader("If-None-Match", "etag");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req2.addHeader("If-None-Match", "etag");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
@@ -1637,11 +1636,11 @@ public abstract class TestCachingExecChain {
impl = createCachingExecChain(mockBackend, new BasicHttpCache(), CacheConfig.DEFAULT);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
req1.addHeader("If-None-Match", "etag");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet(
- "http://foo.example.com/"));
+ "http://foo.example.com/"), host);
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
HttpStatus.SC_NOT_MODIFIED, "Not modified");
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java
index 2e728bd0b..006ca0316 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCombinedEntity.java
@@ -32,8 +32,8 @@ import static org.mockito.Mockito.when;
import java.io.ByteArrayInputStream;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.client.cache.Resource;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestConditionalRequestBuilder.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestConditionalRequestBuilder.java
index 0c2193f24..725053b1c 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestConditionalRequestBuilder.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestConditionalRequestBuilder.java
@@ -30,17 +30,18 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolException;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpRequest;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -48,14 +49,16 @@ import org.junit.Test;
public class TestConditionalRequestBuilder {
private ConditionalRequestBuilder impl;
+ private HttpHost host;
private HttpRequestWrapper request;
private HttpCacheEntry entry;
@Before
public void setUp() throws Exception {
impl = new ConditionalRequestBuilder();
+ host = new HttpHost("foo.example.com", 80);
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
entry = HttpTestUtils.makeCacheEntry();
}
@@ -67,7 +70,7 @@ public class TestConditionalRequestBuilder {
final HttpRequest basicRequest = new BasicHttpRequest(theMethod, theUri);
basicRequest.addHeader("Accept-Encoding", "gzip");
- final HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(basicRequest);
+ final HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(basicRequest, host);
final Header[] headers = new Header[] {
new BasicHeader("Date", DateUtils.formatDate(new Date())),
@@ -105,7 +108,7 @@ public class TestConditionalRequestBuilder {
new BasicHeader("ETag", etag)
};
final HttpRequest basicRequest = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
- final HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(basicRequest);
+ final HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(basicRequest, host);
final HttpCacheEntry cacheEntry = HttpTestUtils.makeCacheEntry(headers);
final HttpRequest result = impl.buildConditionalRequest(requestWrapper, cacheEntry);
Assert.assertEquals(lmDate,
@@ -122,7 +125,7 @@ public class TestConditionalRequestBuilder {
final HttpRequest basicRequest = new BasicHttpRequest(theMethod, theUri);
basicRequest.addHeader("Accept-Encoding", "gzip");
- final HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(basicRequest);
+ final HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(basicRequest, host);
final Header[] headers = new Header[] {
new BasicHeader("Date", DateUtils.formatDate(new Date())),
@@ -152,7 +155,7 @@ public class TestConditionalRequestBuilder {
@Test
public void testCacheEntryWithMustRevalidateDoesEndToEndRevalidation() throws Exception {
final HttpRequest basicRequest = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
- final HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(basicRequest);
+ final HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(basicRequest, host);
final Date now = new Date();
final Date elevenSecondsAgo = new Date(now.getTime() - 11 * 1000L);
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
@@ -181,7 +184,7 @@ public class TestConditionalRequestBuilder {
@Test
public void testCacheEntryWithProxyRevalidateDoesEndToEndRevalidation() throws Exception {
final HttpRequest basicRequest = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
- final HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(basicRequest);
+ final HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(basicRequest, host);
final Date now = new Date();
final Date elevenSecondsAgo = new Date(now.getTime() - 11 * 1000L);
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
@@ -218,7 +221,7 @@ public class TestConditionalRequestBuilder {
public void testBuildUnconditionalRequestUsesRequestUri()
throws Exception {
final String uri = "/theURI";
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1), host);
final HttpRequest result = impl.buildUnconditionalRequest(request, entry);
Assert.assertEquals(uri, result.getRequestLine().getUri());
}
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestExponentialBackingOffSchedulingStrategy.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestExponentialBackingOffSchedulingStrategy.java
index 40559afdb..cedc488fd 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestExponentialBackingOffSchedulingStrategy.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestExponentialBackingOffSchedulingStrategy.java
@@ -30,18 +30,18 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import org.apache.http.HttpHost;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.execchain.ClientExecChain;
-import org.apache.http.message.BasicHttpRequest;
import org.junit.Before;
import org.junit.Test;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
public class TestExponentialBackingOffSchedulingStrategy {
private ScheduledExecutorService mockExecutor;
@@ -159,8 +159,9 @@ public class TestExponentialBackingOffSchedulingStrategy {
final ClientExecChain clientExecChain = mock(ClientExecChain.class);
final CachingExec cachingHttpClient = new CachingExec(clientExecChain);
final AsynchronousValidator mockValidator = new AsynchronousValidator(impl);
- final HttpRoute httpRoute = new HttpRoute(new HttpHost("foo.example.com", 80));
- final HttpRequestWrapper httpRequestWrapper = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/"));
+ final HttpHost host = new HttpHost("foo.example.com", 80);
+ final HttpRoute httpRoute = new HttpRoute(host);
+ final HttpRequestWrapper httpRequestWrapper = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/"), host);
final HttpClientContext httpClientContext = new HttpClientContext();
return new AsynchronousValidationRequest(mockValidator, cachingHttpClient, httpRoute, httpRequestWrapper,
httpClientContext, null, null, "identifier", errorCount);
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheEntrySerializers.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheEntrySerializers.java
index 703be3dbb..54feec665 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheEntrySerializers.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheEntrySerializers.java
@@ -39,15 +39,15 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
-import org.apache.http.Header;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.StatusLine;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.StatusLine;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicStatusLine;
import org.apache.http.client.cache.HeaderConstants;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheEntrySerializer;
import org.apache.http.client.cache.Resource;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicStatusLine;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java
index ceb8f71ae..45483115c 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java
@@ -36,9 +36,10 @@ import static org.mockito.Mockito.when;
import java.io.File;
import java.util.Date;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.cache.HttpCacheStorage;
import org.apache.http.client.cache.ResourceFactory;
import org.apache.http.client.methods.HttpExecutionAware;
@@ -48,7 +49,6 @@ import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.DateUtils;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.execchain.ClientExecChain;
-import org.apache.http.message.BasicHttpResponse;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -95,7 +95,7 @@ public class TestHttpCacheJiraNumber1147 {
final HttpCacheStorage httpCacheStorage = new ManagedHttpCacheStorage(cacheConfig);
final ClientExecChain backend = mock(ClientExecChain.class);
- final HttpRequestWrapper get = HttpRequestWrapper.wrap(new HttpGet("http://somehost/"));
+ final HttpRequestWrapper get = HttpRequestWrapper.wrap(new HttpGet("http://somehost/"), new HttpHost("somehost"));
final HttpClientContext context = HttpClientContext.create();
final HttpHost target = new HttpHost("somehost", 80);
final HttpRoute route = new HttpRoute(target);
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestImmediateSchedulingStrategy.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestImmediateSchedulingStrategy.java
index fdb48051e..4f46e5701 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestImmediateSchedulingStrategy.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestImmediateSchedulingStrategy.java
@@ -28,11 +28,11 @@ package org.apache.http.impl.client.cache;
import static org.mockito.Mockito.mock;
+import java.util.concurrent.ExecutorService;
+
import org.junit.Before;
import org.junit.Test;
-import java.util.concurrent.ExecutorService;
-
public class TestImmediateSchedulingStrategy {
private ExecutorService mockExecutor;
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolAllowedBehavior.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolAllowedBehavior.java
index 2de853e07..50f26b7de 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolAllowedBehavior.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolAllowedBehavior.java
@@ -29,12 +29,12 @@ package org.apache.http.impl.client.cache;
import java.net.SocketTimeoutException;
import java.util.Date;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHttpRequest;
import org.junit.Assert;
import org.junit.Test;
@@ -49,7 +49,7 @@ public class TestProtocolAllowedBehavior extends AbstractProtocolTest {
public void testNonSharedCacheReturnsStaleResponseWhenRevalidationFailsForProxyRevalidate()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET","/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET","/", HttpVersion.HTTP_1_1), host);
final Date now = new Date();
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
originResponse.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
@@ -59,7 +59,7 @@ public class TestProtocolAllowedBehavior extends AbstractProtocolTest {
backendExpectsAnyRequest().andReturn(originResponse);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET","/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET","/", HttpVersion.HTTP_1_1), host);
backendExpectsAnyRequest().andThrow(new SocketTimeoutException());
@@ -76,13 +76,13 @@ public class TestProtocolAllowedBehavior extends AbstractProtocolTest {
public void testNonSharedCacheMayCacheResponsesWithCacheControlPrivate()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET","/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET","/", HttpVersion.HTTP_1_1), host);
originResponse.setHeader("Cache-Control","private,max-age=3600");
backendExpectsAnyRequest().andReturn(originResponse);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET","/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET","/", HttpVersion.HTTP_1_1), host);
replayMocks();
behaveAsNonSharedCache();
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java
index 85e677714..41c6b9d73 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolDeviations.java
@@ -29,26 +29,24 @@ package org.apache.http.impl.client.cache;
import java.util.Date;
import java.util.Random;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolVersion;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.client.utils.DateUtils;
+import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.execchain.ClientExecChain;
-import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.BasicHttpResponse;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.junit.Assert;
@@ -73,7 +71,7 @@ import org.junit.Test;
@SuppressWarnings("boxing") // test code
public class TestProtocolDeviations {
- private static ProtocolVersion HTTP_1_1 = new ProtocolVersion("HTTP", 1, 1);
+ private static final ProtocolVersion HTTP_1_1 = new ProtocolVersion("HTTP", 1, 1);
private static final int MAX_BYTES = 1024;
private static final int MAX_ENTRIES = 100;
@@ -174,13 +172,13 @@ public class TestProtocolDeviations {
*/
@Ignore
public void testHTTP1_1RequestsWithBodiesOfKnownLengthMustHaveContentLength() throws Exception {
- final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
+ final BasicHttpRequest post = new BasicHttpRequest("POST", "/",
HTTP_1_1);
post.setEntity(mockEntity);
replayMocks();
- final HttpResponse response = impl.execute(route, HttpRequestWrapper.wrap(post), context, null);
+ final HttpResponse response = impl.execute(route, HttpRequestWrapper.wrap(post, host), context, null);
verifyMocks();
@@ -215,7 +213,7 @@ public class TestProtocolDeviations {
@Ignore
public void testHTTP1_1RequestsWithUnknownBodyLengthAreRejectedOrHaveContentLengthAdded()
throws Exception {
- final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
+ final BasicHttpRequest post = new BasicHttpRequest("POST", "/",
HTTP_1_1);
final byte[] bytes = new byte[128];
@@ -238,7 +236,7 @@ public class TestProtocolDeviations {
replayMocks();
EasyMock.replay(mockBody);
- final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(post), context, null);
+ final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(post, host), context, null);
verifyMocks();
EasyMock.verify(mockBody);
@@ -263,7 +261,7 @@ public class TestProtocolDeviations {
*/
@Test
public void testOPTIONSRequestsWithBodiesAndNoContentTypeHaveOneSupplied() throws Exception {
- final BasicHttpEntityEnclosingRequest options = new BasicHttpEntityEnclosingRequest("OPTIONS",
+ final BasicHttpRequest options = new BasicHttpRequest("OPTIONS",
"/", HTTP_1_1);
options.setEntity(body);
options.setHeader("Content-Length", "1");
@@ -277,13 +275,11 @@ public class TestProtocolDeviations {
EasyMock.isNull())).andReturn(originResponse);
replayMocks();
- impl.execute(route, HttpRequestWrapper.wrap(options), context, null);
+ impl.execute(route, HttpRequestWrapper.wrap(options, host), context, null);
verifyMocks();
- final HttpRequest forwarded = reqCap.getValue();
- Assert.assertTrue(forwarded instanceof HttpEntityEnclosingRequest);
- final HttpEntityEnclosingRequest reqWithBody = (HttpEntityEnclosingRequest) forwarded;
+ final HttpRequest reqWithBody = reqCap.getValue();
final HttpEntity reqBody = reqWithBody.getEntity();
Assert.assertNotNull(reqBody);
Assert.assertNotNull(reqBody.getContentType());
@@ -319,7 +315,7 @@ public class TestProtocolDeviations {
replayMocks();
try {
- final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
+ final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request, host), context, null);
Assert.assertTrue(HttpStatus.SC_PARTIAL_CONTENT != result.getStatusLine()
.getStatusCode());
} catch (final ClientProtocolException acceptableBehavior) {
@@ -347,7 +343,7 @@ public class TestProtocolDeviations {
EasyMock.isA(HttpClientContext.class),
EasyMock.isNull())).andReturn(originResponse);
replayMocks();
- final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
+ final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request, host), context, null);
verifyMocks();
Assert.assertSame(originResponse, result);
}
@@ -370,7 +366,7 @@ public class TestProtocolDeviations {
EasyMock.isA(HttpClientContext.class),
EasyMock.isNull())).andReturn(originResponse);
replayMocks();
- final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
+ final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request, host), context, null);
verifyMocks();
Assert.assertSame(originResponse, result);
}
@@ -394,7 +390,7 @@ public class TestProtocolDeviations {
EasyMock.isA(HttpClientContext.class),
EasyMock.isNull())).andReturn(originResponse);
replayMocks();
- final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
+ final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request, host), context, null);
verifyMocks();
Assert.assertSame(originResponse, result);
}
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRecommendations.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRecommendations.java
index b9de85950..51a02dc62 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRecommendations.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRecommendations.java
@@ -37,23 +37,20 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.client.ClientProtocolException;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.BasicHttpResponse;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.junit.Before;
@@ -114,9 +111,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
*/
private void cacheGenerated304ForValidatorShouldNotContainEntityHeader(
final String headerName, final String headerValue, final String validatorHeader,
- final String validator, final String conditionalHeader) throws Exception,
- IOException {
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final String validator, final String conditionalHeader) throws Exception {
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","max-age=3600");
resp1.setHeader(validatorHeader, validator);
@@ -124,7 +120,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader(conditionalHeader, validator);
replayMocks();
@@ -138,15 +134,13 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
}
private void cacheGenerated304ForStrongETagValidatorShouldNotContainEntityHeader(
- final String headerName, final String headerValue) throws Exception,
- IOException {
+ final String headerName, final String headerValue) throws Exception {
cacheGenerated304ForValidatorShouldNotContainEntityHeader(headerName,
headerValue, "ETag", "\"etag\"", "If-None-Match");
}
private void cacheGenerated304ForStrongDateValidatorShouldNotContainEntityHeader(
- final String headerName, final String headerValue) throws Exception,
- IOException {
+ final String headerName, final String headerValue) throws Exception {
cacheGenerated304ForValidatorShouldNotContainEntityHeader(headerName,
headerValue, "Last-Modified", DateUtils.formatDate(twoMinutesAgo),
"If-Modified-Since");
@@ -224,8 +218,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
private void cacheGenerated304ForStrongValidatorShouldNotContainContentRange(
final String validatorHeader, final String validator, final String conditionalHeader)
- throws Exception, IOException, ClientProtocolException {
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ throws Exception {
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req1.setHeader("Range","bytes=0-127");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
resp1.setHeader("Cache-Control","max-age=3600");
@@ -234,7 +228,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("If-Range", validator);
req2.setHeader("Range","bytes=0-127");
req2.setHeader(conditionalHeader, validator);
@@ -309,9 +303,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
}
private void shouldStripEntityHeaderFromOrigin304ResponseToStrongValidation(
- final String entityHeader, final String entityHeaderValue) throws Exception,
- IOException {
- final HttpRequestWrapper req = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final String entityHeader, final String entityHeaderValue) throws Exception {
+ final HttpRequestWrapper req = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req.setHeader("If-None-Match", "\"etag\"");
final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not Modified");
@@ -373,7 +366,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void shouldStripContentRangeFromOrigin304ResponseToStringValidation()
throws Exception {
- final HttpRequestWrapper req = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req.setHeader("If-Range","\"etag\"");
req.setHeader("Range","bytes=0-127");
@@ -405,7 +398,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
*/
private HttpRequestWrapper requestToPopulateStaleCacheEntry() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
resp1.setHeader("Cache-Control","public,max-age=5");
@@ -416,7 +409,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
}
private void testDoesNotReturnStaleResponseOnError(final HttpRequestWrapper req2)
- throws Exception, IOException {
+ throws Exception {
final HttpRequestWrapper req1 = requestToPopulateStaleCacheEntry();
backendExpectsAnyRequest().andThrow(new IOException());
@@ -439,7 +432,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFirstHandOneWithCacheControl()
throws Exception {
final HttpRequestWrapper req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req.setHeader("Cache-Control","no-cache");
testDoesNotReturnStaleResponseOnError(req);
}
@@ -448,7 +441,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFirstHandOneWithPragma()
throws Exception {
final HttpRequestWrapper req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req.setHeader("Pragma","no-cache");
testDoesNotReturnStaleResponseOnError(req);
}
@@ -457,7 +450,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFreshWithMaxAge()
throws Exception {
final HttpRequestWrapper req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req.setHeader("Cache-Control","max-age=0");
testDoesNotReturnStaleResponseOnError(req);
}
@@ -466,7 +459,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void testDoesNotReturnStaleResponseIfClientExplicitlySpecifiesLargerMaxAge()
throws Exception {
final HttpRequestWrapper req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req.setHeader("Cache-Control","max-age=20");
testDoesNotReturnStaleResponseOnError(req);
}
@@ -476,7 +469,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFreshWithMinFresh()
throws Exception {
final HttpRequestWrapper req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req.setHeader("Cache-Control","min-fresh=2");
testDoesNotReturnStaleResponseOnError(req);
@@ -486,7 +479,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFreshWithMaxStale()
throws Exception {
final HttpRequestWrapper req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req.setHeader("Cache-Control","max-stale=2");
testDoesNotReturnStaleResponseOnError(req);
@@ -497,7 +490,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
throws Exception {
final HttpRequestWrapper req1 = requestToPopulateStaleCacheEntry();
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control","max-stale=20");
backendExpectsAnyRequest().andThrow(new IOException()).times(0,1);
@@ -548,7 +541,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void testReturnsCachedResponsesAppropriatelyWhenNoOriginCommunication()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control", "public, max-age=5");
resp1.setHeader("ETag","\"etag\"");
@@ -557,7 +550,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
backendExpectsAnyRequest().andThrow(new IOException()).anyTimes();
@@ -680,11 +673,11 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void testDoesNotModifyContentLengthOnRequests()
throws Exception {
- final HttpEntityEnclosingRequest post =
- new BasicHttpEntityEnclosingRequest("POST", "/", HttpVersion.HTTP_1_1);
+ final HttpRequest post =
+ new BasicHttpRequest("POST", "/", HttpVersion.HTTP_1_1);
post.setEntity(HttpTestUtils.makeBody(128));
post.setHeader("Content-Length","128");
- request = HttpRequestWrapper.wrap(post);
+ request = HttpRequestWrapper.wrap(post, host);
testDoesNotModifyHeaderOnRequests("Content-Length");
}
@@ -699,12 +692,12 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void testDoesNotModifyContentMD5OnRequests()
throws Exception {
- final HttpEntityEnclosingRequest post =
- new BasicHttpEntityEnclosingRequest("POST", "/", HttpVersion.HTTP_1_1);
+ final HttpRequest post =
+ new BasicHttpRequest("POST", "/", HttpVersion.HTTP_1_1);
post.setEntity(HttpTestUtils.makeBody(128));
post.setHeader("Content-Length","128");
post.setHeader("Content-MD5","Q2hlY2sgSW50ZWdyaXR5IQ==");
- request = HttpRequestWrapper.wrap(post);
+ request = HttpRequestWrapper.wrap(post, host);
testDoesNotModifyHeaderOnRequests("Content-MD5");
}
@@ -719,12 +712,12 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void testDoesNotModifyContentRangeOnRequests()
throws Exception {
- final HttpEntityEnclosingRequest put =
- new BasicHttpEntityEnclosingRequest("PUT", "/", HttpVersion.HTTP_1_1);
+ final HttpRequest put =
+ new BasicHttpRequest("PUT", "/", HttpVersion.HTTP_1_1);
put.setEntity(HttpTestUtils.makeBody(128));
put.setHeader("Content-Length","128");
put.setHeader("Content-Range","bytes 0-127/256");
- request = HttpRequestWrapper.wrap(put);
+ request = HttpRequestWrapper.wrap(put, host);
testDoesNotModifyHeaderOnRequests("Content-Range");
}
@@ -742,12 +735,12 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void testDoesNotModifyContentTypeOnRequests()
throws Exception {
- final HttpEntityEnclosingRequest post =
- new BasicHttpEntityEnclosingRequest("POST", "/", HttpVersion.HTTP_1_1);
+ final HttpRequest post =
+ new BasicHttpRequest("POST", "/", HttpVersion.HTTP_1_1);
post.setEntity(HttpTestUtils.makeBody(128));
post.setHeader("Content-Length","128");
post.setHeader("Content-Type","application/octet-stream");
- request = HttpRequestWrapper.wrap(post);
+ request = HttpRequestWrapper.wrap(post, host);
testDoesNotModifyHeaderOnRequests("Content-Type");
}
@@ -796,8 +789,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void testDoesNotModifyIfMatchOnRequests()
throws Exception {
- request = HttpRequestWrapper.wrap(HttpRequestWrapper.wrap(
- new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1)));
+ request = HttpRequestWrapper.wrap(
+ new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1), host);
request.setHeader("If-Match", "\"etag\"");
testDoesNotModifyHeaderOnRequests("If-Match");
}
@@ -827,8 +820,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void testDoesNotModifyIfUnmodifiedSinceOnRequests()
throws Exception {
- request = HttpRequestWrapper.wrap(HttpRequestWrapper.wrap(
- new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1)));
+ request = HttpRequestWrapper.wrap(
+ new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1), host);
request.setHeader("If-Unmodified-Since", DateUtils.formatDate(new Date()));
testDoesNotModifyHeaderOnRequests("If-Unmodified-Since");
}
@@ -923,7 +916,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
final String lmDate = DateUtils.formatDate(twentySecondsAgo);
final HttpRequestWrapper req1 =
- HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
resp1.setHeader("Last-Modified", lmDate);
@@ -933,7 +926,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
final Capture cap = new Capture<>();
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
EasyMock.expect(
@@ -971,7 +964,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
final String etag = "\"etag\"";
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
resp1.setHeader("Last-Modified", lmDate);
@@ -982,7 +975,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
final Capture cap = new Capture<>();
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
EasyMock.expect(
@@ -1022,7 +1015,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
final Date oneSecondFromNow = new Date(now.getTime() + 1 * 1000L);
final Date twoSecondsFromNow = new Date(now.getTime() + 2 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("ETag","\"etag\"");
resp1.setHeader("Date", DateUtils.formatDate(now));
@@ -1032,9 +1025,9 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpRequestWrapper revalidate = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/",HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/",HttpVersion.HTTP_1_1), host);
revalidate.setHeader("If-None-Match","\"etag\"");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
@@ -1078,7 +1071,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
throws Exception {
final Date elevenSecondsAgo = new Date(now.getTime() - 11 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("ETag","\"etag\"");
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
@@ -1087,7 +1080,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
HttpStatus.SC_NOT_MODIFIED, "Not Modified");
resp2.setHeader("ETag","\"etag\"");
@@ -1152,7 +1145,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void testSendsAllVariantEtagsInConditionalRequest()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1), host);
req1.setHeader("User-Agent","agent1");
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","max-age=3600");
@@ -1162,7 +1155,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1), host);
req2.setHeader("User-Agent","agent2");
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("Cache-Control","max-age=3600");
@@ -1173,7 +1166,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
final Capture cap = new Capture<>();
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1), host);
req3.setHeader("User-Agent","agent3");
final HttpResponse resp3 = HttpTestUtils.make200Response();
@@ -1219,7 +1212,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("User-Agent", "agent1");
final HttpResponse resp1 = HttpTestUtils.make200Response();
@@ -1232,7 +1225,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("User-Agent", "agent2");
final HttpResponse resp2 = HttpTestUtils.make200Response();
@@ -1244,7 +1237,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req3.setHeader("User-Agent", "agent3");
final HttpResponse resp3 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not Modified");
@@ -1254,7 +1247,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp3);
final HttpRequestWrapper req4 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req4.setHeader("User-Agent", "agent1");
replayMocks();
@@ -1275,7 +1268,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("User-Agent", "agent1");
final HttpResponse resp1 = HttpTestUtils.make200Response();
@@ -1287,7 +1280,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("User-Agent", "agent2");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not Modified");
@@ -1297,7 +1290,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req3.setHeader("User-Agent", "agent2");
replayMocks();
@@ -1317,7 +1310,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void variantNegotiationsDoNotIncludeEtagsForPartialResponses()
throws Exception {
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req1.setHeader("User-Agent", "agent1");
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control", "max-age=3600");
@@ -1326,7 +1319,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("User-Agent", "agent2");
req2.setHeader("Range", "bytes=0-49");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
@@ -1341,7 +1334,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
- final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req3.setHeader("User-Agent", "agent3");
final HttpResponse resp3 = HttpTestUtils.make200Response();
@@ -1385,7 +1378,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void cachedEntryShouldNotBeUsedIfMoreRecentMentionInContentLocation()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new HttpGet("http://foo.example.com/"));
+ new HttpGet("http://foo.example.com/"), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","max-age=3600");
resp1.setHeader("ETag", "\"old-etag\"");
@@ -1394,7 +1387,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new HttpPost("http://foo.example.com/bar"));
+ new HttpPost("http://foo.example.com/bar"), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("ETag", "\"new-etag\"");
resp2.setHeader("Date", DateUtils.formatDate(now));
@@ -1403,7 +1396,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new HttpGet("http://foo.example.com"));
+ new HttpGet("http://foo.example.com"), host);
final HttpResponse resp3 = HttpTestUtils.make200Response();
backendExpectsAnyRequestAndReturn(resp3);
@@ -1426,7 +1419,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void responseToGetWithQueryFrom1_0OriginAndNoExpiresIsNotCached()
throws Exception {
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new HttpGet("http://foo.example.com/bar?baz=quux"));
+ new HttpGet("http://foo.example.com/bar?baz=quux"), host);
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
resp2.setEntity(HttpTestUtils.makeBody(200));
resp2.setHeader("Content-Length","200");
@@ -1443,7 +1436,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void responseToGetWithQueryFrom1_0OriginVia1_1ProxyAndNoExpiresIsNotCached()
throws Exception {
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new HttpGet("http://foo.example.com/bar?baz=quux"));
+ new HttpGet("http://foo.example.com/bar?baz=quux"), host);
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
resp2.setEntity(HttpTestUtils.makeBody(200));
resp2.setHeader("Content-Length","200");
@@ -1468,21 +1461,21 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void shouldInvalidateNonvariantCacheEntryForUnknownMethod()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","max-age=3600");
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("FROB", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("FROB", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("Cache-Control","max-age=3600");
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp3 = HttpTestUtils.make200Response();
resp3.setHeader("ETag", "\"etag\"");
@@ -1501,7 +1494,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void shouldInvalidateAllVariantsForUnknownMethod()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("User-Agent", "agent1");
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","max-age=3600");
@@ -1510,7 +1503,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("User-Agent", "agent2");
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("Cache-Control","max-age=3600");
@@ -1519,7 +1512,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("FROB", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("FROB", "/", HttpVersion.HTTP_1_1), host);
req3.setHeader("User-Agent", "agent3");
final HttpResponse resp3 = HttpTestUtils.make200Response();
resp3.setHeader("Cache-Control","max-age=3600");
@@ -1527,7 +1520,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp3);
final HttpRequestWrapper req4 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req4.setHeader("User-Agent", "agent1");
final HttpResponse resp4 = HttpTestUtils.make200Response();
resp4.setHeader("ETag", "\"etag1\"");
@@ -1535,7 +1528,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp4);
final HttpRequestWrapper req5 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req5.setHeader("User-Agent", "agent2");
final HttpResponse resp5 = HttpTestUtils.make200Response();
resp5.setHeader("ETag", "\"etag2\"");
@@ -1564,7 +1557,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void cacheShouldUpdateWithNewCacheableResponse()
throws Exception {
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
resp1.setHeader("Cache-Control", "max-age=3600");
@@ -1572,7 +1565,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control", "max-age=0");
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("Date", DateUtils.formatDate(now));
@@ -1581,7 +1574,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
- final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
replayMocks();
impl.execute(route, req1, context, null);
@@ -1606,7 +1599,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void expiresEqualToDateWithNoCacheControlIsNotCacheable()
throws Exception {
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(now));
resp1.setHeader("Expires", DateUtils.formatDate(now));
@@ -1614,7 +1607,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control", "max-stale=1000");
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("ETag", "\"etag2\"");
@@ -1632,7 +1625,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void expiresPriorToDateWithNoCacheControlIsNotCacheable()
throws Exception {
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(now));
resp1.setHeader("Expires", DateUtils.formatDate(tenSecondsAgo));
@@ -1640,7 +1633,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control", "max-stale=1000");
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("ETag", "\"etag2\"");
@@ -1664,7 +1657,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void otherFreshnessRequestDirectivesNotAllowedWithNoCache()
throws Exception {
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req1.setHeader("Cache-Control", "min-fresh=10, no-cache");
req1.addHeader("Cache-Control", "max-stale=0, max-age=0");
@@ -1713,7 +1706,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void cacheMissResultsIn504WithOnlyIfCached()
throws Exception {
- final HttpRequestWrapper req = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req.setHeader("Cache-Control", "only-if-cached");
replayMocks();
@@ -1727,13 +1720,13 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void cacheHitOkWithOnlyIfCached()
throws Exception {
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","max-age=3600");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control", "only-if-cached");
replayMocks();
@@ -1747,14 +1740,14 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void returns504ForStaleEntryWithOnlyIfCached()
throws Exception {
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
resp1.setHeader("Cache-Control","max-age=5");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control", "only-if-cached");
replayMocks();
@@ -1770,14 +1763,14 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
public void returnsStaleCacheEntryWithOnlyIfCachedAndMaxStale()
throws Exception {
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
resp1.setHeader("Cache-Control","max-age=5");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control", "max-stale=20, only-if-cached");
replayMocks();
@@ -1790,7 +1783,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
@Test
public void issues304EvenWithWeakETag() throws Exception {
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
resp1.setHeader("Cache-Control", "max-age=300");
@@ -1798,7 +1791,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("If-None-Match","W/\"weak-sauce\"");
replayMocks();
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java
index f62d1b7a3..3ad3a7f6c 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java
@@ -34,15 +34,21 @@ import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolVersion;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.entity.BasicHttpEntity;
+import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -51,13 +57,6 @@ import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.DateUtils;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.entity.BasicHttpEntity;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.protocol.HTTP;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.junit.Assert;
@@ -108,7 +107,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
// tunnel behavior: I don't muck with request or response in
// any way
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 2, 13)));
+ new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 2, 13)), host);
EasyMock.expect(
mockBackend.execute(
@@ -128,10 +127,10 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testHigher1_XProtocolVersionsDowngradeTo1_1() throws Exception {
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 2)));
+ new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 2)), host);
final HttpRequestWrapper downgraded = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1), host);
EasyMock.expect(
mockBackend.execute(
@@ -160,9 +159,9 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testRequestsWithLowerProtocolVersionsGetUpgradedTo1_1() throws Exception {
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 0)));
+ new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 0)), host);
final HttpRequestWrapper upgraded = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1), host);
EasyMock.expect(
mockBackend.execute(
@@ -213,7 +212,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testResponseToA1_0RequestShouldUse1_1() throws Exception {
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 0)));
+ new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 0)), host);
EasyMock.expect(
mockBackend.execute(
@@ -236,12 +235,12 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testForwardsUnknownHeadersOnRequestsFromHigherProtocolVersions() throws Exception {
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 2)));
+ new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 2)), host);
request.removeHeaders("Connection");
request.addHeader("X-Unknown-Header", "some-value");
final HttpRequestWrapper downgraded = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1), host);
downgraded.removeHeaders("Connection");
downgraded.addHeader("X-Unknown-Header", "some-value");
@@ -268,7 +267,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
originResponse.setHeader("Transfer-Encoding", "identity");
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 0)));
+ new BasicHttpRequest("GET", "/foo", new ProtocolVersion("HTTP", 1, 0)), host);
EasyMock.expect(
mockBackend.execute(
@@ -355,13 +354,13 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testOrderOfMultipleAllowHeadersIsPreservedOnRequests() throws Exception {
- final BasicHttpEntityEnclosingRequest put = new BasicHttpEntityEnclosingRequest("PUT", "/",
+ final BasicHttpRequest put = new BasicHttpRequest("PUT", "/",
HttpVersion.HTTP_1_1);
put.setEntity(body);
put.addHeader("Allow", "GET, HEAD");
put.addHeader("Allow", "DELETE");
put.addHeader("Content-Length", "128");
- testOrderOfMultipleHeadersIsPreservedOnRequests("Allow", HttpRequestWrapper.wrap(put));
+ testOrderOfMultipleHeadersIsPreservedOnRequests("Allow", HttpRequestWrapper.wrap(put, host));
}
@Test
@@ -373,35 +372,35 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testOrderOfMultipleContentEncodingHeadersIsPreservedOnRequests() throws Exception {
- final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
+ final BasicHttpRequest post = new BasicHttpRequest("POST", "/",
HttpVersion.HTTP_1_1);
post.setEntity(body);
post.addHeader("Content-Encoding", "gzip");
post.addHeader("Content-Encoding", "compress");
post.addHeader("Content-Length", "128");
- testOrderOfMultipleHeadersIsPreservedOnRequests("Content-Encoding", HttpRequestWrapper.wrap(post));
+ testOrderOfMultipleHeadersIsPreservedOnRequests("Content-Encoding", HttpRequestWrapper.wrap(post, host));
}
@Test
public void testOrderOfMultipleContentLanguageHeadersIsPreservedOnRequests() throws Exception {
- final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
+ final BasicHttpRequest post = new BasicHttpRequest("POST", "/",
HttpVersion.HTTP_1_1);
post.setEntity(body);
post.addHeader("Content-Language", "mi");
post.addHeader("Content-Language", "en");
post.addHeader("Content-Length", "128");
- testOrderOfMultipleHeadersIsPreservedOnRequests("Content-Language", HttpRequestWrapper.wrap(post));
+ testOrderOfMultipleHeadersIsPreservedOnRequests("Content-Language", HttpRequestWrapper.wrap(post, host));
}
@Test
public void testOrderOfMultipleExpectHeadersIsPreservedOnRequests() throws Exception {
- final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
+ final BasicHttpRequest post = new BasicHttpRequest("POST", "/",
HttpVersion.HTTP_1_1);
post.setEntity(body);
post.addHeader("Expect", "100-continue");
post.addHeader("Expect", "x-expect=true");
post.addHeader("Content-Length", "128");
- testOrderOfMultipleHeadersIsPreservedOnRequests("Expect", HttpRequestWrapper.wrap(post));
+ testOrderOfMultipleHeadersIsPreservedOnRequests("Expect", HttpRequestWrapper.wrap(post, host));
}
@Test
@@ -605,9 +604,9 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
*/
@Test
public void testRequestsExpecting100ContinueBehaviorShouldSetExpectHeader() throws Exception {
- final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest(
+ final BasicHttpRequest post = new BasicHttpRequest(
"POST", "/", HttpVersion.HTTP_1_1);
- post.setHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
+ post.setHeader(HttpHeaders.EXPECT, HeaderElements.CONTINUE);
post.setHeader("Content-Length", "128");
post.setEntity(new BasicHttpEntity());
@@ -622,7 +621,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
replayMocks();
- impl.execute(route, HttpRequestWrapper.wrap(post), context, null);
+ impl.execute(route, HttpRequestWrapper.wrap(post, host), context, null);
verifyMocks();
@@ -649,7 +648,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testRequestsNotExpecting100ContinueBehaviorShouldNotSetExpectContinueHeader()
throws Exception {
- final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest(
+ final BasicHttpRequest post = new BasicHttpRequest(
"POST", "/", HttpVersion.HTTP_1_1);
post.setHeader("Content-Length", "128");
post.setEntity(new BasicHttpEntity());
@@ -665,7 +664,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
replayMocks();
- impl.execute(route, HttpRequestWrapper.wrap(post), context, null);
+ impl.execute(route, HttpRequestWrapper.wrap(post, host), context, null);
verifyMocks();
@@ -750,7 +749,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void test100ContinueResponsesAreNotForwardedTo1_0ClientsWhoDidNotAskForThem()
throws Exception {
- final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
+ final BasicHttpRequest post = new BasicHttpRequest("POST", "/",
new ProtocolVersion("HTTP", 1, 0));
post.setEntity(body);
post.setHeader("Content-Length", "128");
@@ -768,7 +767,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
try {
// if a 100 response gets up to us from the HttpClient
// backend, we can't really handle it at that point
- impl.execute(route, HttpRequestWrapper.wrap(post), context, null);
+ impl.execute(route, HttpRequestWrapper.wrap(post, host), context, null);
Assert.fail("should have thrown an exception");
} catch (final ClientProtocolException expected) {
}
@@ -784,7 +783,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testResponsesToOPTIONSAreNotCacheable() throws Exception {
emptyMockCacheExpectsNoPuts();
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("OPTIONS", "/", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("OPTIONS", "/", HttpVersion.HTTP_1_1), host);
originResponse.addHeader("Cache-Control", "max-age=3600");
EasyMock.expect(
@@ -810,7 +809,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void test200ResponseToOPTIONSWithNoBodyShouldIncludeContentLengthZero() throws Exception {
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("OPTIONS", "/", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("OPTIONS", "/", HttpVersion.HTTP_1_1), host);
originResponse.setEntity(null);
originResponse.setHeader("Content-Length", "0");
@@ -842,7 +841,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testDoesNotForwardOPTIONSWhenMaxForwardsIsZeroOnAbsoluteURIRequest()
throws Exception {
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("OPTIONS", "*", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("OPTIONS", "*", HttpVersion.HTTP_1_1), host);
request.setHeader("Max-Forwards", "0");
replayMocks();
@@ -859,7 +858,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testDecrementsMaxForwardsWhenForwardingOPTIONSRequest() throws Exception {
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("OPTIONS", "*", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("OPTIONS", "*", HttpVersion.HTTP_1_1), host);
request.setHeader("Max-Forwards", "7");
final Capture cap = new Capture<>();
@@ -887,7 +886,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
*/
@Test
public void testDoesNotAddAMaxForwardsHeaderToForwardedOPTIONSRequests() throws Exception {
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("OPTIONS", "/", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("OPTIONS", "/", HttpVersion.HTTP_1_1), host);
final Capture reqCap = new Capture<>();
EasyMock.expect(
mockBackend.execute(
@@ -912,7 +911,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
*/
@Test
public void testResponseToAHEADRequestMustNotHaveABody() throws Exception {
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("HEAD", "/", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("HEAD", "/", HttpVersion.HTTP_1_1), host);
EasyMock.expect(
mockBackend.execute(
EasyMock.eq(route),
@@ -942,14 +941,14 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
// put something cacheable in the cache
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.addHeader("Cache-Control", "max-age=3600");
resp1.setHeader(eHeader, oldVal);
// get a head that penetrates the cache
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("HEAD", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("HEAD", "/", HttpVersion.HTTP_1_1), host);
req2.addHeader("Cache-Control", "no-cache");
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setEntity(null);
@@ -957,7 +956,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
// next request doesn't tolerate stale entry
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req3.addHeader("Cache-Control", "max-stale=0");
final HttpResponse resp3 = HttpTestUtils.make200Response();
resp3.setHeader(eHeader, newVal);
@@ -1029,7 +1028,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testResponsesToPOSTWithoutCacheControlOrExpiresAreNotCached() throws Exception {
emptyMockCacheExpectsNoPuts();
- final BasicHttpEntityEnclosingRequest post = new BasicHttpEntityEnclosingRequest("POST", "/",
+ final BasicHttpRequest post = new BasicHttpRequest("POST", "/",
HttpVersion.HTTP_1_1);
post.setHeader("Content-Length", "128");
post.setEntity(HttpTestUtils.makeBody(128));
@@ -1046,7 +1045,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
replayMocks();
- impl.execute(route, HttpRequestWrapper.wrap(post), context, null);
+ impl.execute(route, HttpRequestWrapper.wrap(post, host), context, null);
verifyMocks();
}
@@ -1060,7 +1059,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testResponsesToPUTsAreNotCached() throws Exception {
emptyMockCacheExpectsNoPuts();
- final BasicHttpEntityEnclosingRequest put = new BasicHttpEntityEnclosingRequest("PUT", "/",
+ final BasicHttpRequest put = new BasicHttpRequest("PUT", "/",
HttpVersion.HTTP_1_1);
put.setEntity(HttpTestUtils.makeBody(128));
put.addHeader("Content-Length", "128");
@@ -1076,7 +1075,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
replayMocks();
- impl.execute(route, HttpRequestWrapper.wrap(put), context, null);
+ impl.execute(route, HttpRequestWrapper.wrap(put, host), context, null);
verifyMocks();
}
@@ -1090,7 +1089,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testResponsesToDELETEsAreNotCached() throws Exception {
emptyMockCacheExpectsNoPuts();
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1), host);
originResponse.setHeader("Cache-Control", "max-age=3600");
EasyMock.expect(
@@ -1114,7 +1113,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
*/
@Test
public void testForwardedTRACERequestsDoNotIncludeAnEntity() throws Exception {
- final BasicHttpEntityEnclosingRequest trace = new BasicHttpEntityEnclosingRequest("TRACE", "/",
+ final BasicHttpRequest trace = new BasicHttpRequest("TRACE", "/",
HttpVersion.HTTP_1_1);
trace.setEntity(HttpTestUtils.makeBody(entityLength));
trace.setHeader("Content-Length", Integer.toString(entityLength));
@@ -1129,17 +1128,11 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
EasyMock.isNull())).andReturn(originResponse);
replayMocks();
- impl.execute(route, HttpRequestWrapper.wrap(trace), context, null);
+ impl.execute(route, HttpRequestWrapper.wrap(trace, host), context, null);
verifyMocks();
- final HttpRequest forwarded = reqCap.getValue();
- if (forwarded instanceof HttpEntityEnclosingRequest) {
- final HttpEntityEnclosingRequest bodyReq = (HttpEntityEnclosingRequest) forwarded;
- Assert.assertTrue(bodyReq.getEntity() == null
- || bodyReq.getEntity().getContentLength() == 0);
- } else {
- // request didn't enclose an entity
- }
+ final HttpRequest bodyReq = reqCap.getValue();
+ Assert.assertTrue(bodyReq.getEntity() == null || bodyReq.getEntity().getContentLength() == 0);
}
/*
@@ -1151,7 +1144,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testResponsesToTRACEsAreNotCached() throws Exception {
emptyMockCacheExpectsNoPuts();
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("TRACE", "/", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("TRACE", "/", HttpVersion.HTTP_1_1), host);
originResponse.setHeader("Cache-Control", "max-age=3600");
EasyMock.expect(
@@ -1247,13 +1240,13 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("ETag", "\"etag\"");
resp1.setHeader("Cache-Control", "max-age=3600");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range", "bytes=0-50");
backendExpectsAnyRequestAndReturn(resp1).times(1, 2);
@@ -1279,13 +1272,13 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("ETag", "\"etag\"");
resp1.setHeader("Cache-Control", "max-age=3600");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range", "bytes=0-50");
backendExpectsAnyRequestAndReturn(resp1).times(1, 2);
@@ -1313,13 +1306,13 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void test206ResponseGeneratedFromCacheMustHaveDateHeader() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("ETag", "\"etag\"");
resp1.setHeader("Cache-Control", "max-age=3600");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range", "bytes=0-50");
backendExpectsAnyRequestAndReturn(resp1).times(1, 2);
@@ -1364,13 +1357,13 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void test206ContainsETagIfA200ResponseWouldHaveIncludedIt() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
originResponse.addHeader("Cache-Control", "max-age=3600");
originResponse.addHeader("ETag", "\"etag1\"");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.addHeader("Range", "bytes=0-50");
backendExpectsAnyRequest().andReturn(originResponse).times(1, 2);
@@ -1390,13 +1383,13 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void test206ContainsContentLocationIfA200ResponseWouldHaveIncludedIt() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
originResponse.addHeader("Cache-Control", "max-age=3600");
originResponse.addHeader("Content-Location", "http://foo.example.com/other/url");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.addHeader("Range", "bytes=0-50");
backendExpectsAnyRequest().andReturn(originResponse).times(1, 2);
@@ -1417,7 +1410,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void test206ResponseIncludesVariantHeadersIfValueMightDiffer() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.addHeader("Accept-Encoding", "gzip");
final Date now = new Date();
@@ -1427,7 +1420,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
originResponse.addHeader("Vary", "Accept-Encoding");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.addHeader("Cache-Control", "no-cache");
req2.addHeader("Accept-Encoding", "gzip");
final Date nextSecond = new Date(now.getTime() + 1000L);
@@ -1440,7 +1433,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
originResponse2.setHeader("Vary", "Accept-Encoding");
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req3.addHeader("Range", "bytes=0-50");
req3.addHeader("Accept-Encoding", "gzip");
@@ -1475,7 +1468,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final Date now = new Date();
final Date oneHourAgo = new Date(now.getTime() - 3600 * 1000L);
@@ -1491,7 +1484,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
originResponse.addHeader("ETag", "W/\"weak-tag\"");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.addHeader("If-Range", "W/\"weak-tag\"");
req2.addHeader("Range", "bytes=0-50");
@@ -1525,7 +1518,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final Date now = new Date();
final Date oneHourAgo = new Date(now.getTime() - 3600 * 1000L);
@@ -1540,7 +1533,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
originResponse.addHeader("ETag", "\"strong-tag\"");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.addHeader("If-Range", "\"strong-tag\"");
req2.addHeader("Range", "bytes=0-50");
@@ -1579,7 +1572,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date now = new Date();
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control", "max-age=3600");
resp1.setHeader("ETag", "\"etag1\"");
@@ -1590,7 +1583,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp1.setEntity(new ByteArrayEntity(bytes1));
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control", "no-cache");
req2.setHeader("Range", "bytes=0-50");
@@ -1609,7 +1602,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date inTwoSeconds = new Date(now.getTime() + 2000L);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp3 = HttpTestUtils.make200Response();
resp3.setHeader("Date", DateUtils.formatDate(inTwoSeconds));
resp3.setHeader("Cache-Control", "max-age=3600");
@@ -1672,7 +1665,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date now = new Date();
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
final Date oneHourAgo = new Date(now.getTime() - 3600L);
resp1.setHeader("Cache-Control", "max-age=3600");
@@ -1684,7 +1677,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp1.setEntity(new ByteArrayEntity(bytes1));
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control", "no-cache");
req2.setHeader("Range", "bytes=0-50");
@@ -1703,7 +1696,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date inTwoSeconds = new Date(now.getTime() + 2000L);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp3 = HttpTestUtils.make200Response();
resp3.setHeader("Date", DateUtils.formatDate(inTwoSeconds));
resp3.setHeader("Cache-Control", "max-age=3600");
@@ -1773,7 +1766,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
emptyMockCacheExpectsNoPuts();
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
request.addHeader("Range", "bytes=0-50");
originResponse = Proxies.enhanceResponse(
@@ -1809,7 +1802,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void test303ResponsesAreNotCached() throws Exception {
emptyMockCacheExpectsNoPuts();
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
originResponse = Proxies.enhanceResponse(
new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_SEE_OTHER, "See Other"));
@@ -1904,12 +1897,12 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void test304ResponseGeneratedFromCacheIncludesDateHeader() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
originResponse.setHeader("Cache-Control", "max-age=3600");
originResponse.setHeader("ETag", "\"etag\"");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("If-None-Match", "\"etag\"");
EasyMock.expect(
@@ -1939,12 +1932,12 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void test304ResponseGeneratedFromCacheIncludesEtagIfOriginResponseDid() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
originResponse.setHeader("Cache-Control", "max-age=3600");
originResponse.setHeader("ETag", "\"etag\"");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("If-None-Match", "\"etag\"");
EasyMock.expect(
@@ -1968,13 +1961,13 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void test304ResponseGeneratedFromCacheIncludesContentLocationIfOriginResponseDid()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
originResponse.setHeader("Cache-Control", "max-age=3600");
originResponse.setHeader("Content-Location", "http://foo.example.com/other");
originResponse.setHeader("ETag", "\"etag\"");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("If-None-Match", "\"etag\"");
EasyMock.expect(
@@ -2009,7 +2002,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date inTwoHours = new Date(now.getTime() + 2 * 3600 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Accept-Encoding", "gzip");
final HttpResponse resp1 = HttpTestUtils.make200Response();
@@ -2020,7 +2013,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp1.setEntity(HttpTestUtils.makeBody(entityLength));
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Accept-Encoding", "gzip");
req1.setHeader("Cache-Control", "no-cache");
@@ -2032,7 +2025,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp2.setEntity(HttpTestUtils.makeBody(entityLength));
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req3.setHeader("Accept-Encoding", "gzip");
req3.setHeader("If-None-Match", "\"v2\"");
@@ -2080,7 +2073,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date oneHourAgo = new Date(now.getTime() - 3600 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("ETag", "W/\"v1\"");
@@ -2094,7 +2087,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp1.setHeader("Cache-Control", "max-age=7200");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("If-None-Match", "W/\"v1\"");
EasyMock.expect(
@@ -2136,14 +2129,14 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
// load cache with cacheable entry
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("ETag", "\"etag1\"");
resp1.setHeader("Cache-Control", "max-age=3600");
// force a revalidation
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control", "max-age=0,max-stale=0");
// updated ETag provided to a conditional revalidation
@@ -2155,12 +2148,12 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
// conditional validation uses If-None-Match
final HttpRequestWrapper conditionalValidation = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
conditionalValidation.setHeader("If-None-Match", "\"etag1\"");
// unconditional validation doesn't use If-None-Match
final HttpRequestWrapper unconditionalValidation = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
// new response to unconditional validation provides new body
final HttpResponse resp3 = HttpTestUtils.make200Response();
resp1.setHeader("ETag", "\"etag2\"");
@@ -2211,22 +2204,22 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date inFiveSeconds = new Date(now.getTime() + 5000L);
final HttpRequestWrapper initialRequest = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse cachedResponse = HttpTestUtils.make200Response();
cachedResponse.setHeader("Cache-Control", "max-age=3600");
cachedResponse.setHeader("ETag", "\"etag\"");
final HttpRequestWrapper secondRequest = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
secondRequest.setHeader("Cache-Control", "max-age=0,max-stale=0");
final HttpRequestWrapper conditionalValidationRequest = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
conditionalValidationRequest.setHeader("If-None-Match", "\"etag\"");
final HttpRequestWrapper unconditionalValidationRequest = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
// to be used if the cache generates a conditional validation
final HttpResponse conditionalResponse = new BasicHttpResponse(
@@ -2405,7 +2398,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
originResponse.setHeader("Cache-Control", "max-age=3600");
final HttpRequestWrapper rangeReq = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
rangeReq.setHeader("Range", "bytes=1000-1200");
final HttpResponse orig416 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 416,
@@ -2493,10 +2486,10 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
impl = new CachingExec(mockBackend, mockCache, config);
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1), host);
final HttpRequestWrapper validate = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1), host);
validate.setHeader("If-None-Match", "\"etag\"");
final CloseableHttpResponse notModified = Proxies.enhanceResponse(
@@ -2549,7 +2542,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, eightSecondsAgo, hdrs, bytes);
impl = new CachingExec(mockBackend, mockCache, config);
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1), host);
mockCache.flushInvalidatedCacheEntriesFor(EasyMock.eq(host), eqRequest(request));
EasyMock.expect(mockCache.getCacheEntry(EasyMock.eq(host), eqRequest(request))).andReturn(entry);
@@ -2597,7 +2590,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, eightSecondsAgo, hdrs, bytes);
impl = new CachingExec(mockBackend, mockCache, config);
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1), host);
mockCache.flushInvalidatedCacheEntriesFor(EasyMock.eq(host), eqRequest(request));
EasyMock.expect(mockCache.getCacheEntry(EasyMock.eq(host), eqRequest(request))).andReturn(entry);
@@ -2652,7 +2645,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date now = new Date();
final Date tenSecondsAgo = new Date(now.getTime() - 25 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
resp1.setHeader("ETag", "\"etag\"");
@@ -2660,10 +2653,10 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp1.setHeader("Warning", "110 squid \"stale stuff\"");
resp1.setHeader("Via", "1.1 fred");
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpRequestWrapper validate = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
validate.setHeader("If-None-Match", "\"etag\"");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED,
@@ -2682,7 +2675,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
EasyMock.isNull())).andReturn(
Proxies.enhanceResponse(resp2));
- final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
replayMocks();
@@ -2723,7 +2716,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void test2xxWarningsAreNotDeletedAfterSuccessfulRevalidation() throws Exception {
final Date now = new Date();
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
resp1.setHeader("ETag", "\"etag\"");
@@ -2731,10 +2724,10 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp1.setHeader("Via", "1.1 xproxy");
resp1.setHeader("Warning", "214 xproxy \"transformed stuff\"");
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpRequestWrapper validate = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
validate.setHeader("If-None-Match", "\"etag\"");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED,
@@ -2744,7 +2737,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp2.setHeader("ETag", "\"etag\"");
resp1.setHeader("Via", "1.1 xproxy");
- final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
backendExpectsAnyRequestAndReturn(resp1);
@@ -2816,7 +2809,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, eightSecondsAgo, hdrs, bytes);
impl = new CachingExec(mockBackend, mockCache, config);
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1), host);
mockCache.flushInvalidatedCacheEntriesFor(EasyMock.eq(host), eqRequest(request));
EasyMock.expect(mockCache.getCacheEntry(EasyMock.eq(host), eqRequest(request))).andReturn(entry);
@@ -2869,7 +2862,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
impl = new CachingExec(mockBackend, mockCache, config);
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/thing", HttpVersion.HTTP_1_1), host);
final CloseableHttpResponse validated = Proxies.enhanceResponse(HttpTestUtils.make200Response());
validated.setHeader("Cache-Control", "public");
@@ -2939,7 +2932,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
// put an entry in the cache
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(inFiveSecond));
@@ -2949,7 +2942,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
// force another origin hit
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control", "no-cache");
final HttpResponse resp2 = HttpTestUtils.make200Response();
@@ -2959,7 +2952,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp2.setHeader("Content-Length", "128");
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
EasyMock.expect(
mockBackend.execute(
@@ -3021,7 +3014,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testSubrangeGETWithWeakETagIsNotAllowed() throws Exception {
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
request.setHeader("Range", "bytes=0-500");
request.setHeader("If-Range", "W/\"etag\"");
@@ -3031,22 +3024,22 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testPUTWithIfMatchWeakETagIsNotAllowed() throws Exception {
- final HttpEntityEnclosingRequest put = new BasicHttpEntityEnclosingRequest("PUT", "/", HttpVersion.HTTP_1_1);
+ final HttpRequest put = new BasicHttpRequest("PUT", "/", HttpVersion.HTTP_1_1);
put.setEntity(HttpTestUtils.makeBody(128));
put.setHeader("Content-Length", "128");
put.setHeader("If-Match", "W/\"etag\"");
- request = HttpRequestWrapper.wrap(put);
+ request = HttpRequestWrapper.wrap(put, host);
testRequestWithWeakETagValidatorIsNotAllowed("If-Match");
}
@Test
public void testPUTWithIfNoneMatchWeakETagIsNotAllowed() throws Exception {
- final HttpEntityEnclosingRequest put = new BasicHttpEntityEnclosingRequest("PUT", "/", HttpVersion.HTTP_1_1);
+ final HttpRequest put = new BasicHttpRequest("PUT", "/", HttpVersion.HTTP_1_1);
put.setEntity(HttpTestUtils.makeBody(128));
put.setHeader("Content-Length", "128");
put.setHeader("If-None-Match", "W/\"etag\"");
- request = HttpRequestWrapper.wrap(put);
+ request = HttpRequestWrapper.wrap(put, host);
testRequestWithWeakETagValidatorIsNotAllowed("If-None-Match");
}
@@ -3054,7 +3047,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testDELETEWithIfMatchWeakETagIsNotAllowed() throws Exception {
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1), host);
request.setHeader("If-Match", "W/\"etag\"");
testRequestWithWeakETagValidatorIsNotAllowed("If-Match");
@@ -3063,7 +3056,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testDELETEWithIfNoneMatchWeakETagIsNotAllowed() throws Exception {
request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1), host);
request.setHeader("If-None-Match", "W/\"etag\"");
testRequestWithWeakETagValidatorIsNotAllowed("If-None-Match");
@@ -3080,7 +3073,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testSubrangeGETMustUseStrongComparisonForCachedResponse() throws Exception {
final Date now = new Date();
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(now));
resp1.setHeader("Cache-Control", "max-age=3600");
@@ -3092,7 +3085,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
// either get an error back or the full entity, but we better
// not get the conditionally-requested Partial Content (206).
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range", "bytes=0-50");
req2.setHeader("If-Range", "W/\"etag\"");
@@ -3126,7 +3119,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(now));
resp1.setHeader("Cache-Control", "max-age=3600");
@@ -3134,7 +3127,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp1.setHeader("ETag", "W/\"etag\"");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control", "max-age=0,max-stale=0");
final Capture cap = new Capture<>();
@@ -3208,7 +3201,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date twentySecondsAgo = new Date(now.getTime() - 20 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(now));
resp1.setHeader("Cache-Control", "max-age=3600");
@@ -3216,7 +3209,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp1.setHeader("ETag", "W/\"etag\"");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("If-None-Match", "W/\"etag\"");
req2.setHeader("If-Modified-Since", DateUtils.formatDate(twentySecondsAgo));
@@ -3244,7 +3237,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(now));
resp1.setHeader("Cache-Control", "max-age=3600");
@@ -3252,7 +3245,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
resp1.setHeader("ETag", "W/\"etag\"");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("If-None-Match", "W/\"etag\"");
req2.setHeader("If-Modified-Since", DateUtils.formatDate(tenSecondsAgo));
@@ -3286,7 +3279,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
emptyMockCacheExpectsNoPuts();
final HttpRequestWrapper req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req.setHeader("Range", "bytes=0-50");
final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, 206, "Partial Content");
@@ -3410,9 +3403,9 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
originResponse = Proxies.enhanceResponse(HttpTestUtils.make200Response());
originResponse.setHeader("Cache-Control", "max-age=3600");
@@ -3453,9 +3446,9 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
private void testDoesNotAddHeaderOnCacheHit(final String header) throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
originResponse.addHeader("Cache-Control", "max-age=3600");
originResponse.removeHeaders(header);
@@ -3491,8 +3484,8 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
}
private void testDoesNotModifyHeaderOnRequest(final String header, final String value) throws Exception {
- final BasicHttpEntityEnclosingRequest req =
- new BasicHttpEntityEnclosingRequest("POST","/",HttpVersion.HTTP_1_1);
+ final BasicHttpRequest req =
+ new BasicHttpRequest("POST","/",HttpVersion.HTTP_1_1);
req.setEntity(HttpTestUtils.makeBody(128));
req.setHeader("Content-Length","128");
req.setHeader(header,value);
@@ -3507,7 +3500,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
EasyMock.isNull())).andReturn(originResponse);
replayMocks();
- impl.execute(route, HttpRequestWrapper.wrap(req), context, null);
+ impl.execute(route, HttpRequestWrapper.wrap(req, host), context, null);
verifyMocks();
final HttpRequest captured = cap.getValue();
@@ -3538,8 +3531,8 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
}
private void testDoesNotAddHeaderToRequestIfNotPresent(final String header) throws Exception {
- final BasicHttpEntityEnclosingRequest req =
- new BasicHttpEntityEnclosingRequest("POST","/",HttpVersion.HTTP_1_1);
+ final BasicHttpRequest req =
+ new BasicHttpRequest("POST","/",HttpVersion.HTTP_1_1);
req.setEntity(HttpTestUtils.makeBody(128));
req.setHeader("Content-Length","128");
req.removeHeaders(header);
@@ -3554,7 +3547,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
EasyMock.isNull())).andReturn(originResponse);
replayMocks();
- impl.execute(route, HttpRequestWrapper.wrap(req), context, null);
+ impl.execute(route, HttpRequestWrapper.wrap(req, host), context, null);
verifyMocks();
final HttpRequest captured = cap.getValue();
@@ -3621,9 +3614,9 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testExpiresHeaderMatchesDateIfAddedToCacheHit() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
originResponse.setHeader("Cache-Control","max-age=3600");
originResponse.removeHeaders("Expires");
@@ -3684,9 +3677,9 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
private void testDoesNotModifyHeaderOnCachedResponseWithNoTransform(final String header, final String value) throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
originResponse.addHeader("Cache-Control","max-age=3600, no-transform");
originResponse.setHeader(header, value);
@@ -3714,11 +3707,11 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testDoesNotModifyContentRangeHeaderOnCachedResponseWithNoTransform() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("If-Range","\"etag\"");
req1.setHeader("Range","bytes=0-49");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("If-Range","\"etag\"");
req2.setHeader("Range","bytes=0-49");
@@ -3817,13 +3810,13 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
*/
public void testCachedEntityBodyIsUsedForResponseAfter304Validation() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","max-age=3600");
resp1.setHeader("ETag","\"etag\"");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control","max-age=0, max-stale=0");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not Modified");
@@ -3877,14 +3870,14 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testResponseIncludesCacheEntryEndToEndHeadersForResponseAfter304Validation() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","max-age=3600");
resp1.setHeader("ETag","\"etag\"");
decorateWithEndToEndHeaders(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control", "max-age=0, max-stale=0");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not Modified");
resp2.setHeader("Date", DateUtils.formatDate(new Date()));
@@ -3914,14 +3907,14 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testUpdatedEndToEndHeadersFrom304ArePassedOnResponseAndUpdatedInCacheEntry() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","max-age=3600");
resp1.setHeader("ETag","\"etag\"");
decorateWithEndToEndHeaders(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control", "max-age=0, max-stale=0");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not Modified");
resp2.setHeader("Cache-Control", "max-age=1800");
@@ -3940,7 +3933,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
replayMocks();
impl.execute(route, req1, context, null);
@@ -3968,14 +3961,14 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testMultiHeadersAreSuccessfullyReplacedOn304Validation() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.addHeader("Cache-Control","max-age=3600");
resp1.addHeader("Cache-Control","public");
resp1.setHeader("ETag","\"etag\"");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control", "max-age=0, max-stale=0");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not Modified");
resp2.setHeader("Cache-Control", "max-age=1800");
@@ -3984,7 +3977,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
replayMocks();
impl.execute(route, req1, context, null);
@@ -4023,7 +4016,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Range","bytes=0-49");
final Date now = new Date();
@@ -4041,7 +4034,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range","bytes=50-127");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4054,7 +4047,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp3 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
resp3.setEntity(HttpTestUtils.makeBody(128));
@@ -4079,7 +4072,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date twoSecondsAgo = new Date(now.getTime() - 2 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Range","bytes=0-49");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4092,7 +4085,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range","bytes=50-127");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4106,7 +4099,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp3 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
resp3.setEntity(HttpTestUtils.makeBody(128));
@@ -4131,7 +4124,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date twoSecondsAgo = new Date(now.getTime() - 2 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Range","bytes=0-49");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4145,7 +4138,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range","bytes=50-127");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4159,7 +4152,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp3 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
resp3.setEntity(HttpTestUtils.makeBody(128));
@@ -4184,7 +4177,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date twoSecondsAgo = new Date(now.getTime() - 2 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Range","bytes=0-49");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4198,7 +4191,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range","bytes=50-127");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4211,7 +4204,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req3.setHeader("Range","bytes=0-49");
final HttpResponse resp3 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -4238,7 +4231,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date twoSecondsAgo = new Date(now.getTime() - 2 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Range","bytes=0-49");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4251,7 +4244,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range","bytes=50-127");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4265,7 +4258,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req3.setHeader("Range","bytes=0-49");
final HttpResponse resp3 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -4292,7 +4285,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date twoSecondsAgo = new Date(now.getTime() - 2 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Range","bytes=0-49");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4306,7 +4299,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range","bytes=50-127");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4320,7 +4313,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req3.setHeader("Range","bytes=0-49");
final HttpResponse resp3 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -4347,7 +4340,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date twoSecondsAgo = new Date(now.getTime() - 2 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Range","bytes=0-49");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4361,7 +4354,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range","bytes=50-127");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4375,7 +4368,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req3.setHeader("Range","bytes=50-127");
final HttpResponse resp3 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -4401,7 +4394,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date oneSecondAgo = new Date(now.getTime() - 1 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Range","bytes=0-49");
final HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4415,7 +4408,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Range","bytes=50-127");
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
@@ -4429,7 +4422,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req3.setHeader("Range","bytes=0-49");
final HttpResponse resp3 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
@@ -4461,7 +4454,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Accept-Encoding","gzip");
final HttpResponse resp1 = HttpTestUtils.make200Response();
@@ -4472,7 +4465,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.removeHeaders("Accept-Encoding");
final HttpResponse resp2 = HttpTestUtils.make200Response();
@@ -4497,7 +4490,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testCannotServeFromCacheForVaryStar() throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("ETag","\"etag1\"");
@@ -4507,7 +4500,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("ETag","\"etag1\"");
@@ -4549,7 +4542,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("User-Agent","MyBrowser/1.0");
final HttpResponse resp1 = HttpTestUtils.make200Response();
@@ -4561,11 +4554,11 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("User-Agent","MyBrowser/1.5");
final HttpRequestWrapper conditional = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
conditional.setHeader("User-Agent","MyBrowser/1.5");
conditional.setHeader("If-None-Match","\"etag1\"");
@@ -4652,9 +4645,9 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.9
*/
protected void testUnsafeOperationInvalidatesCacheForThatUri(
- final HttpRequestWrapper unsafeReq) throws Exception, IOException {
+ final HttpRequestWrapper unsafeReq) throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","public, max-age=3600");
@@ -4665,7 +4658,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp3 = HttpTestUtils.make200Response();
resp3.setHeader("Cache-Control","public, max-age=3600");
@@ -4682,12 +4675,12 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testPutToUriInvalidatesCacheForThatUri() throws Exception {
final HttpRequest req = makeRequestWithBody("PUT","/");
- testUnsafeOperationInvalidatesCacheForThatUri(HttpRequestWrapper.wrap(req));
+ testUnsafeOperationInvalidatesCacheForThatUri(HttpRequestWrapper.wrap(req, host));
}
@Test
public void testDeleteToUriInvalidatesCacheForThatUri() throws Exception {
- final HttpRequestWrapper req = HttpRequestWrapper.wrap(new BasicHttpRequest("DELETE","/"));
+ final HttpRequestWrapper req = HttpRequestWrapper.wrap(new BasicHttpRequest("DELETE","/"), host);
testUnsafeOperationInvalidatesCacheForThatUri(req);
}
@@ -4698,9 +4691,9 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
}
protected void testUnsafeMethodInvalidatesCacheForHeaderUri(
- final HttpRequestWrapper unsafeReq) throws Exception, IOException {
+ final HttpRequestWrapper unsafeReq) throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/content", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/content", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","public, max-age=3600");
@@ -4711,7 +4704,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/content", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/content", HttpVersion.HTTP_1_1), host);
final HttpResponse resp3 = HttpTestUtils.make200Response();
resp3.setHeader("Cache-Control","public, max-age=3600");
@@ -4726,19 +4719,19 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
}
protected void testUnsafeMethodInvalidatesCacheForUriInContentLocationHeader(
- final HttpRequestWrapper unsafeReq) throws Exception, IOException {
+ final HttpRequestWrapper unsafeReq) throws Exception {
unsafeReq.setHeader("Content-Location","http://foo.example.com/content");
testUnsafeMethodInvalidatesCacheForHeaderUri(unsafeReq);
}
protected void testUnsafeMethodInvalidatesCacheForRelativeUriInContentLocationHeader(
- final HttpRequestWrapper unsafeReq) throws Exception, IOException {
+ final HttpRequestWrapper unsafeReq) throws Exception {
unsafeReq.setHeader("Content-Location","/content");
testUnsafeMethodInvalidatesCacheForHeaderUri(unsafeReq);
}
protected void testUnsafeMethodInvalidatesCacheForUriInLocationHeader(
- final HttpRequestWrapper unsafeReq) throws Exception, IOException {
+ final HttpRequestWrapper unsafeReq) throws Exception {
unsafeReq.setHeader("Location","http://foo.example.com/content");
testUnsafeMethodInvalidatesCacheForHeaderUri(unsafeReq);
}
@@ -4763,19 +4756,19 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testDeleteInvalidatesCacheForThatUriInContentLocationHeader() throws Exception {
- final HttpRequestWrapper req = HttpRequestWrapper.wrap(new BasicHttpRequest("DELETE", "/"));
+ final HttpRequestWrapper req = HttpRequestWrapper.wrap(new BasicHttpRequest("DELETE", "/"), host);
testUnsafeMethodInvalidatesCacheForUriInContentLocationHeader(req);
}
@Test
public void testDeleteInvalidatesCacheForThatUriInRelativeContentLocationHeader() throws Exception {
- final HttpRequestWrapper req = HttpRequestWrapper.wrap(new BasicHttpRequest("DELETE", "/"));
+ final HttpRequestWrapper req = HttpRequestWrapper.wrap(new BasicHttpRequest("DELETE", "/"), host);
testUnsafeMethodInvalidatesCacheForRelativeUriInContentLocationHeader(req);
}
@Test
public void testDeleteInvalidatesCacheForThatUriInLocationHeader() throws Exception {
- final HttpRequestWrapper req = HttpRequestWrapper.wrap(new BasicHttpRequest("DELETE", "/"));
+ final HttpRequestWrapper req = HttpRequestWrapper.wrap(new BasicHttpRequest("DELETE", "/"), host);
testUnsafeMethodInvalidatesCacheForUriInLocationHeader(req);
}
@@ -4804,12 +4797,12 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.10
*/
protected void testUnsafeMethodDoesNotInvalidateCacheForHeaderUri(
- final HttpRequestWrapper unsafeReq) throws Exception, IOException {
+ final HttpRequestWrapper unsafeReq) throws Exception {
final HttpHost otherHost = new HttpHost("bar.example.com", 80);
final HttpRoute otherRoute = new HttpRoute(otherHost);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/content", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/content", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","public, max-age=3600");
@@ -4820,7 +4813,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/content", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/content", HttpVersion.HTTP_1_1), host);
replayMocks();
impl.execute(otherRoute, req1, context, null);
@@ -4830,24 +4823,24 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
}
protected void testUnsafeMethodDoesNotInvalidateCacheForUriInContentLocationHeadersFromOtherHosts(
- final HttpRequestWrapper unsafeReq) throws Exception, IOException {
+ final HttpRequestWrapper unsafeReq) throws Exception {
unsafeReq.setHeader("Content-Location","http://bar.example.com/content");
testUnsafeMethodDoesNotInvalidateCacheForHeaderUri(unsafeReq);
}
protected void testUnsafeMethodDoesNotInvalidateCacheForUriInLocationHeadersFromOtherHosts(
- final HttpRequestWrapper unsafeReq) throws Exception, IOException {
+ final HttpRequestWrapper unsafeReq) throws Exception {
unsafeReq.setHeader("Location","http://bar.example.com/content");
testUnsafeMethodDoesNotInvalidateCacheForHeaderUri(unsafeReq);
}
protected HttpRequestWrapper makeRequestWithBody(final String method, final String requestUri) {
- final HttpEntityEnclosingRequest req =
- new BasicHttpEntityEnclosingRequest(method, requestUri, HttpVersion.HTTP_1_1);
+ final HttpRequest req =
+ new BasicHttpRequest(method, requestUri, HttpVersion.HTTP_1_1);
final int nbytes = 128;
req.setEntity(HttpTestUtils.makeBody(nbytes));
req.setHeader("Content-Length",""+nbytes);
- return HttpRequestWrapper.wrap(req);
+ return HttpRequestWrapper.wrap(req, host);
}
@Test
@@ -4877,14 +4870,14 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testDeleteDoesNotInvalidateCacheForUriInContentLocationHeadersFromOtherHosts() throws Exception {
final HttpRequestWrapper req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1), host);
testUnsafeMethodDoesNotInvalidateCacheForUriInContentLocationHeadersFromOtherHosts(req);
}
@Test
public void testDeleteDoesNotInvalidateCacheForUriInLocationHeadersFromOtherHosts() throws Exception {
final HttpRequestWrapper req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1), host);
testUnsafeMethodDoesNotInvalidateCacheForUriInLocationHeadersFromOtherHosts(req);
}
@@ -4900,7 +4893,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
private void testRequestIsWrittenThroughToOrigin(final HttpRequest req)
throws Exception {
final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NO_CONTENT, "No Content");
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req, host);
EasyMock.expect(
mockBackend.execute(
EasyMock.eq(route),
@@ -4918,14 +4911,14 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testOPTIONSRequestsAreWrittenThroughToOrigin()
throws Exception {
final HttpRequest req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("OPTIONS","*",HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("OPTIONS","*",HttpVersion.HTTP_1_1), host);
testRequestIsWrittenThroughToOrigin(req);
}
@Test
public void testPOSTRequestsAreWrittenThroughToOrigin()
throws Exception {
- final HttpEntityEnclosingRequest req = new BasicHttpEntityEnclosingRequest("POST","/",HttpVersion.HTTP_1_1);
+ final HttpRequest req = new BasicHttpRequest("POST","/",HttpVersion.HTTP_1_1);
req.setEntity(HttpTestUtils.makeBody(128));
req.setHeader("Content-Length","128");
testRequestIsWrittenThroughToOrigin(req);
@@ -4934,7 +4927,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testPUTRequestsAreWrittenThroughToOrigin()
throws Exception {
- final HttpEntityEnclosingRequest req = new BasicHttpEntityEnclosingRequest("PUT","/",HttpVersion.HTTP_1_1);
+ final HttpRequest req = new BasicHttpRequest("PUT","/",HttpVersion.HTTP_1_1);
req.setEntity(HttpTestUtils.makeBody(128));
req.setHeader("Content-Length","128");
testRequestIsWrittenThroughToOrigin(req);
@@ -4944,7 +4937,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testDELETERequestsAreWrittenThroughToOrigin()
throws Exception {
final HttpRequest req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("DELETE", "/", HttpVersion.HTTP_1_1), host);
testRequestIsWrittenThroughToOrigin(req);
}
@@ -4952,7 +4945,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testTRACERequestsAreWrittenThroughToOrigin()
throws Exception {
final HttpRequest req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("TRACE","/",HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("TRACE","/",HttpVersion.HTTP_1_1), host);
testRequestIsWrittenThroughToOrigin(req);
}
@@ -4960,7 +4953,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testCONNECTRequestsAreWrittenThroughToOrigin()
throws Exception {
final HttpRequest req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("CONNECT","/",HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("CONNECT","/",HttpVersion.HTTP_1_1), host);
testRequestIsWrittenThroughToOrigin(req);
}
@@ -4968,7 +4961,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testUnknownMethodRequestsAreWrittenThroughToOrigin()
throws Exception {
final HttpRequest req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("UNKNOWN","/",HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("UNKNOWN","/",HttpVersion.HTTP_1_1), host);
testRequestIsWrittenThroughToOrigin(req);
}
@@ -5040,18 +5033,17 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
* it MAY be returned in reply to any subsequent request.
*/
protected void testSharedCacheRevalidatesAuthorizedResponse(
- final HttpResponse authorizedResponse, final int minTimes, final int maxTimes) throws Exception,
- IOException {
+ final HttpResponse authorizedResponse, final int minTimes, final int maxTimes) throws Exception {
if (config.isSharedCache()) {
final String authorization = "Basic dXNlcjpwYXNzd2Q=";
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Authorization",authorization);
backendExpectsAnyRequestAndReturn(authorizedResponse);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("Cache-Control","max-age=3600");
@@ -5113,20 +5105,19 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
}
protected void testSharedCacheMustUseNewRequestHeadersWhenRevalidatingAuthorizedResponse(
- final HttpResponse authorizedResponse) throws Exception, IOException,
- ClientProtocolException {
+ final HttpResponse authorizedResponse) throws Exception {
if (config.isSharedCache()) {
final String authorization1 = "Basic dXNlcjpwYXNzd2Q=";
final String authorization2 = "Basic dXNlcjpwYXNzd2Qy";
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req1.setHeader("Authorization",authorization1);
backendExpectsAnyRequestAndReturn(authorizedResponse);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Authorization",authorization2);
final HttpResponse resp2 = HttpTestUtils.make200Response();
@@ -5196,7 +5187,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
final Date now = new Date();
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
resp1.setHeader("Cache-Control","max-age=5");
@@ -5205,7 +5196,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control","max-stale=60");
final HttpResponse resp2 = HttpTestUtils.make200Response();
@@ -5282,7 +5273,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
protected void testCacheIsNotUsedWhenRespondingToRequest(final HttpRequestWrapper req)
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Etag","\"etag\"");
resp1.setHeader("Cache-Control","max-age=3600");
@@ -5315,7 +5306,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testCacheIsNotUsedWhenRespondingToRequestWithCacheControlNoCache()
throws Exception {
final HttpRequestWrapper req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req.setHeader("Cache-Control","no-cache");
testCacheIsNotUsedWhenRespondingToRequest(req);
}
@@ -5324,7 +5315,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testCacheIsNotUsedWhenRespondingToRequestWithPragmaNoCache()
throws Exception {
final HttpRequestWrapper req = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req.setHeader("Pragma","no-cache");
testCacheIsNotUsedWhenRespondingToRequest(req);
}
@@ -5341,12 +5332,12 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
protected void testStaleCacheResponseMustBeRevalidatedWithOrigin(
final HttpResponse staleResponse) throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
backendExpectsAnyRequestAndReturn(staleResponse);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control","max-stale=3600");
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("ETag","\"etag2\"");
@@ -5401,12 +5392,12 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
protected void testGenerates504IfCannotRevalidateStaleResponse(
final HttpResponse staleResponse) throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
backendExpectsAnyRequestAndReturn(staleResponse);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
backendExpectsAnyRequest().andThrow(new SocketTimeoutException());
@@ -5479,14 +5470,14 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
throws Exception {
if (config.isSharedCache()) {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","private,max-age=3600");
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
// this backend request MUST happen
backendExpectsAnyRequestAndReturn(resp2);
@@ -5503,7 +5494,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
throws Exception {
if (config.isSharedCache()) {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("X-Personal","stuff");
resp1.setHeader("Cache-Control","private=\"X-Personal\",s-maxage=3600");
@@ -5511,7 +5502,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
// this backend request MAY happen
@@ -5537,7 +5528,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testNoCacheCannotSatisfyASubsequentRequestWithoutRevalidation()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("ETag","\"etag\"");
resp1.setHeader("Cache-Control","no-cache");
@@ -5545,7 +5536,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
// this MUST happen
@@ -5561,7 +5552,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testNoCacheCannotSatisfyASubsequentRequestWithoutRevalidationEvenWithContraryIndications()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("ETag","\"etag\"");
resp1.setHeader("Cache-Control","no-cache,s-maxage=3600");
@@ -5569,7 +5560,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control","max-stale=7200");
final HttpResponse resp2 = HttpTestUtils.make200Response();
@@ -5592,7 +5583,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testNoCacheOnFieldIsNotReturnedWithoutRevalidation()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("ETag","\"etag\"");
resp1.setHeader("X-Stuff","things");
@@ -5601,7 +5592,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("ETag","\"etag\"");
resp2.setHeader("X-Stuff","things");
@@ -5762,14 +5753,14 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testCacheDoesNotAssumeContentLocationHeaderIndicatesAnotherCacheableResource()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","public,max-age=3600");
resp1.setHeader("Etag","\"etag\"");
resp1.setHeader("Content-Location","http://foo.example.com/bar");
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/bar", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/bar", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("Cache-Control","public,max-age=3600");
resp2.setHeader("Etag","\"etag\"");
@@ -5814,14 +5805,14 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
private void testInvalidExpiresHeaderIsTreatedAsStale(
final String expiresHeader) throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","public");
resp1.setHeader("ETag","\"etag\"");
resp1.setHeader("Expires", expiresHeader);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
backendExpectsAnyRequestAndReturn(resp1);
@@ -5855,14 +5846,14 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testExpiresHeaderEqualToDateHeaderIsTreatedAsStale()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control","public");
resp1.setHeader("ETag","\"etag\"");
resp1.setHeader("Expires", resp1.getFirstHeader("Date").getValue());
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
backendExpectsAnyRequestAndReturn(resp1);
@@ -6095,7 +6086,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
@Test
public void testViaHeaderOnRequestProperlyRecordsClientProtocol()
throws Exception {
- request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_0));
+ request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_0), host);
request.removeHeaders("Via");
final Capture cap = new Capture<>();
EasyMock.expect(
@@ -6174,9 +6165,9 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
public void testUpdatesWarningHeadersOnValidation()
throws Exception {
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final Date now = new Date();
final Date twentySecondsAgo = new Date(now.getTime() - 20 * 1000L);
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java
index c69e6bfde..0e7b30646 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java
@@ -33,15 +33,15 @@ import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.util.Date;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.message.BasicHttpRequest;
import org.junit.Test;
/**
@@ -70,13 +70,13 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
public void testStaleIfErrorInResponseIsTrueReturnsStaleEntryWithWarning()
throws Exception{
final Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
"public, max-age=5, stale-if-error=60");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp2 = HttpTestUtils.make500Response();
backendExpectsAnyRequestAndReturn(resp2);
@@ -93,13 +93,13 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
public void testConsumesErrorResponseWhenServingStale()
throws Exception{
final Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
"public, max-age=5, stale-if-error=60");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp2 = HttpTestUtils.make500Response();
final byte[] body101 = HttpTestUtils.getRandomBytes(101);
final ByteArrayInputStream buf = new ByteArrayInputStream(body101);
@@ -121,13 +121,13 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
public void testStaleIfErrorInResponseYieldsToMustRevalidate()
throws Exception{
final Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
"public, max-age=5, stale-if-error=60, must-revalidate");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp2 = HttpTestUtils.make500Response();
backendExpectsAnyRequestAndReturn(resp2);
@@ -145,13 +145,13 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
throws Exception{
assertTrue(config.isSharedCache());
final Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
"public, max-age=5, stale-if-error=60, proxy-revalidate");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp2 = HttpTestUtils.make500Response();
backendExpectsAnyRequestAndReturn(resp2);
@@ -172,13 +172,13 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
impl = new CachingExec(mockBackend, new BasicHttpCache(configUnshared), configUnshared);
final Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
"public, max-age=5, stale-if-error=60, proxy-revalidate");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp2 = HttpTestUtils.make500Response();
backendExpectsAnyRequestAndReturn(resp2);
@@ -195,13 +195,13 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
public void testStaleIfErrorInResponseYieldsToExplicitFreshnessRequest()
throws Exception{
final Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
"public, max-age=5, stale-if-error=60");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control","min-fresh=2");
final HttpResponse resp2 = HttpTestUtils.make500Response();
@@ -219,13 +219,13 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
public void testStaleIfErrorInRequestIsTrueReturnsStaleEntryWithWarning()
throws Exception{
final Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
"public, max-age=5");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control","public, stale-if-error=60");
final HttpResponse resp2 = HttpTestUtils.make500Response();
@@ -243,14 +243,14 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
public void testStaleIfErrorInRequestIsTrueReturnsStaleNonRevalidatableEntryWithWarning()
throws Exception {
final Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
resp1.setHeader("Cache-Control", "public, max-age=5");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control", "public, stale-if-error=60");
final HttpResponse resp2 = HttpTestUtils.make500Response();
@@ -269,13 +269,13 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
throws Exception{
final Date now = new Date();
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
"public, max-age=5, stale-if-error=2");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp2 = HttpTestUtils.make500Response();
backendExpectsAnyRequestAndReturn(resp2);
@@ -294,13 +294,13 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
throws Exception{
final Date now = new Date();
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
- final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
final HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
"public, max-age=5");
backendExpectsAnyRequestAndReturn(resp1);
- final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
+ final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
req2.setHeader("Cache-Control","stale-if-error=2");
final HttpResponse resp2 = HttpTestUtils.make500Response();
@@ -335,7 +335,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
impl = new CachingExec(mockBackend, cache, config, new AsynchronousValidator(config));
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
final Date now = new Date();
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
@@ -346,7 +346,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1).times(1,2);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
replayMocks();
impl.execute(route, req1, context, null);
@@ -380,7 +380,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
impl = new CachingExec(mockBackend, cache, config, new AsynchronousValidator(config));
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/",
- HttpVersion.HTTP_1_1));
+ HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
final Date now = new Date();
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
@@ -390,7 +390,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1).times(1, 2);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/",
- HttpVersion.HTTP_1_1));
+ HttpVersion.HTTP_1_1), host);
replayMocks();
impl.execute(route, req1, context, null);
@@ -423,7 +423,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
impl = new CachingExec(mockBackend, cache, config, new AsynchronousValidator(config));
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
final Date now = new Date();
final Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
@@ -434,7 +434,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1).times(1,2);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("If-None-Match","\"etag\"");
replayMocks();
@@ -471,7 +471,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
impl = new CachingExec(mockBackend, cache, config);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15, must-revalidate");
resp1.setHeader("ETag","\"etag\"");
@@ -480,7 +480,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15, must-revalidate");
resp2.setHeader("ETag","\"etag\"");
@@ -522,7 +522,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
impl = new CachingExec(mockBackend, cache, config);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15, proxy-revalidate");
resp1.setHeader("ETag","\"etag\"");
@@ -531,7 +531,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15, proxy-revalidate");
resp2.setHeader("ETag","\"etag\"");
@@ -573,7 +573,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
impl = new CachingExec(mockBackend, cache, config);
final HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
final HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15");
resp1.setHeader("ETag","\"etag\"");
@@ -582,7 +582,7 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
+ new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1), host);
req2.setHeader("Cache-Control","min-fresh=2");
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15");
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRequestProtocolCompliance.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRequestProtocolCompliance.java
index e2ace0640..02472b055 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRequestProtocolCompliance.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRequestProtocolCompliance.java
@@ -32,24 +32,25 @@ import static org.junit.Assert.assertTrue;
import java.util.Arrays;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolVersion;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestWrapper;
-import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.apache.http.message.BasicHttpRequest;
import org.junit.Before;
import org.junit.Test;
public class TestRequestProtocolCompliance {
+ private HttpHost host;
private RequestProtocolCompliance impl;
private HttpRequest req;
@Before
public void setUp() {
+ host = new HttpHost("foo.example.com", 80);
req = HttpTestUtils.makeDefaultRequest();
impl = new RequestProtocolCompliance(false);
}
@@ -84,27 +85,25 @@ public class TestRequestProtocolCompliance {
@Test
public void doesNotModifyACompliantRequest() throws Exception {
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req, host);
impl.makeRequestCompliant(wrapper);
assertTrue(HttpTestUtils.equivalent(req, wrapper));
}
@Test
public void removesEntityFromTRACERequest() throws Exception {
- final HttpEntityEnclosingRequest reqst =
- new BasicHttpEntityEnclosingRequest("TRACE", "/", HttpVersion.HTTP_1_1);
- reqst.setEntity(HttpTestUtils.makeBody(50));
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(reqst);
+ final HttpRequest request =
+ new BasicHttpRequest("TRACE", "/", HttpVersion.HTTP_1_1);
+ request.setEntity(HttpTestUtils.makeBody(50));
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(request, host);
impl.makeRequestCompliant(wrapper);
- if (wrapper instanceof HttpEntityEnclosingRequest) {
- assertNull(((HttpEntityEnclosingRequest) wrapper).getEntity());
- }
+ assertNull(wrapper.getEntity());
}
@Test
public void upgrades1_0RequestTo1_1() throws Exception {
req = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_0);
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req, host);
impl.makeRequestCompliant(wrapper);
assertEquals(HttpVersion.HTTP_1_1, wrapper.getProtocolVersion());
}
@@ -113,7 +112,7 @@ public class TestRequestProtocolCompliance {
public void downgrades1_2RequestTo1_1() throws Exception {
final ProtocolVersion HTTP_1_2 = new ProtocolVersion("HTTP", 1, 2);
req = new BasicHttpRequest("GET", "/", HTTP_1_2);
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req, host);
impl.makeRequestCompliant(wrapper);
assertEquals(HttpVersion.HTTP_1_1, wrapper.getProtocolVersion());
}
@@ -122,7 +121,7 @@ public class TestRequestProtocolCompliance {
public void stripsMinFreshFromRequestIfNoCachePresent()
throws Exception {
req.setHeader("Cache-Control", "no-cache, min-fresh=10");
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req, host);
impl.makeRequestCompliant(wrapper);
assertEquals("no-cache",
wrapper.getFirstHeader("Cache-Control").getValue());
@@ -132,7 +131,7 @@ public class TestRequestProtocolCompliance {
public void stripsMaxFreshFromRequestIfNoCachePresent()
throws Exception {
req.setHeader("Cache-Control", "no-cache, max-stale=10");
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req, host);
impl.makeRequestCompliant(wrapper);
assertEquals("no-cache",
wrapper.getFirstHeader("Cache-Control").getValue());
@@ -142,7 +141,7 @@ public class TestRequestProtocolCompliance {
public void stripsMaxAgeFromRequestIfNoCachePresent()
throws Exception {
req.setHeader("Cache-Control", "no-cache, max-age=10");
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req, host);
impl.makeRequestCompliant(wrapper);
assertEquals("no-cache",
wrapper.getFirstHeader("Cache-Control").getValue());
@@ -152,7 +151,7 @@ public class TestRequestProtocolCompliance {
public void doesNotStripMinFreshFromRequestWithoutNoCache()
throws Exception {
req.setHeader("Cache-Control", "min-fresh=10");
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req, host);
impl.makeRequestCompliant(wrapper);
assertEquals("min-fresh=10",
wrapper.getFirstHeader("Cache-Control").getValue());
@@ -162,7 +161,7 @@ public class TestRequestProtocolCompliance {
public void correctlyStripsMinFreshFromMiddleIfNoCache()
throws Exception {
req.setHeader("Cache-Control", "no-cache,min-fresh=10,no-store");
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req, host);
impl.makeRequestCompliant(wrapper);
assertEquals("no-cache,no-store",
wrapper.getFirstHeader("Cache-Control").getValue());
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestResponseCachingPolicy.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestResponseCachingPolicy.java
index 8bab0a5f0..4fb1bf01a 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestResponseCachingPolicy.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestResponseCachingPolicy.java
@@ -29,16 +29,16 @@ package org.apache.http.impl.client.cache;
import java.util.Date;
import java.util.Random;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolVersion;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.message.BasicStatusLine;
import org.apache.http.client.methods.HttpOptions;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.message.BasicStatusLine;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestResponseProtocolCompliance.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestResponseProtocolCompliance.java
index 6460e85e8..8ec4b879a 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestResponseProtocolCompliance.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestResponseProtocolCompliance.java
@@ -32,29 +32,32 @@ import static junit.framework.TestCase.assertTrue;
import java.io.ByteArrayInputStream;
import java.util.Date;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.apache.http.message.BasicHttpResponse;
import org.junit.Before;
import org.junit.Test;
public class TestResponseProtocolCompliance {
+ private HttpHost host;
private ResponseProtocolCompliance impl;
@Before
public void setUp() {
+ host = new HttpHost("foo.example.com", 80);
impl = new ResponseProtocolCompliance();
}
@@ -88,7 +91,7 @@ public class TestResponseProtocolCompliance {
@Test
public void consumesBodyIfOriginSendsOneInResponseToHEAD() throws Exception {
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(new HttpHead("http://foo.example.com/"));
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(new HttpHead("http://foo.example.com/"), host);
final int nbytes = 128;
final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
setMinimalResponseHeaders(resp);
@@ -105,7 +108,7 @@ public class TestResponseProtocolCompliance {
@Test(expected=ClientProtocolException.class)
public void throwsExceptionIfOriginReturnsPartialResponseWhenNotRequested() throws Exception {
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"), host);
final int nbytes = 128;
final HttpResponse resp = makePartialResponse(nbytes);
resp.setEntity(HttpTestUtils.makeBody(nbytes));
@@ -115,7 +118,7 @@ public class TestResponseProtocolCompliance {
@Test
public void consumesPartialContentFromOriginEvenIfNotRequested() throws Exception {
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"), host);
final int nbytes = 128;
final HttpResponse resp = makePartialResponse(nbytes);
@@ -132,13 +135,13 @@ public class TestResponseProtocolCompliance {
@Test
public void consumesBodyOf100ContinueResponseIfItArrives() throws Exception {
- final HttpEntityEnclosingRequest req = new BasicHttpEntityEnclosingRequest("POST", "/", HttpVersion.HTTP_1_1);
+ final HttpRequest req = new BasicHttpRequest("POST", "/", HttpVersion.HTTP_1_1);
final int nbytes = 128;
req.setHeader("Content-Length","" + nbytes);
req.setHeader("Content-Type", "application/octet-stream");
final HttpEntity postBody = new ByteArrayEntity(HttpTestUtils.getRandomBytes(nbytes));
req.setEntity(postBody);
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req, host);
final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_CONTINUE, "Continue");
final Flag closed = new Flag();
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestSizeLimitedResponseReader.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestSizeLimitedResponseReader.java
index 1560767eb..db8c09525 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestSizeLimitedResponseReader.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestSizeLimitedResponseReader.java
@@ -30,17 +30,17 @@ import java.io.IOException;
import java.lang.reflect.Proxy;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java
index b91feb44c..0895fcec3 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java
@@ -30,30 +30,30 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Locale;
-import org.apache.http.Consts;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.MethodNotSupportedException;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.MethodNotSupportedException;
+import org.apache.hc.core5.http.bootstrap.io.HttpServer;
+import org.apache.hc.core5.http.bootstrap.io.ServerBootstrap;
+import org.apache.hc.core5.http.config.SocketConfig;
+import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.cache.CacheResponseStatus;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.config.SocketConfig;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -253,7 +253,7 @@ public class TestStaleWhileRevalidationReleasesConnection {
* @param response the response
* @param context the context
*
- * @throws org.apache.http.HttpException in case of a problem
+ * @throws org.apache.hc.core5.http.HttpException in case of a problem
* @throws java.io.IOException in case of an IO problem
*/
@Override
@@ -271,7 +271,7 @@ public class TestStaleWhileRevalidationReleasesConnection {
(method + " not supported by " + getClass().getName());
}
- response.setStatusCode(org.apache.http.HttpStatus.SC_OK);
+ response.setStatusCode(org.apache.hc.core5.http.HttpStatus.SC_OK);
response.addHeader("Cache-Control",getCacheContent(request));
final byte[] content = getHeaderContent(request);
final ByteArrayEntity bae = new ByteArrayEntity(content);
@@ -285,7 +285,7 @@ public class TestStaleWhileRevalidationReleasesConnection {
public byte[] getHeaderContent(final HttpRequest request) {
final Header contentHeader = request.getFirstHeader(DEFAULT_CLIENT_CONTROLLED_CONTENT_HEADER);
if(contentHeader!=null) {
- return contentHeader.getValue().getBytes(Consts.UTF_8);
+ return contentHeader.getValue().getBytes(StandardCharsets.UTF_8);
} else {
return DEFAULT_CONTENT;
}
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestWarningValue.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestWarningValue.java
index d0f99aa44..ee9eca20c 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestWarningValue.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestWarningValue.java
@@ -28,9 +28,9 @@ package org.apache.http.impl.client.cache;
import java.util.Date;
-import org.apache.http.Header;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHeader;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java
index 05187ca2b..37f596f4e 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheHttpCacheStorage.java
@@ -37,10 +37,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import junit.framework.TestCase;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheEntrySerializer;
import org.apache.http.client.cache.HttpCacheUpdateCallback;
@@ -49,6 +45,10 @@ import org.apache.http.impl.client.cache.CacheConfig;
import org.apache.http.impl.client.cache.HttpTestUtils;
import org.junit.Test;
+import junit.framework.TestCase;
+import net.sf.ehcache.Ehcache;
+import net.sf.ehcache.Element;
+
@SuppressWarnings("boxing") // test code
public class TestEhcacheHttpCacheStorage extends TestCase {
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java
index ddda48e45..e9ccbeb12 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java
@@ -26,11 +26,6 @@
*/
package org.apache.http.impl.client.cache.ehcache;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.config.CacheConfiguration;
-import net.sf.ehcache.config.Configuration;
-import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
-
import org.apache.http.client.cache.HttpCacheStorage;
import org.apache.http.impl.client.cache.CacheConfig;
import org.apache.http.impl.client.cache.CachingExec;
@@ -43,6 +38,11 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.config.CacheConfiguration;
+import net.sf.ehcache.config.Configuration;
+import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
+
public class TestEhcacheProtocolRequirements extends TestProtocolRequirements{
protected final String TEST_EHCACHE_NAME = "TestEhcacheProtocolRequirements-cache";
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java
index a5ac52e14..c5cd48186 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java
@@ -34,13 +34,6 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-import junit.framework.TestCase;
-import net.spy.memcached.CASResponse;
-import net.spy.memcached.CASValue;
-import net.spy.memcached.MemcachedClientIF;
-import net.spy.memcached.OperationTimeoutException;
import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheUpdateCallback;
@@ -50,6 +43,12 @@ import org.apache.http.impl.client.cache.HttpTestUtils;
import org.junit.Before;
import org.junit.Test;
+import junit.framework.TestCase;
+import net.spy.memcached.CASResponse;
+import net.spy.memcached.CASValue;
+import net.spy.memcached.MemcachedClientIF;
+import net.spy.memcached.OperationTimeoutException;
+
public class TestMemcachedHttpCacheStorage extends TestCase {
private MemcachedHttpCacheStorage impl;
private MemcachedClientIF mockMemcachedClient;
@@ -168,7 +167,7 @@ public class TestMemcachedHttpCacheStorage extends TestCase {
}
@Test
- public void testSuccessfulCacheGet() throws UnsupportedEncodingException,
+ public void testSuccessfulCacheGet() throws
IOException {
final String url = "foo";
final String key = "key";
@@ -195,7 +194,7 @@ public class TestMemcachedHttpCacheStorage extends TestCase {
}
@Test
- public void testTreatsNoneByteArrayFromMemcachedAsCacheMiss() throws UnsupportedEncodingException,
+ public void testTreatsNoneByteArrayFromMemcachedAsCacheMiss() throws
IOException {
final String url = "foo";
final String key = "key";
@@ -212,7 +211,7 @@ public class TestMemcachedHttpCacheStorage extends TestCase {
}
@Test
- public void testTreatsNullFromMemcachedAsCacheMiss() throws UnsupportedEncodingException,
+ public void testTreatsNullFromMemcachedAsCacheMiss() throws
IOException {
final String url = "foo";
final String key = "key";
@@ -229,7 +228,7 @@ public class TestMemcachedHttpCacheStorage extends TestCase {
}
@Test
- public void testTreatsAsCacheMissIfCannotReconstituteEntry() throws UnsupportedEncodingException,
+ public void testTreatsAsCacheMissIfCannotReconstituteEntry() throws
IOException {
final String url = "foo";
final String key = "key";
@@ -250,7 +249,7 @@ public class TestMemcachedHttpCacheStorage extends TestCase {
}
@Test
- public void testTreatsAsCacheMissIfCantHashStorageKey() throws UnsupportedEncodingException,
+ public void testTreatsAsCacheMissIfCantHashStorageKey() throws
IOException {
final String url = "foo";
diff --git a/httpclient-osgi/pom.xml b/httpclient-osgi/pom.xml
index 01ec27295..488181bb0 100644
--- a/httpclient-osgi/pom.xml
+++ b/httpclient-osgi/pom.xml
@@ -56,8 +56,8 @@
- org.apache.httpcomponents
- httpcore-osgi
+ org.apache.httpcomponents.core5
+ httpcore5-osgi
${httpcore.version}
diff --git a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiHttpRoutePlanner.java b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiHttpRoutePlanner.java
index 9b00b1594..388032c74 100644
--- a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiHttpRoutePlanner.java
+++ b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/OSGiHttpRoutePlanner.java
@@ -31,12 +31,12 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.impl.conn.DefaultRoutePlanner;
import org.apache.http.osgi.services.ProxyConfiguration;
-import org.apache.http.protocol.HttpContext;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
@@ -108,7 +108,7 @@ final class OSGiHttpRoutePlanner extends DefaultRoutePlanner {
return new HostNameMatcher(name);
}
- private static interface HostMatcher {
+ private interface HostMatcher {
boolean matches(String host);
diff --git a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/PropertiesUtils.java b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/PropertiesUtils.java
index b5e4a2dd7..e8235ad6d 100644
--- a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/PropertiesUtils.java
+++ b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/PropertiesUtils.java
@@ -111,7 +111,7 @@ final class PropertiesUtils {
// do nothing
}
- private static interface PropertyConverter {
+ private interface PropertyConverter {
T to(Object propValue);
diff --git a/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java b/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java
index 2f27829cf..60a5d9bd8 100644
--- a/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java
+++ b/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java
@@ -27,9 +27,20 @@
package org.apache.http.osgi.impl;
-import org.apache.http.HttpEntity;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.ContentType;
import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.ByteArrayBody;
import org.apache.http.entity.mime.content.StringBody;
@@ -41,17 +52,6 @@ import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-
/**
* pax-exam test for the OSGi packaging of the client.
*/
@@ -64,7 +64,7 @@ public class MimeExportedIT {
final String projectBuildDirectory = System.getProperty("project.build.directory", "target");
final String projectVersion = System.getProperty("project.version");
- final List bundleUrls = new ArrayList();
+ final List bundleUrls = new ArrayList<>();
final File bundleDir = new File(projectBuildDirectory, "bundles");
final File[] bundleFiles = bundleDir.listFiles(new FilenameFilter() {
@Override
diff --git a/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/OSGiProxyConfigurationTest.java b/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/OSGiProxyConfigurationTest.java
index 2fd901e5d..727a3ea5b 100644
--- a/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/OSGiProxyConfigurationTest.java
+++ b/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/OSGiProxyConfigurationTest.java
@@ -26,13 +26,13 @@
*/
package org.apache.http.osgi.impl;
-import org.junit.Test;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
import java.util.Dictionary;
import java.util.Hashtable;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertThat;
+import org.junit.Test;
public class OSGiProxyConfigurationTest {
diff --git a/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/TestOSGiHttpRoutePlanner.java b/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/TestOSGiHttpRoutePlanner.java
index 9cd0bf6fd..e5421f6ef 100644
--- a/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/TestOSGiHttpRoutePlanner.java
+++ b/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/TestOSGiHttpRoutePlanner.java
@@ -36,7 +36,7 @@ import java.net.InetAddress;
import java.util.Map;
import java.util.TreeMap;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.apache.http.osgi.services.ProxyConfiguration;
import org.junit.Test;
import org.osgi.framework.BundleContext;
@@ -120,7 +120,7 @@ public class TestOSGiHttpRoutePlanner {
final BundleContext bc = mock(BundleContext.class);
when(bc.getService(sRef1)).thenReturn(this.pc1);
- final Map registrations = new TreeMap(); // TreeMap for order
+ final Map registrations = new TreeMap<>(); // TreeMap for order
registrations.put("foo1", sReg1);
OSGiHttpRoutePlanner planner = new OSGiHttpRoutePlanner(bc, registrations);
@@ -176,7 +176,7 @@ public class TestOSGiHttpRoutePlanner {
when(sReg2.getReference()).thenReturn(sRef2);
final BundleContext bc = mock(BundleContext.class);
when(bc.getService(sRef2)).thenReturn(this.pc2);
- final Map registrations = new TreeMap();
+ final Map registrations = new TreeMap<>();
registrations.put("foo2", sReg2);
final OSGiHttpRoutePlanner planner = new OSGiHttpRoutePlanner(bc, registrations);
diff --git a/httpclient-win/src/examples/org/apache/http/examples/client/win/ClientWinAuth.java b/httpclient-win/src/examples/org/apache/http/examples/client/win/ClientWinAuth.java
index 97e3db749..7e9f43f21 100644
--- a/httpclient-win/src/examples/org/apache/http/examples/client/win/ClientWinAuth.java
+++ b/httpclient-win/src/examples/org/apache/http/examples/client/win/ClientWinAuth.java
@@ -27,11 +27,11 @@
package org.apache.http.examples.client.win;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.WinHttpClients;
-import org.apache.http.util.EntityUtils;
/**
* This example demonstrates how to create HttpClient pre-configured
diff --git a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java
index 94f715a50..d49d6405f 100644
--- a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java
+++ b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNTLMSchemeFactory.java
@@ -27,11 +27,11 @@
package org.apache.http.impl.auth.win;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.client.config.AuthSchemes;
-import org.apache.http.protocol.HttpContext;
/**
* {@link AuthSchemeProvider} implementation that creates and initializes
@@ -45,7 +45,7 @@ import org.apache.http.protocol.HttpContext;
@Immutable
public class WindowsNTLMSchemeFactory implements AuthSchemeProvider {
- private String servicePrincipalName;
+ private final String servicePrincipalName;
public WindowsNTLMSchemeFactory(final String servicePrincipalName) {
super();
diff --git a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java
index 9246f706a..0b4bb067c 100644
--- a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java
+++ b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java
@@ -31,9 +31,11 @@ import java.security.Principal;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthenticationException;
@@ -43,8 +45,6 @@ import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.RouteInfo;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
import com.sun.jna.platform.win32.Secur32;
import com.sun.jna.platform.win32.Secur32Util;
diff --git a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java
index b1e3e5743..539474837 100644
--- a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java
+++ b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateSchemeFactory.java
@@ -27,11 +27,11 @@
package org.apache.http.impl.auth.win;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.client.config.AuthSchemes;
-import org.apache.http.protocol.HttpContext;
/**
* {@link AuthSchemeProvider} implementation that creates and initializes
@@ -45,7 +45,7 @@ import org.apache.http.protocol.HttpContext;
@Immutable
public class WindowsNegotiateSchemeFactory implements AuthSchemeProvider {
- private String servicePrincipalName;
+ private final String servicePrincipalName;
public WindowsNegotiateSchemeFactory(final String servicePrincipalName) {
super();
diff --git a/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java b/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java
index 984c1bc85..1c25b46c0 100644
--- a/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java
+++ b/httpclient-win/src/main/java/org/apache/http/impl/client/WinHttpClients.java
@@ -28,10 +28,10 @@ package org.apache.http.impl.client;
import java.util.Locale;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.client.config.AuthSchemes;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
import org.apache.http.impl.auth.BasicSchemeFactory;
import org.apache.http.impl.auth.DigestSchemeFactory;
import org.apache.http.impl.auth.win.WindowsNTLMSchemeFactory;
diff --git a/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java b/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java
index e90fa34d6..87719de06 100644
--- a/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java
+++ b/httpclient-win/src/test/java/org/apache/http/impl/auth/win/TestWindowsNegotiateScheme.java
@@ -28,26 +28,26 @@ package org.apache.http.impl.auth.win;
import java.io.IOException;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.WinHttpClients;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
diff --git a/httpclient/pom.xml b/httpclient/pom.xml
index 99fc7a11c..4440ffb83 100644
--- a/httpclient/pom.xml
+++ b/httpclient/pom.xml
@@ -40,8 +40,8 @@
- org.apache.httpcomponents
- httpcore
+ org.apache.httpcomponents.core5
+ httpcore5
compile
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java b/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java
index 401ec197b..7eb3539e0 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java
@@ -26,6 +26,7 @@
*/
package org.apache.http.examples.client;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -33,7 +34,6 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
/**
* A simple example that uses HttpClient to execute an HTTP request against
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java b/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java
index 0c40e509e..11c072e7d 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientChunkEncodedPost.java
@@ -29,13 +29,13 @@ package org.apache.http.examples.client;
import java.io.File;
import java.io.FileInputStream;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.InputStreamEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.InputStreamEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
/**
* Example how to use unbuffered chunk-encoded POST request.
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java b/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
index d820dd6f1..585d48893 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
@@ -30,17 +30,33 @@ package org.apache.http.examples.client;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.charset.CodingErrorAction;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import javax.net.ssl.SSLContext;
-import org.apache.http.Consts;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.ParseException;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.MessageConstraints;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.config.SocketConfig;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.impl.DefaultHttpResponseFactory;
+import org.apache.hc.core5.http.impl.io.DefaultHttpRequestWriterFactory;
+import org.apache.hc.core5.http.io.HttpMessageParser;
+import org.apache.hc.core5.http.io.HttpMessageParserFactory;
+import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicLineParser;
+import org.apache.hc.core5.http.message.LineParser;
+import org.apache.hc.core5.ssl.SSLContexts;
+import org.apache.hc.core5.util.CharArrayBuffer;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.client.CookieStore;
import org.apache.http.client.config.AuthSchemes;
@@ -49,11 +65,6 @@ import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.config.MessageConstraints;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.config.SocketConfig;
import org.apache.http.conn.DnsResolver;
import org.apache.http.conn.HttpConnectionFactory;
import org.apache.http.conn.ManagedHttpClientConnection;
@@ -61,27 +72,15 @@ import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.impl.DefaultHttpResponseFactory;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.DefaultHttpResponseParser;
import org.apache.http.impl.conn.DefaultHttpResponseParserFactory;
+import org.apache.http.impl.conn.LenientHttpResponseParser;
import org.apache.http.impl.conn.ManagedHttpClientConnectionFactory;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.impl.conn.SystemDefaultDnsResolver;
-import org.apache.http.impl.io.DefaultHttpRequestWriterFactory;
-import org.apache.http.io.HttpMessageParser;
-import org.apache.http.io.HttpMessageParserFactory;
-import org.apache.http.io.HttpMessageWriterFactory;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicLineParser;
-import org.apache.http.message.LineParser;
-import org.apache.http.ssl.SSLContexts;
-import org.apache.http.util.CharArrayBuffer;
-import org.apache.http.util.EntityUtils;
/**
* This example demonstrates how to customize and configure the most common aspects
@@ -96,8 +95,7 @@ public class ClientConfiguration {
HttpMessageParserFactory responseParserFactory = new DefaultHttpResponseParserFactory() {
@Override
- public HttpMessageParser create(
- SessionInputBuffer buffer, MessageConstraints constraints) {
+ public HttpMessageParser create(MessageConstraints constraints) {
LineParser lineParser = new BasicLineParser() {
@Override
@@ -110,16 +108,7 @@ public class ClientConfiguration {
}
};
- return new DefaultHttpResponseParser(
- buffer, lineParser, DefaultHttpResponseFactory.INSTANCE, constraints) {
-
- @Override
- protected boolean reject(final CharArrayBuffer line, int count) {
- // try to ignore all garbage preceding a status line infinitely
- return false;
- }
-
- };
+ return new LenientHttpResponseParser(lineParser, DefaultHttpResponseFactory.INSTANCE, constraints);
}
};
@@ -186,7 +175,7 @@ public class ClientConfiguration {
ConnectionConfig connectionConfig = ConnectionConfig.custom()
.setMalformedInputAction(CodingErrorAction.IGNORE)
.setUnmappableInputAction(CodingErrorAction.IGNORE)
- .setCharset(Consts.UTF_8)
+ .setCharset(StandardCharsets.UTF_8)
.setMessageConstraints(messageConstraints)
.build();
// Configure the connection manager to use connection configuration either
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java b/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
index b29319c19..123abdfe6 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
@@ -30,7 +30,7 @@ package org.apache.http.examples.client;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.http.HttpEntity;
+import org.apache.hc.core5.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java b/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java
index a3f241442..343834121 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientCustomContext.java
@@ -29,6 +29,7 @@ package org.apache.http.examples.client;
import java.util.List;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.client.CookieStore;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
@@ -37,7 +38,6 @@ import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
/**
* This example demonstrates the use of a local HTTP context populated with
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientCustomPublicSuffixList.java b/httpclient/src/examples/org/apache/http/examples/client/ClientCustomPublicSuffixList.java
index d80e01f28..4acdc02d3 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientCustomPublicSuffixList.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientCustomPublicSuffixList.java
@@ -28,12 +28,13 @@ package org.apache.http.examples.client;
import java.net.URL;
-import org.apache.http.HttpEntity;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
import org.apache.http.conn.util.PublicSuffixMatcher;
import org.apache.http.conn.util.PublicSuffixMatcherLoader;
@@ -41,7 +42,6 @@ import org.apache.http.cookie.CookieSpecProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.cookie.RFC6265CookieSpecProvider;
-import org.apache.http.util.EntityUtils;
/**
* This example demonstrates how to use a custom public suffix list.
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java b/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
index a6b9de866..edb06d911 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
@@ -30,15 +30,15 @@ import java.io.File;
import javax.net.ssl.SSLContext;
-import org.apache.http.HttpEntity;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.ssl.SSLContexts;
-import org.apache.http.util.EntityUtils;
/**
* This example demonstrates how to create secure connections with a custom SSL
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java b/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java
index cb318ce24..8edd9390d 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java
@@ -28,13 +28,13 @@ package org.apache.http.examples.client;
import java.util.concurrent.TimeUnit;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.pool.PoolStats;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.pool.PoolStats;
-import org.apache.http.util.EntityUtils;
/**
* Example demonstrating how to evict expired and idle connections
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java b/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
index d863ca413..eb841c76c 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteProxy.java
@@ -27,13 +27,13 @@
package org.apache.http.examples.client;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
/**
* How to send a request via proxy.
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteSOCKS.java b/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteSOCKS.java
index 8b69cf32a..7eaac05db 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteSOCKS.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientExecuteSOCKS.java
@@ -33,19 +33,19 @@ import java.net.Proxy;
import java.net.Socket;
import java.net.SocketTimeoutException;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.EntityUtils;
/**
* How to send a request via SOCKS proxy.
@@ -94,7 +94,7 @@ public class ClientExecuteSOCKS {
final HttpHost host,
final InetSocketAddress remoteAddress,
final InetSocketAddress localAddress,
- final HttpContext context) throws IOException, ConnectTimeoutException {
+ final HttpContext context) throws IOException {
Socket sock;
if (socket != null) {
sock = socket;
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java b/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
index 9d5dac2e1..c5fb9fcb1 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientFormLogin.java
@@ -29,7 +29,8 @@ package org.apache.http.examples.client;
import java.net.URI;
import java.util.List;
-import org.apache.http.HttpEntity;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
@@ -38,7 +39,6 @@ import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
/**
* A example that demonstrates how HttpClient APIs can be used to perform
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java b/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
index cd96224dc..1f746f0fa 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
@@ -26,15 +26,15 @@
*/
package org.apache.http.examples.client;
-import org.apache.http.HttpEntity;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.EntityUtils;
/**
* An example that performs GETs from multiple threads.
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java b/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java
index 147a83ce2..93e02ba31 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java
@@ -26,7 +26,8 @@
*/
package org.apache.http.examples.client;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
@@ -34,7 +35,6 @@ import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
/**
* An example of HttpClient can be customized to authenticate
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java b/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java
index 127c7adfb..0e45c3c73 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveDigestAuthentication.java
@@ -26,7 +26,8 @@
*/
package org.apache.http.examples.client;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -36,7 +37,6 @@ import org.apache.http.impl.auth.DigestScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
/**
* An example of HttpClient can be customized to authenticate
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java b/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
index f105690d3..0822fc7c3 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java
@@ -26,7 +26,8 @@
*/
package org.apache.http.examples.client;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.config.RequestConfig;
@@ -35,7 +36,6 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
/**
* A simple example that uses HttpClient to execute an HTTP request
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java b/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java
index 5643dc127..45e01d6db 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientWithRequestFuture.java
@@ -32,13 +32,13 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
+import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.concurrent.FutureCallback;
import org.apache.http.impl.client.FutureRequestExecutionService;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpRequestFutureTask;
@@ -56,7 +56,7 @@ public class ClientWithRequestFuture {
// Because things are asynchronous, you must provide a ResponseHandler
ResponseHandler handler = new ResponseHandler() {
@Override
- public Boolean handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
+ public Boolean handleResponse(HttpResponse response) throws IOException {
// simply return true if the status was OK
return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK;
}
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java b/httpclient/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
index b89e3c1dd..c3c18e8c5 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
@@ -29,14 +29,15 @@ package org.apache.http.examples.client;
import java.io.IOException;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
/**
* This example demonstrates the use of the {@link ResponseHandler} to simplify
@@ -55,11 +56,15 @@ public class ClientWithResponseHandler {
@Override
public String handleResponse(
- final HttpResponse response) throws ClientProtocolException, IOException {
+ final HttpResponse response) throws IOException {
int status = response.getStatusLine().getStatusCode();
if (status >= 200 && status < 300) {
HttpEntity entity = response.getEntity();
- return entity != null ? EntityUtils.toString(entity) : null;
+ try {
+ return entity != null ? EntityUtils.toString(entity) : null;
+ } catch (ParseException ex) {
+ throw new ClientProtocolException(ex);
+ }
} else {
throw new ClientProtocolException("Unexpected response status: " + status);
}
diff --git a/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java b/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java
index e79ffaba0..aeb1fbf21 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/ProxyTunnelDemo.java
@@ -32,11 +32,11 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.Socket;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.client.ProxyClient;
-import org.apache.http.protocol.HTTP;
/**
* Example code for using {@link ProxyClient} in order to establish a tunnel through an HTTP proxy.
@@ -50,7 +50,7 @@ public class ProxyTunnelDemo {
HttpHost proxy = new HttpHost("localhost", 8888);
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("user", "pwd".toCharArray());
try (Socket socket = proxyClient.tunnel(proxy, target, credentials)) {
- Writer out = new OutputStreamWriter(socket.getOutputStream(), HTTP.DEF_CONTENT_CHARSET);
+ Writer out = new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.ISO_8859_1);
out.write("GET / HTTP/1.1\r\n");
out.write("Host: " + target.toHostString() + "\r\n");
out.write("Agent: whatever\r\n");
@@ -58,7 +58,7 @@ public class ProxyTunnelDemo {
out.write("\r\n");
out.flush();
BufferedReader in = new BufferedReader(
- new InputStreamReader(socket.getInputStream(), HTTP.DEF_CONTENT_CHARSET));
+ new InputStreamReader(socket.getInputStream(), StandardCharsets.ISO_8859_1));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
diff --git a/httpclient/src/examples/org/apache/http/examples/client/QuickStart.java b/httpclient/src/examples/org/apache/http/examples/client/QuickStart.java
index eafd6fc70..cad06f541 100644
--- a/httpclient/src/examples/org/apache/http/examples/client/QuickStart.java
+++ b/httpclient/src/examples/org/apache/http/examples/client/QuickStart.java
@@ -29,16 +29,16 @@ package org.apache.http.examples.client;
import java.util.ArrayList;
import java.util.List;
-import org.apache.http.HttpEntity;
-import org.apache.http.NameValuePair;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.util.EntityUtils;
public class QuickStart {
diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthChallenge.java b/httpclient/src/main/java/org/apache/http/auth/AuthChallenge.java
index 7c6ed9f46..3ed811e47 100644
--- a/httpclient/src/main/java/org/apache/http/auth/AuthChallenge.java
+++ b/httpclient/src/main/java/org/apache/http/auth/AuthChallenge.java
@@ -31,9 +31,9 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.apache.http.NameValuePair;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.util.Args;
/**
* This class represents an authentication challenge consisting of a auth scheme
diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthExchange.java b/httpclient/src/main/java/org/apache/http/auth/AuthExchange.java
index c31a178ff..63f88dbbc 100644
--- a/httpclient/src/main/java/org/apache/http/auth/AuthExchange.java
+++ b/httpclient/src/main/java/org/apache/http/auth/AuthExchange.java
@@ -28,8 +28,8 @@ package org.apache.http.auth;
import java.util.Queue;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.util.Args;
/**
* This class represents the actual state of authentication handshake including the current {@link AuthScheme}
diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthScheme.java b/httpclient/src/main/java/org/apache/http/auth/AuthScheme.java
index 76ce39420..76e9bf194 100644
--- a/httpclient/src/main/java/org/apache/http/auth/AuthScheme.java
+++ b/httpclient/src/main/java/org/apache/http/auth/AuthScheme.java
@@ -28,9 +28,9 @@ package org.apache.http.auth;
import java.security.Principal;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* This interface represents an abstract challenge-response oriented authentication scheme.
@@ -112,7 +112,7 @@ public interface AuthScheme {
*/
void processChallenge(
AuthChallenge authChallenge,
- HttpContext context) throws MalformedChallengeException;
+ HttpContext context) throws MalformedChallengeException;
/**
* Authentication process may involve a series of challenge-response exchanges.
diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthSchemeProvider.java b/httpclient/src/main/java/org/apache/http/auth/AuthSchemeProvider.java
index 572a8dd43..355311bb8 100644
--- a/httpclient/src/main/java/org/apache/http/auth/AuthSchemeProvider.java
+++ b/httpclient/src/main/java/org/apache/http/auth/AuthSchemeProvider.java
@@ -27,7 +27,7 @@
package org.apache.http.auth;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* Factory for {@link AuthScheme} implementations.
diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthScope.java b/httpclient/src/main/java/org/apache/http/auth/AuthScope.java
index 548854009..71c8aebbe 100644
--- a/httpclient/src/main/java/org/apache/http/auth/AuthScope.java
+++ b/httpclient/src/main/java/org/apache/http/auth/AuthScope.java
@@ -28,10 +28,10 @@ package org.apache.http.auth;
import java.util.Locale;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
-import org.apache.http.util.LangUtils;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.LangUtils;
/**
* {@code AuthScope} represents an authentication scope consisting of a host name,
diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthenticationException.java b/httpclient/src/main/java/org/apache/http/auth/AuthenticationException.java
index 8d8e34c63..67059d814 100644
--- a/httpclient/src/main/java/org/apache/http/auth/AuthenticationException.java
+++ b/httpclient/src/main/java/org/apache/http/auth/AuthenticationException.java
@@ -26,8 +26,8 @@
*/
package org.apache.http.auth;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.ProtocolException;
/**
* Signals a failure in authentication process
diff --git a/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java b/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java
index 92bf4e6c9..4995399cc 100644
--- a/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java
+++ b/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java
@@ -29,9 +29,9 @@ package org.apache.http.auth;
import java.io.Serializable;
import java.security.Principal;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
-import org.apache.http.util.LangUtils;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.LangUtils;
/**
* Basic user principal used for HTTP authentication
diff --git a/httpclient/src/main/java/org/apache/http/auth/InvalidCredentialsException.java b/httpclient/src/main/java/org/apache/http/auth/InvalidCredentialsException.java
index e357241c1..009b5623d 100644
--- a/httpclient/src/main/java/org/apache/http/auth/InvalidCredentialsException.java
+++ b/httpclient/src/main/java/org/apache/http/auth/InvalidCredentialsException.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.auth;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Authentication credentials required to respond to a authentication
diff --git a/httpclient/src/main/java/org/apache/http/auth/KerberosCredentials.java b/httpclient/src/main/java/org/apache/http/auth/KerberosCredentials.java
index 39a4bfb2f..7273b0148 100644
--- a/httpclient/src/main/java/org/apache/http/auth/KerberosCredentials.java
+++ b/httpclient/src/main/java/org/apache/http/auth/KerberosCredentials.java
@@ -29,7 +29,7 @@ package org.apache.http.auth;
import java.io.Serializable;
import java.security.Principal;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
import org.ietf.jgss.GSSCredential;
/**
diff --git a/httpclient/src/main/java/org/apache/http/auth/MalformedChallengeException.java b/httpclient/src/main/java/org/apache/http/auth/MalformedChallengeException.java
index 172ba0c6e..2c3b30687 100644
--- a/httpclient/src/main/java/org/apache/http/auth/MalformedChallengeException.java
+++ b/httpclient/src/main/java/org/apache/http/auth/MalformedChallengeException.java
@@ -26,8 +26,8 @@
*/
package org.apache.http.auth;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.ProtocolException;
/**
* Signals that authentication challenge is in some way invalid or
diff --git a/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java b/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java
index d062247ac..c1cb7125e 100644
--- a/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java
+++ b/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java
@@ -30,9 +30,9 @@ import java.io.Serializable;
import java.security.Principal;
import java.util.Locale;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
-import org.apache.http.util.LangUtils;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.LangUtils;
/**
* {@link Credentials} implementation for Microsoft Windows platforms that includes
diff --git a/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java b/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java
index 82999395e..03a311f2d 100644
--- a/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java
+++ b/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java
@@ -30,9 +30,9 @@ import java.io.Serializable;
import java.security.Principal;
import java.util.Locale;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
-import org.apache.http.util.LangUtils;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.LangUtils;
/**
* Microsoft Windows specific user principal implementation.
diff --git a/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java b/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java
index 6700f3d96..18eb3f2f7 100644
--- a/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java
+++ b/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java
@@ -29,9 +29,9 @@ package org.apache.http.auth;
import java.io.Serializable;
import java.security.Principal;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
-import org.apache.http.util.LangUtils;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.LangUtils;
/**
* Simple {@link Credentials} implementation based on a user name / password
diff --git a/httpclient/src/main/java/org/apache/http/auth/util/ByteArrayBuilder.java b/httpclient/src/main/java/org/apache/http/auth/util/ByteArrayBuilder.java
index ae446df7a..e400ee508 100644
--- a/httpclient/src/main/java/org/apache/http/auth/util/ByteArrayBuilder.java
+++ b/httpclient/src/main/java/org/apache/http/auth/util/ByteArrayBuilder.java
@@ -33,9 +33,9 @@ import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.Consts;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Builder class for sequences of bytes.
@@ -102,7 +102,7 @@ public class ByteArrayBuilder {
private void doAppend(final CharBuffer charBuffer) {
if (this.charsetEncoder == null) {
- this.charsetEncoder = Consts.ASCII.newEncoder()
+ this.charsetEncoder = StandardCharsets.US_ASCII.newEncoder()
.onMalformedInput(CodingErrorAction.IGNORE)
.onUnmappableCharacter(CodingErrorAction.REPLACE);
}
diff --git a/httpclient/src/main/java/org/apache/http/client/AuthCache.java b/httpclient/src/main/java/org/apache/http/client/AuthCache.java
index 26c0b88cc..831381675 100644
--- a/httpclient/src/main/java/org/apache/http/client/AuthCache.java
+++ b/httpclient/src/main/java/org/apache/http/client/AuthCache.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.client;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.apache.http.auth.AuthScheme;
/**
diff --git a/httpclient/src/main/java/org/apache/http/client/AuthenticationStrategy.java b/httpclient/src/main/java/org/apache/http/client/AuthenticationStrategy.java
index 5463c050d..01dc8de88 100644
--- a/httpclient/src/main/java/org/apache/http/client/AuthenticationStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/client/AuthenticationStrategy.java
@@ -30,10 +30,10 @@ package org.apache.http.client;
import java.util.List;
import java.util.Map;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.ChallengeType;
-import org.apache.http.protocol.HttpContext;
/**
* Strategy to select auth schemes in order of preference based on auth challenges
diff --git a/httpclient/src/main/java/org/apache/http/client/BackoffManager.java b/httpclient/src/main/java/org/apache/http/client/BackoffManager.java
index d79b9fb52..98aecbc5a 100644
--- a/httpclient/src/main/java/org/apache/http/client/BackoffManager.java
+++ b/httpclient/src/main/java/org/apache/http/client/BackoffManager.java
@@ -43,12 +43,12 @@ public interface BackoffManager {
* using a connection should be interpreted as a
* backoff signal.
*/
- public void backOff(HttpRoute route);
+ void backOff(HttpRoute route);
/**
* Called when we have determined that the result of
* using a connection has succeeded and that we may
* probe for more connections.
*/
- public void probe(HttpRoute route);
+ void probe(HttpRoute route);
}
diff --git a/httpclient/src/main/java/org/apache/http/client/CircularRedirectException.java b/httpclient/src/main/java/org/apache/http/client/CircularRedirectException.java
index 489aa72e0..3ca9f8980 100644
--- a/httpclient/src/main/java/org/apache/http/client/CircularRedirectException.java
+++ b/httpclient/src/main/java/org/apache/http/client/CircularRedirectException.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.client;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Signals a circular redirect
diff --git a/httpclient/src/main/java/org/apache/http/client/ClientProtocolException.java b/httpclient/src/main/java/org/apache/http/client/ClientProtocolException.java
index 8383eac47..999ed052a 100644
--- a/httpclient/src/main/java/org/apache/http/client/ClientProtocolException.java
+++ b/httpclient/src/main/java/org/apache/http/client/ClientProtocolException.java
@@ -28,7 +28,7 @@ package org.apache.http.client;
import java.io.IOException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Signals an error in the HTTP protocol.
diff --git a/httpclient/src/main/java/org/apache/http/client/ConnectionBackoffStrategy.java b/httpclient/src/main/java/org/apache/http/client/ConnectionBackoffStrategy.java
index 5a7a6d9b1..c800b757f 100644
--- a/httpclient/src/main/java/org/apache/http/client/ConnectionBackoffStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/client/ConnectionBackoffStrategy.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.client;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponse;
/**
* When managing a dynamic number of connections for a given route, this
diff --git a/httpclient/src/main/java/org/apache/http/client/HttpClient.java b/httpclient/src/main/java/org/apache/http/client/HttpClient.java
index d1d2e8cc3..da776da36 100644
--- a/httpclient/src/main/java/org/apache/http/client/HttpClient.java
+++ b/httpclient/src/main/java/org/apache/http/client/HttpClient.java
@@ -29,11 +29,11 @@ package org.apache.http.client;
import java.io.IOException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.protocol.HttpContext;
/**
* This interface represents only the most basic contract for HTTP request
@@ -59,7 +59,7 @@ public interface HttpClient {
* @throws ClientProtocolException in case of an http protocol error
*/
HttpResponse execute(HttpUriRequest request)
- throws IOException, ClientProtocolException;
+ throws IOException;
/**
* Executes HTTP request using the given context.
@@ -77,7 +77,7 @@ public interface HttpClient {
* @throws ClientProtocolException in case of an http protocol error
*/
HttpResponse execute(HttpUriRequest request, HttpContext context)
- throws IOException, ClientProtocolException;
+ throws IOException;
/**
* Executes HTTP request using the default context.
@@ -97,7 +97,7 @@ public interface HttpClient {
* @throws ClientProtocolException in case of an http protocol error
*/
HttpResponse execute(HttpHost target, HttpRequest request)
- throws IOException, ClientProtocolException;
+ throws IOException;
/**
* Executes HTTP request using the given context.
@@ -120,7 +120,7 @@ public interface HttpClient {
*/
HttpResponse execute(HttpHost target, HttpRequest request,
HttpContext context)
- throws IOException, ClientProtocolException;
+ throws IOException;
/**
* Executes HTTP request using the default context and processes the
@@ -143,7 +143,7 @@ public interface HttpClient {
T execute(
HttpUriRequest request,
ResponseHandler extends T> responseHandler)
- throws IOException, ClientProtocolException;
+ throws IOException;
/**
* Executes HTTP request using the given context and processes the
@@ -169,7 +169,7 @@ public interface HttpClient {
HttpUriRequest request,
ResponseHandler extends T> responseHandler,
HttpContext context)
- throws IOException, ClientProtocolException;
+ throws IOException;
/**
* Executes HTTP request to the target using the default context and
@@ -197,7 +197,7 @@ public interface HttpClient {
HttpHost target,
HttpRequest request,
ResponseHandler extends T> responseHandler)
- throws IOException, ClientProtocolException;
+ throws IOException;
/**
* Executes HTTP request to the target using the given context and
@@ -228,6 +228,6 @@ public interface HttpClient {
HttpRequest request,
ResponseHandler extends T> responseHandler,
HttpContext context)
- throws IOException, ClientProtocolException;
+ throws IOException;
}
diff --git a/httpclient/src/main/java/org/apache/http/client/HttpRequestRetryHandler.java b/httpclient/src/main/java/org/apache/http/client/HttpRequestRetryHandler.java
index 5c91c8fba..7b2329ac1 100644
--- a/httpclient/src/main/java/org/apache/http/client/HttpRequestRetryHandler.java
+++ b/httpclient/src/main/java/org/apache/http/client/HttpRequestRetryHandler.java
@@ -29,8 +29,8 @@ package org.apache.http.client;
import java.io.IOException;
-import org.apache.http.HttpRequest;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* A handler for determining if an HttpRequest should be retried after a
diff --git a/httpclient/src/main/java/org/apache/http/client/HttpResponseException.java b/httpclient/src/main/java/org/apache/http/client/HttpResponseException.java
index 07e43776a..91a24900e 100644
--- a/httpclient/src/main/java/org/apache/http/client/HttpResponseException.java
+++ b/httpclient/src/main/java/org/apache/http/client/HttpResponseException.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.client;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Signals a non 2xx HTTP response.
diff --git a/httpclient/src/main/java/org/apache/http/client/NonRepeatableRequestException.java b/httpclient/src/main/java/org/apache/http/client/NonRepeatableRequestException.java
index 4f4befb2c..444792ac8 100644
--- a/httpclient/src/main/java/org/apache/http/client/NonRepeatableRequestException.java
+++ b/httpclient/src/main/java/org/apache/http/client/NonRepeatableRequestException.java
@@ -26,8 +26,8 @@
*/
package org.apache.http.client;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.ProtocolException;
/**
* Signals failure to retry the request due to non-repeatable request
diff --git a/httpclient/src/main/java/org/apache/http/client/RedirectException.java b/httpclient/src/main/java/org/apache/http/client/RedirectException.java
index cf2abacd0..de4b85a17 100644
--- a/httpclient/src/main/java/org/apache/http/client/RedirectException.java
+++ b/httpclient/src/main/java/org/apache/http/client/RedirectException.java
@@ -26,8 +26,8 @@
*/
package org.apache.http.client;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.ProtocolException;
/**
* Signals violation of HTTP specification caused by an invalid redirect
diff --git a/httpclient/src/main/java/org/apache/http/client/RedirectStrategy.java b/httpclient/src/main/java/org/apache/http/client/RedirectStrategy.java
index 405435d67..c157d6454 100644
--- a/httpclient/src/main/java/org/apache/http/client/RedirectStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/client/RedirectStrategy.java
@@ -27,11 +27,11 @@
package org.apache.http.client;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.protocol.HttpContext;
/**
* A strategy for determining if an HTTP request should be redirected to
diff --git a/httpclient/src/main/java/org/apache/http/client/ResponseHandler.java b/httpclient/src/main/java/org/apache/http/client/ResponseHandler.java
index 29679b0f4..f85fc858d 100644
--- a/httpclient/src/main/java/org/apache/http/client/ResponseHandler.java
+++ b/httpclient/src/main/java/org/apache/http/client/ResponseHandler.java
@@ -28,7 +28,7 @@ package org.apache.http.client;
import java.io.IOException;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponse;
/**
* Handler that encapsulates the process of generating a response object
@@ -49,6 +49,6 @@ public interface ResponseHandler {
* @throws ClientProtocolException in case of an http protocol error
* @throws IOException in case of a problem or the connection was aborted
*/
- T handleResponse(HttpResponse response) throws ClientProtocolException, IOException;
+ T handleResponse(HttpResponse response) throws IOException;
}
diff --git a/httpclient/src/main/java/org/apache/http/client/ServiceUnavailableRetryStrategy.java b/httpclient/src/main/java/org/apache/http/client/ServiceUnavailableRetryStrategy.java
index 7a7ad7ad0..0761a238a 100644
--- a/httpclient/src/main/java/org/apache/http/client/ServiceUnavailableRetryStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/client/ServiceUnavailableRetryStrategy.java
@@ -27,8 +27,8 @@
package org.apache.http.client;
-import org.apache.http.HttpResponse;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* Strategy interface that allows API users to plug in their own logic to
diff --git a/httpclient/src/main/java/org/apache/http/client/UserTokenHandler.java b/httpclient/src/main/java/org/apache/http/client/UserTokenHandler.java
index 1eadfb2c6..b841386c1 100644
--- a/httpclient/src/main/java/org/apache/http/client/UserTokenHandler.java
+++ b/httpclient/src/main/java/org/apache/http/client/UserTokenHandler.java
@@ -27,8 +27,8 @@
package org.apache.http.client;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.protocol.HttpContext;
/**
* A handler for determining if the given execution context is user specific
diff --git a/httpclient/src/main/java/org/apache/http/client/config/AuthSchemes.java b/httpclient/src/main/java/org/apache/http/client/config/AuthSchemes.java
index 58f5d613e..dfab8b0c3 100644
--- a/httpclient/src/main/java/org/apache/http/client/config/AuthSchemes.java
+++ b/httpclient/src/main/java/org/apache/http/client/config/AuthSchemes.java
@@ -27,7 +27,7 @@
package org.apache.http.client.config;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Standard authentication schemes supported by HttpClient.
diff --git a/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java b/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java
index 8c728fd6f..345d87b6f 100644
--- a/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java
+++ b/httpclient/src/main/java/org/apache/http/client/config/CookieSpecs.java
@@ -27,7 +27,7 @@
package org.apache.http.client.config;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Standard cookie specifications supported by HttpClient.
diff --git a/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java b/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java
index 893b558e6..1219692d2 100644
--- a/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java
+++ b/httpclient/src/main/java/org/apache/http/client/config/RequestConfig.java
@@ -30,13 +30,11 @@ package org.apache.http.client.config;
import java.net.InetAddress;
import java.util.Collection;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpHost;
/**
* Immutable class encapsulating request configuration items.
- * The default setting for stale connection checking changed
- * to false, and the feature was deprecated starting with version 4.4.
*/
@Immutable
public class RequestConfig implements Cloneable {
@@ -441,6 +439,11 @@ public class RequestConfig implements Cloneable {
return this;
}
+ public Builder setStaleConnectionCheckEnabled(final boolean staleConnectionCheckEnabled) {
+ this.staleConnectionCheckEnabled = staleConnectionCheckEnabled;
+ return this;
+ }
+
public RequestConfig build() {
return new RequestConfig(
expectContinueEnabled,
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
index eb222209e..bff1ee34e 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
@@ -30,10 +30,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.HttpEntityWrapper;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.HttpEntityWrapper;
+import org.apache.hc.core5.util.Args;
/**
* Common base class for decompressing {@link HttpEntity} implementations.
@@ -68,13 +67,13 @@ public class DecompressingEntity extends HttpEntityWrapper {
}
private InputStream getDecompressingStream() throws IOException {
- final InputStream in = wrappedEntity.getContent();
+ final InputStream in = super.getContent();
return new LazyDecompressingInputStream(in, inputStreamFactory);
}
@Override
public InputStream getContent() throws IOException {
- if (wrappedEntity.isStreaming()) {
+ if (super.isStreaming()) {
if (content == null) {
content = getDecompressingStream();
}
@@ -97,7 +96,7 @@ public class DecompressingEntity extends HttpEntityWrapper {
}
@Override
- public Header getContentEncoding() {
+ public String getContentEncoding() {
/* Content encoding is now 'identity' */
return null;
}
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java
index 1d3cd7fe7..e8a08956c 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java
@@ -29,7 +29,7 @@ package org.apache.http.client.entity;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.http.HttpEntity;
+import org.apache.hc.core5.http.HttpEntity;
/**
* {@link org.apache.http.entity.HttpEntityWrapper} responsible for handling
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/DeflateInputStream.java b/httpclient/src/main/java/org/apache/http/client/entity/DeflateInputStream.java
index 24f7d048b..75d5a6ac7 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/DeflateInputStream.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/DeflateInputStream.java
@@ -39,7 +39,7 @@ import java.util.zip.ZipException;
*/
public class DeflateInputStream extends InputStream {
- private InputStream sourceStream;
+ private final InputStream sourceStream;
public DeflateInputStream(final InputStream wrapped) throws IOException {
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java b/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java
index ce3dfe2fe..0f4563d77 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java
@@ -33,17 +33,17 @@ import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
-import org.apache.http.HttpEntity;
-import org.apache.http.NameValuePair;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.entity.AbstractHttpEntity;
-import org.apache.http.entity.BasicHttpEntity;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.FileEntity;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.SerializableEntity;
-import org.apache.http.entity.StringEntity;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.entity.AbstractHttpEntity;
+import org.apache.hc.core5.http.entity.BasicHttpEntity;
+import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.FileEntity;
+import org.apache.hc.core5.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.entity.SerializableEntity;
+import org.apache.hc.core5.http.entity.StringEntity;
/**
* Builder for {@link HttpEntity} instances.
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java
index 30082398f..f7c28ef19 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java
@@ -58,12 +58,9 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.GZIPOutputStream;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.HttpEntityWrapper;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.HttpEntityWrapper;
+import org.apache.hc.core5.util.Args;
/**
* Wrapping entity that compresses content when {@link #writeTo writing}.
@@ -80,8 +77,8 @@ public class GzipCompressingEntity extends HttpEntityWrapper {
}
@Override
- public Header getContentEncoding() {
- return new BasicHeader(HTTP.CONTENT_ENCODING, GZIP_CODEC);
+ public String getContentEncoding() {
+ return GZIP_CODEC;
}
@Override
@@ -104,7 +101,7 @@ public class GzipCompressingEntity extends HttpEntityWrapper {
public void writeTo(final OutputStream outstream) throws IOException {
Args.notNull(outstream, "Output stream");
final GZIPOutputStream gzip = new GZIPOutputStream(outstream);
- wrappedEntity.writeTo(gzip);
+ super.writeTo(gzip);
// Only close output stream if the wrapped entity has been
// successfully written out
gzip.close();
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/GzipDecompressingEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/GzipDecompressingEntity.java
index ca45b59bb..1f993d963 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/GzipDecompressingEntity.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/GzipDecompressingEntity.java
@@ -30,7 +30,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.zip.GZIPInputStream;
-import org.apache.http.HttpEntity;
+import org.apache.hc.core5.http.HttpEntity;
/**
* {@link org.apache.http.entity.HttpEntityWrapper} for handling gzip
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java b/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java
index db95ce8b4..4bfd7aef7 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java
@@ -29,7 +29,7 @@ package org.apache.http.client.entity;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
/**
* Lazy init InputStream wrapper.
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java
index a34c9e79a..8773b22a1 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java
@@ -27,14 +27,14 @@
package org.apache.http.client.entity;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.List;
-import org.apache.http.NameValuePair;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.StringEntity;
import org.apache.http.client.utils.URLEncodedUtils;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.protocol.HTTP;
/**
* An entity composed of a list of url-encoded pairs.
@@ -58,13 +58,13 @@ public class UrlEncodedFormEntity extends StringEntity {
final Iterable extends NameValuePair> parameters,
final Charset charset) {
super(URLEncodedUtils.format(parameters,
- charset != null ? charset : HTTP.DEF_CONTENT_CHARSET),
+ charset != null ? charset : StandardCharsets.ISO_8859_1),
ContentType.create(URLEncodedUtils.CONTENT_TYPE, charset));
}
/**
* Constructs a new {@link UrlEncodedFormEntity} with the list
- * of parameters with the default encoding of {@link HTTP#DEFAULT_CONTENT_CHARSET}
+ * of parameters with the default encoding of {@link StandardCharsets#ISO_8859_1}
*
* @param parameters list of name/value pairs
*/
@@ -74,7 +74,7 @@ public class UrlEncodedFormEntity extends StringEntity {
/**
* Constructs a new {@link UrlEncodedFormEntity} with the list
- * of parameters with the default encoding of {@link HTTP#DEFAULT_CONTENT_CHARSET}
+ * of parameters with the default encoding of {@link StandardCharsets#ISO_8859_1}
*
* @param parameters iterable collection of name/value pairs
*
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/AbstractExecutionAwareRequest.java b/httpclient/src/main/java/org/apache/http/client/methods/AbstractExecutionAwareRequest.java
index b9b6a4c7f..219f05502 100644
--- a/httpclient/src/main/java/org/apache/http/client/methods/AbstractExecutionAwareRequest.java
+++ b/httpclient/src/main/java/org/apache/http/client/methods/AbstractExecutionAwareRequest.java
@@ -29,13 +29,11 @@ package org.apache.http.client.methods;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
-import org.apache.http.HttpRequest;
-import org.apache.http.client.utils.CloneUtils;
-import org.apache.http.concurrent.Cancellable;
-import org.apache.http.message.AbstractHttpMessage;
+import org.apache.hc.core5.concurrent.Cancellable;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.message.AbstractHttpMessage;
-public abstract class AbstractExecutionAwareRequest extends AbstractHttpMessage implements
- HttpExecutionAware, Cloneable, HttpRequest {
+public abstract class AbstractExecutionAwareRequest extends AbstractHttpMessage implements HttpExecutionAware, HttpRequest {
private final AtomicBoolean aborted;
private final AtomicReference cancellableRef;
@@ -70,13 +68,6 @@ public abstract class AbstractExecutionAwareRequest extends AbstractHttpMessage
}
}
- @Override
- public Object clone() throws CloneNotSupportedException {
- final AbstractExecutionAwareRequest clone = (AbstractExecutionAwareRequest) super.clone();
- clone.headergroup = CloneUtils.cloneObject(this.headergroup);
- return clone;
- }
-
/**
* @since 4.2
*/
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/CloseableHttpResponse.java b/httpclient/src/main/java/org/apache/http/client/methods/CloseableHttpResponse.java
index d0391daa3..1914781de 100644
--- a/httpclient/src/main/java/org/apache/http/client/methods/CloseableHttpResponse.java
+++ b/httpclient/src/main/java/org/apache/http/client/methods/CloseableHttpResponse.java
@@ -29,7 +29,7 @@ package org.apache.http.client.methods;
import java.io.Closeable;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponse;
/**
* Extended version of the {@link HttpResponse} interface that also extends {@link Closeable}.
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpDelete.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpDelete.java
index 9b078a3ea..14305bf15 100644
--- a/httpclient/src/main/java/org/apache/http/client/methods/HttpDelete.java
+++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpDelete.java
@@ -29,7 +29,7 @@ package org.apache.http.client.methods;
import java.net.URI;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
/**
* HTTP DELETE method
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java
deleted file mode 100644
index 5efb82810..000000000
--- a/httpclient/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.client.utils.CloneUtils;
-import org.apache.http.protocol.HTTP;
-
-/**
- * Basic implementation of an entity enclosing HTTP request
- * that can be modified
- *
- * @since 4.0
- */
-@NotThreadSafe // HttpRequestBase is @NotThreadSafe
-public abstract class HttpEntityEnclosingRequestBase
- extends HttpRequestBase implements HttpEntityEnclosingRequest {
-
- private HttpEntity entity;
-
- public HttpEntityEnclosingRequestBase() {
- super();
- }
-
- @Override
- public HttpEntity getEntity() {
- return this.entity;
- }
-
- @Override
- public void setEntity(final HttpEntity entity) {
- this.entity = entity;
- }
-
- @Override
- public boolean expectContinue() {
- final Header expect = getFirstHeader(HTTP.EXPECT_DIRECTIVE);
- return expect != null && HTTP.EXPECT_CONTINUE.equalsIgnoreCase(expect.getValue());
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- final HttpEntityEnclosingRequestBase clone =
- (HttpEntityEnclosingRequestBase) super.clone();
- if (this.entity != null) {
- clone.entity = CloneUtils.cloneObject(this.entity);
- }
- return clone;
- }
-
-}
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java
index 0a52376b3..bc372b809 100644
--- a/httpclient/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java
+++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java
@@ -27,7 +27,7 @@
package org.apache.http.client.methods;
-import org.apache.http.concurrent.Cancellable;
+import org.apache.hc.core5.concurrent.Cancellable;
/**
* Interface to be implemented by any object that wishes to be notified of
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpGet.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpGet.java
index 35de2d3e4..7c6c59104 100644
--- a/httpclient/src/main/java/org/apache/http/client/methods/HttpGet.java
+++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpGet.java
@@ -29,7 +29,7 @@ package org.apache.http.client.methods;
import java.net.URI;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
/**
* HTTP GET method.
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpHead.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpHead.java
index 4e4bd9667..82aafd61a 100644
--- a/httpclient/src/main/java/org/apache/http/client/methods/HttpHead.java
+++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpHead.java
@@ -29,7 +29,7 @@ package org.apache.http.client.methods;
import java.net.URI;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
/**
* HTTP HEAD method.
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java
index fd3b7ce56..b438eb216 100644
--- a/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java
+++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpOptions.java
@@ -29,14 +29,14 @@ package org.apache.http.client.methods;
import java.net.URI;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.util.Args;
/**
* HTTP OPTIONS method.
@@ -85,10 +85,10 @@ public class HttpOptions extends HttpRequestBase {
public Set getAllowedMethods(final HttpResponse response) {
Args.notNull(response, "HTTP response");
- final HeaderIterator it = response.headerIterator("Allow");
+ final Iterator
*
diff --git a/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java b/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java
index 25255d68e..77993a5c0 100644
--- a/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java
+++ b/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionOperator.java
@@ -30,9 +30,9 @@ package org.apache.http.conn;
import java.io.IOException;
import java.net.InetSocketAddress;
-import org.apache.http.HttpHost;
-import org.apache.http.config.SocketConfig;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.SocketConfig;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* Connection operator that performs connection connect and upgrade operations. Usually, components
diff --git a/httpclient/src/main/java/org/apache/http/conn/HttpConnectionFactory.java b/httpclient/src/main/java/org/apache/http/conn/HttpConnectionFactory.java
index 746c2ea4e..c01115437 100644
--- a/httpclient/src/main/java/org/apache/http/conn/HttpConnectionFactory.java
+++ b/httpclient/src/main/java/org/apache/http/conn/HttpConnectionFactory.java
@@ -26,8 +26,8 @@
*/
package org.apache.http.conn;
-import org.apache.http.HttpConnection;
-import org.apache.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.HttpConnection;
+import org.apache.hc.core5.http.config.ConnectionConfig;
/**
* Generic {@link HttpConnection} factory.
diff --git a/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java b/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java
index 0e4ce51d5..36c34e9c1 100644
--- a/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java
+++ b/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java
@@ -31,8 +31,8 @@ import java.net.ConnectException;
import java.net.InetAddress;
import java.util.Arrays;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpHost;
/**
* A {@link ConnectException} that specifies the {@link HttpHost} that was
diff --git a/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java b/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java
index 44cd60ffa..37778c58e 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java
@@ -32,8 +32,7 @@ import java.net.Socket;
import javax.net.ssl.SSLSession;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpInetConnection;
+import org.apache.hc.core5.http.io.HttpClientConnection;
/**
* Represents a managed connection whose state and life cycle is managed by
@@ -43,7 +42,7 @@ import org.apache.http.HttpInetConnection;
*
* @since 4.3
*/
-public interface ManagedHttpClientConnection extends HttpClientConnection, HttpInetConnection {
+public interface ManagedHttpClientConnection extends HttpClientConnection {
/**
* Returns connection ID which is expected to be unique
diff --git a/httpclient/src/main/java/org/apache/http/conn/SchemePortResolver.java b/httpclient/src/main/java/org/apache/http/conn/SchemePortResolver.java
index 848ad2f77..5762048c7 100644
--- a/httpclient/src/main/java/org/apache/http/conn/SchemePortResolver.java
+++ b/httpclient/src/main/java/org/apache/http/conn/SchemePortResolver.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.conn;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
/**
* Strategy for default port resolution for protocol schemes.
diff --git a/httpclient/src/main/java/org/apache/http/conn/UnsupportedSchemeException.java b/httpclient/src/main/java/org/apache/http/conn/UnsupportedSchemeException.java
index 268a0b80a..2e6a63285 100644
--- a/httpclient/src/main/java/org/apache/http/conn/UnsupportedSchemeException.java
+++ b/httpclient/src/main/java/org/apache/http/conn/UnsupportedSchemeException.java
@@ -29,7 +29,7 @@ package org.apache.http.conn;
import java.io.IOException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Signals failure to establish connection using an unknown protocol scheme.
diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java b/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java
index eff3f04a2..68d8d1eaa 100644
--- a/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java
+++ b/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java
@@ -27,8 +27,8 @@
package org.apache.http.conn.routing;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
/**
* Basic {@link HttpRouteDirector} implementation.
diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
index b1fa4b388..26e6a1fa3 100644
--- a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
+++ b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java
@@ -34,10 +34,10 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
-import org.apache.http.util.LangUtils;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.LangUtils;
/**
* The route for a request.
diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRouteDirector.java b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRouteDirector.java
index d6e9d2557..b1f4a5097 100644
--- a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRouteDirector.java
+++ b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRouteDirector.java
@@ -37,25 +37,25 @@ package org.apache.http.conn.routing;
public interface HttpRouteDirector {
/** Indicates that the route can not be established at all. */
- public final static int UNREACHABLE = -1;
+ int UNREACHABLE = -1;
/** Indicates that the route is complete. */
- public final static int COMPLETE = 0;
+ int COMPLETE = 0;
/** Step: open connection to target. */
- public final static int CONNECT_TARGET = 1;
+ int CONNECT_TARGET = 1;
/** Step: open connection to proxy. */
- public final static int CONNECT_PROXY = 2;
+ int CONNECT_PROXY = 2;
/** Step: tunnel through proxy to target. */
- public final static int TUNNEL_TARGET = 3;
+ int TUNNEL_TARGET = 3;
/** Step: tunnel through proxy to other proxy. */
- public final static int TUNNEL_PROXY = 4;
+ int TUNNEL_PROXY = 4;
/** Step: layer protocol (over tunnel). */
- public final static int LAYER_PROTOCOL = 5;
+ int LAYER_PROTOCOL = 5;
/**
@@ -69,6 +69,6 @@ public interface HttpRouteDirector {
* either the next step to perform, or success, or failure.
* 0 is for success, a negative value for failure.
*/
- public int nextStep(RouteInfo plan, RouteInfo fact);
+ int nextStep(RouteInfo plan, RouteInfo fact);
}
diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoutePlanner.java b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoutePlanner.java
index 76297d45d..aa2f2ad40 100644
--- a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoutePlanner.java
+++ b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoutePlanner.java
@@ -27,10 +27,10 @@
package org.apache.http.conn.routing;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* Encapsulates logic to compute a {@link HttpRoute} to a target host.
@@ -61,8 +61,8 @@ public interface HttpRoutePlanner {
*
* @throws HttpException in case of a problem
*/
- public HttpRoute determineRoute(HttpHost target,
- HttpRequest request,
- HttpContext context) throws HttpException;
+ HttpRoute determineRoute(HttpHost target,
+ HttpRequest request,
+ HttpContext context) throws HttpException;
}
diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/RouteInfo.java b/httpclient/src/main/java/org/apache/http/conn/routing/RouteInfo.java
index 59c37a21a..50055b4d0 100644
--- a/httpclient/src/main/java/org/apache/http/conn/routing/RouteInfo.java
+++ b/httpclient/src/main/java/org/apache/http/conn/routing/RouteInfo.java
@@ -29,7 +29,7 @@ package org.apache.http.conn.routing;
import java.net.InetAddress;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
/**
* Read-only interface for route information.
@@ -46,7 +46,7 @@ public interface RouteInfo {
* and tunnelling through all proxies to the target.
* Routes without a proxy cannot be tunnelled.
*/
- public enum TunnelType { PLAIN, TUNNELLED }
+ enum TunnelType { PLAIN, TUNNELLED }
/**
* The layering type of a route.
@@ -62,7 +62,7 @@ public interface RouteInfo {
* But we don't want to exclude that use case.
*
*/
- public enum LayerType { PLAIN, LAYERED }
+ enum LayerType { PLAIN, LAYERED }
/**
* Obtains the target host.
diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java b/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java
index e55079970..cd6a61a9f 100644
--- a/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java
+++ b/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java
@@ -29,11 +29,11 @@ package org.apache.http.conn.routing;
import java.net.InetAddress;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
-import org.apache.http.util.Asserts;
-import org.apache.http.util.LangUtils;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.Asserts;
+import org.apache.hc.core5.util.LangUtils;
/**
* Helps tracking the steps in establishing a route.
diff --git a/httpclient/src/main/java/org/apache/http/conn/socket/ConnectionSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/socket/ConnectionSocketFactory.java
index 9c751b7fd..d4a10dd64 100644
--- a/httpclient/src/main/java/org/apache/http/conn/socket/ConnectionSocketFactory.java
+++ b/httpclient/src/main/java/org/apache/http/conn/socket/ConnectionSocketFactory.java
@@ -31,8 +31,8 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
-import org.apache.http.HttpHost;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* A factory for creating and connecting connection sockets.
diff --git a/httpclient/src/main/java/org/apache/http/conn/socket/LayeredConnectionSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/socket/LayeredConnectionSocketFactory.java
index 3f4e2a9af..f08275e42 100644
--- a/httpclient/src/main/java/org/apache/http/conn/socket/LayeredConnectionSocketFactory.java
+++ b/httpclient/src/main/java/org/apache/http/conn/socket/LayeredConnectionSocketFactory.java
@@ -29,9 +29,8 @@ package org.apache.http.conn.socket;
import java.io.IOException;
import java.net.Socket;
-import java.net.UnknownHostException;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* Extended {@link ConnectionSocketFactory} interface for layered sockets such as SSL/TLS.
@@ -58,6 +57,6 @@ public interface LayeredConnectionSocketFactory extends ConnectionSocketFactory
Socket socket,
String target,
int port,
- HttpContext context) throws IOException, UnknownHostException;
+ HttpContext context) throws IOException;
}
diff --git a/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java
index 193e73da0..470e77f59 100644
--- a/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java
+++ b/httpclient/src/main/java/org/apache/http/conn/socket/PlainConnectionSocketFactory.java
@@ -31,9 +31,9 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* The default class for creating plain (unencrypted) sockets.
diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java b/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
index 2a472e41a..97a92723e 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
@@ -51,7 +51,7 @@ import javax.security.auth.x500.X500Principal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
import org.apache.http.conn.util.DomainType;
import org.apache.http.conn.util.InetAddressUtils;
import org.apache.http.conn.util.PublicSuffixMatcher;
diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/NoopHostnameVerifier.java b/httpclient/src/main/java/org/apache/http/conn/ssl/NoopHostnameVerifier.java
index 1b5cdd954..6ccb3a80e 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ssl/NoopHostnameVerifier.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ssl/NoopHostnameVerifier.java
@@ -30,7 +30,7 @@ package org.apache.http.conn.ssl;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* The NO_OP HostnameVerifier essentially turns hostname verification
diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
index f03a8520e..bd1319ebf 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
@@ -49,14 +49,14 @@ import javax.security.auth.x500.X500Principal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.ssl.SSLContexts;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.TextUtils;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
import org.apache.http.conn.util.PublicSuffixMatcherLoader;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.ssl.SSLContexts;
-import org.apache.http.util.Args;
-import org.apache.http.util.TextUtils;
/**
* Layered socket factory for TLS/SSL connections.
diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/TrustSelfSignedStrategy.java b/httpclient/src/main/java/org/apache/http/conn/ssl/TrustSelfSignedStrategy.java
index e59b52e6e..e39f2039e 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ssl/TrustSelfSignedStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ssl/TrustSelfSignedStrategy.java
@@ -29,6 +29,8 @@ package org.apache.http.conn.ssl;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
+import org.apache.hc.core5.ssl.TrustStrategy;
+
/**
* A trust strategy that accepts self-signed certificates as trusted. Verification of all other
* certificates is done by the trust manager configured in the SSL context.
diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/TrustStrategy.java b/httpclient/src/main/java/org/apache/http/conn/ssl/TrustStrategy.java
deleted file mode 100644
index 53a8091d4..000000000
--- a/httpclient/src/main/java/org/apache/http/conn/ssl/TrustStrategy.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.conn.ssl;
-
-/**
- * A strategy to establish trustworthiness of certificates without consulting the trust manager
- * configured in the actual SSL context. This interface can be used to override the standard
- * JSSE certificate verification process.
- *
- * @since 4.1
- */
-public interface TrustStrategy extends org.apache.http.ssl.TrustStrategy {
-
-}
diff --git a/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java b/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java
index acee8afa2..2ae8ad2c9 100644
--- a/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java
+++ b/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java
@@ -29,7 +29,7 @@ package org.apache.http.conn.util;
import java.util.regex.Pattern;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* A collection of utilities relating to InetAddresses.
diff --git a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixList.java b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixList.java
index dfdd928ce..c3b76bdf3 100644
--- a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixList.java
+++ b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixList.java
@@ -29,8 +29,8 @@ package org.apache.http.conn.util;
import java.util.Collections;
import java.util.List;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
/**
* Public suffix is a set of DNS names or wildcards concatenated with dots. It represents
diff --git a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java
index 959fea2e1..2e4171db6 100644
--- a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java
+++ b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixListParser.java
@@ -32,7 +32,7 @@ import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Parses the list from publicsuffix.org
diff --git a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
index 6dc48c909..8f3fa6a62 100644
--- a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
+++ b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
@@ -33,8 +33,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.util.Args;
/**
* Utility class that can test if DNS names match the content of the Public Suffix List.
diff --git a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java
index a77a5c9e3..e9608a35d 100644
--- a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java
+++ b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcherLoader.java
@@ -32,14 +32,14 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.Consts;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.util.Args;
/**
* {@link org.apache.http.conn.util.PublicSuffixMatcher} loader.
@@ -51,7 +51,7 @@ public final class PublicSuffixMatcherLoader {
private static PublicSuffixMatcher load(final InputStream in) throws IOException {
final List lists = new PublicSuffixListParser().parseByType(
- new InputStreamReader(in, Consts.UTF_8));
+ new InputStreamReader(in, StandardCharsets.UTF_8));
return new PublicSuffixMatcher(lists);
}
diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java b/httpclient/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java
index 935a5a338..2056c948a 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java
@@ -30,7 +30,7 @@ package org.apache.http.cookie;
import java.io.Serializable;
import java.util.Comparator;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* This cookie comparator can be used to compare identity of cookies.
diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java b/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java
index b46f6bd35..4160076e4 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/CookieOrigin.java
@@ -28,9 +28,9 @@ package org.apache.http.cookie;
import java.util.Locale;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
-import org.apache.http.util.TextUtils;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.TextUtils;
/**
* CookieOrigin class encapsulates details of an origin server that
diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookiePathComparator.java b/httpclient/src/main/java/org/apache/http/cookie/CookiePathComparator.java
index f9e3e7672..9135dc2b1 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/CookiePathComparator.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/CookiePathComparator.java
@@ -30,7 +30,7 @@ package org.apache.http.cookie;
import java.io.Serializable;
import java.util.Comparator;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* This cookie comparator ensures that multiple cookies satisfying
diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookiePriorityComparator.java b/httpclient/src/main/java/org/apache/http/cookie/CookiePriorityComparator.java
index cc52036da..e7055c6f1 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/CookiePriorityComparator.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/CookiePriorityComparator.java
@@ -30,7 +30,7 @@ package org.apache.http.cookie;
import java.util.Comparator;
import java.util.Date;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
import org.apache.http.impl.cookie.BasicClientCookie;
/**
diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieRestrictionViolationException.java b/httpclient/src/main/java/org/apache/http/cookie/CookieRestrictionViolationException.java
index 3b30a977b..16b045557 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/CookieRestrictionViolationException.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/CookieRestrictionViolationException.java
@@ -27,7 +27,7 @@
package org.apache.http.cookie;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Signals that a cookie violates a restriction imposed by the cookie
diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieSpec.java b/httpclient/src/main/java/org/apache/http/cookie/CookieSpec.java
index cbe4870f5..f7482992a 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/CookieSpec.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/CookieSpec.java
@@ -29,7 +29,7 @@ package org.apache.http.cookie;
import java.util.List;
-import org.apache.http.Header;
+import org.apache.hc.core5.http.Header;
/**
* Defines the cookie management specification.
diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieSpecProvider.java b/httpclient/src/main/java/org/apache/http/cookie/CookieSpecProvider.java
index fdb4f0279..a53c85af1 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/CookieSpecProvider.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/CookieSpecProvider.java
@@ -27,7 +27,7 @@
package org.apache.http.cookie;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* Factory for {@link CookieSpec} implementations.
diff --git a/httpclient/src/main/java/org/apache/http/cookie/MalformedCookieException.java b/httpclient/src/main/java/org/apache/http/cookie/MalformedCookieException.java
index da70979c6..15230a5b1 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/MalformedCookieException.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/MalformedCookieException.java
@@ -27,8 +27,8 @@
package org.apache.http.cookie;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.ProtocolException;
/**
* Signals that a cookie is in some way invalid or illegal in a given
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/AuthChallengeParser.java b/httpclient/src/main/java/org/apache/http/impl/auth/AuthChallengeParser.java
index 9511f4614..e69845efe 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/AuthChallengeParser.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/AuthChallengeParser.java
@@ -31,13 +31,13 @@ import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
-import org.apache.http.NameValuePair;
-import org.apache.http.ParseException;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
+import org.apache.hc.core5.http.message.ParserCursor;
+import org.apache.hc.core5.http.message.TokenParser;
+import org.apache.hc.core5.util.CharArrayBuffer;
import org.apache.http.auth.AuthChallenge;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.message.TokenParser;
-import org.apache.http.util.CharArrayBuffer;
public class AuthChallengeParser {
@@ -101,7 +101,7 @@ public class AuthChallengeParser {
return list;
}
- private static AuthChallenge createAuthChallenge(final String scheme, final List params) {
+ private static AuthChallenge createAuthChallenge(final String scheme, final List params) throws ParseException {
if (scheme != null) {
if (params.size() == 1) {
final NameValuePair nvp = params.get(0);
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java
index 5d9f64bd6..fc957aa02 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java
@@ -32,6 +32,7 @@ import java.io.ObjectOutputStream;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.security.Principal;
import java.util.HashMap;
import java.util.List;
@@ -39,11 +40,13 @@ import java.util.Locale;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
-import org.apache.http.Consts;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.NameValuePair;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.CharsetUtils;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthScope;
@@ -52,9 +55,6 @@ import org.apache.http.auth.Credentials;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.auth.util.ByteArrayBuilder;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.CharsetUtils;
/**
* Basic authentication scheme as defined in RFC 2617.
@@ -80,12 +80,12 @@ public class BasicScheme implements AuthScheme, Serializable {
*/
public BasicScheme(final Charset charset) {
this.paramMap = new HashMap<>();
- this.charset = charset != null ? charset : Consts.ASCII;
+ this.charset = charset != null ? charset : StandardCharsets.US_ASCII;
this.complete = false;
}
public BasicScheme() {
- this(Consts.ASCII);
+ this(StandardCharsets.US_ASCII);
}
public void initPreemptive(final Credentials credentials) {
@@ -174,7 +174,7 @@ public class BasicScheme implements AuthScheme, Serializable {
}
final byte[] encodedCreds = this.base64codec.encode(this.buffer.toByteArray());
this.buffer.reset();
- return "Basic " + new String(encodedCreds, 0, encodedCreds.length, Consts.ASCII);
+ return "Basic " + new String(encodedCreds, 0, encodedCreds.length, StandardCharsets.US_ASCII);
}
private void writeObject(final ObjectOutputStream out) throws IOException {
@@ -187,7 +187,7 @@ public class BasicScheme implements AuthScheme, Serializable {
in.defaultReadObject();
this.charset = CharsetUtils.get(in.readUTF());
if (this.charset == null) {
- this.charset = Consts.ASCII;
+ this.charset = StandardCharsets.US_ASCII;
}
}
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/BasicSchemeFactory.java b/httpclient/src/main/java/org/apache/http/impl/auth/BasicSchemeFactory.java
index f6854a5cc..b7086c7f9 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/BasicSchemeFactory.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/BasicSchemeFactory.java
@@ -29,10 +29,10 @@ package org.apache.http.impl.auth;
import java.nio.charset.Charset;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.protocol.HttpContext;
/**
* {@link AuthSchemeProvider} implementation that creates and initializes
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
index d73b3683a..7260b93c0 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
@@ -29,6 +29,7 @@ package org.apache.http.impl.auth;
import java.io.IOException;
import java.io.Serializable;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.Principal;
import java.security.SecureRandom;
@@ -42,13 +43,17 @@ import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
-import org.apache.http.Consts;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.NameValuePair;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.message.BasicHeaderValueFormatter;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.CharArrayBuffer;
+import org.apache.hc.core5.util.CharsetUtils;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthScope;
@@ -57,12 +62,6 @@ import org.apache.http.auth.Credentials;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.auth.util.ByteArrayBuilder;
-import org.apache.http.message.BasicHeaderValueFormatter;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.CharArrayBuffer;
-import org.apache.http.util.CharsetUtils;
/**
* Digest authentication scheme as defined in RFC 2617.
@@ -243,10 +242,12 @@ public class DigestScheme implements AuthScheme, Serializable {
final String variant = tok.nextToken().trim();
qopset.add(variant.toLowerCase(Locale.ROOT));
}
- if (request instanceof HttpEntityEnclosingRequest && qopset.contains("auth-int")) {
+ if (request.getEntity() != null && qopset.contains("auth-int")) {
qop = QOP_AUTH_INT;
} else if (qopset.contains("auth")) {
qop = QOP_AUTH;
+ } else if (qopset.contains("auth-int")) {
+ qop = QOP_AUTH_INT;
}
} else {
qop = QOP_MISSING;
@@ -259,7 +260,7 @@ public class DigestScheme implements AuthScheme, Serializable {
final String charsetName = this.paramMap.get("charset");
Charset charset = charsetName != null ? CharsetUtils.lookup(charsetName) : null;
if (charset == null) {
- charset = Consts.ISO_8859_1;
+ charset = StandardCharsets.ISO_8859_1;
}
String digAlg = algorithm;
@@ -327,10 +328,7 @@ public class DigestScheme implements AuthScheme, Serializable {
a2 = buffer.append(method).append(":").append(uri).toByteArray();
} else if (qop == QOP_AUTH_INT) {
// Method ":" digest-uri-value ":" H(entity-body)
- HttpEntity entity = null;
- if (request instanceof HttpEntityEnclosingRequest) {
- entity = ((HttpEntityEnclosingRequest) request).getEntity();
- }
+ final HttpEntity entity = request.getEntity();
if (entity != null && !entity.isRepeatable()) {
// If the entity is not repeatable, try falling back onto QOP_AUTH
if (qopset.contains("auth")) {
@@ -415,11 +413,11 @@ public class DigestScheme implements AuthScheme, Serializable {
}
String getA1() {
- return a1 != null ? new String(a1, Consts.ASCII) : null;
+ return a1 != null ? new String(a1, StandardCharsets.US_ASCII) : null;
}
String getA2() {
- return a2 != null ? new String(a2, Consts.ASCII) : null;
+ return a2 != null ? new String(a2, StandardCharsets.US_ASCII) : null;
}
/**
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/DigestSchemeFactory.java b/httpclient/src/main/java/org/apache/http/impl/auth/DigestSchemeFactory.java
index 545fe5b67..3b95d2cd4 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/DigestSchemeFactory.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/DigestSchemeFactory.java
@@ -27,10 +27,10 @@
package org.apache.http.impl.auth;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.protocol.HttpContext;
/**
* {@link AuthSchemeProvider} implementation that creates and initializes
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
index 09f73b2bc..6ed74e58d 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
@@ -33,9 +33,11 @@ import java.security.Principal;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthScope;
@@ -45,8 +47,6 @@ import org.apache.http.auth.CredentialsProvider;
import org.apache.http.auth.InvalidCredentialsException;
import org.apache.http.auth.KerberosCredentials;
import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java b/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
index 1fbacd561..1da56f49e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
@@ -37,15 +37,20 @@ import java.util.Queue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.FormattedHeader;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.ParseException;
+import org.apache.hc.core5.http.FormattedHeader;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.ParserCursor;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Asserts;
+import org.apache.hc.core5.util.CharArrayBuffer;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.AuthScheme;
@@ -58,11 +63,6 @@ import org.apache.http.client.AuthenticationStrategy;
import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.BasicAuthCache;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Asserts;
-import org.apache.http.util.CharArrayBuffer;
/**
* @since 4.3
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java
index 974361f13..f58f0a476 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/KerberosScheme.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.auth;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
import org.ietf.jgss.GSSException;
import org.ietf.jgss.Oid;
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/KerberosSchemeFactory.java b/httpclient/src/main/java/org/apache/http/impl/auth/KerberosSchemeFactory.java
index 88a61c7ff..dee866def 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/KerberosSchemeFactory.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/KerberosSchemeFactory.java
@@ -26,10 +26,10 @@
*/
package org.apache.http.impl.auth;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.protocol.HttpContext;
/**
* {@link AuthSchemeProvider} implementation that creates and initializes
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineException.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineException.java
index f902ae1bc..6fdd99b8e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineException.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineException.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.auth;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
import org.apache.http.auth.AuthenticationException;
/**
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
index 3b7fa3e32..d7b13b9ec 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
@@ -28,6 +28,7 @@ package org.apache.http.impl.auth;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.security.MessageDigest;
import java.util.Arrays;
@@ -37,11 +38,9 @@ import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
-import org.apache.http.Consts;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.util.CharsetUtils;
import org.apache.http.auth.util.ByteArrayBuilder;
-import org.apache.http.util.CharsetUtils;
-import org.apache.http.util.EncodingUtils;
/**
* Provides an implementation for NTLMv1, NTLMv2, and NTLM2 Session forms of the NTLM
@@ -55,7 +54,7 @@ final class NTLMEngineImpl implements NTLMEngine {
/** Unicode encoding */
private static final Charset UNICODE_LITTLE_UNMARKED = CharsetUtils.lookup("UnicodeLittleUnmarked");
/** Character encoding */
- private static final Charset DEFAULT_CHARSET = Consts.ASCII;
+ private static final Charset DEFAULT_CHARSET = StandardCharsets.US_ASCII;
// Flags we use; descriptions according to:
// http://davenport.sourceforge.net/ntlm.html
@@ -93,7 +92,7 @@ final class NTLMEngineImpl implements NTLMEngine {
private static final byte[] SIGNATURE;
static {
- final byte[] bytesWithoutNull = "NTLMSSP".getBytes(Consts.ASCII);
+ final byte[] bytesWithoutNull = "NTLMSSP".getBytes(StandardCharsets.US_ASCII);
SIGNATURE = new byte[bytesWithoutNull.length + 1];
System.arraycopy(bytesWithoutNull, 0, SIGNATURE, 0, bytesWithoutNull.length);
SIGNATURE[bytesWithoutNull.length] = (byte) 0x00;
@@ -115,7 +114,7 @@ final class NTLMEngineImpl implements NTLMEngine {
* @param domain
* the NT domain to authenticate in.
* @return The response.
- * @throws org.apache.http.HttpException
+ * @throws org.apache.hc.core5.http.HttpException
* If the messages cannot be retrieved.
*/
static String getResponseFor(final String message, final String username, final char[] password,
@@ -570,7 +569,7 @@ final class NTLMEngineImpl implements NTLMEngine {
System.arraycopy(oemPassword, 0, keyBytes, 0, length);
final Key lowKey = createDESKey(keyBytes, 0);
final Key highKey = createDESKey(keyBytes, 7);
- final byte[] magicConstant = "KGS!@#$%".getBytes(Consts.ASCII);
+ final byte[] magicConstant = "KGS!@#$%".getBytes(StandardCharsets.US_ASCII);
final Cipher des = Cipher.getInstance("DES/ECB/NoPadding");
des.init(Cipher.ENCRYPT_MODE, lowKey);
final byte[] lowHash = des.doFinal(magicConstant);
@@ -941,7 +940,7 @@ final class NTLMEngineImpl implements NTLMEngine {
} else {
resp = messageContents;
}
- return EncodingUtils.getAsciiString(Base64.encodeBase64(resp));
+ return new String(Base64.encodeBase64(resp), StandardCharsets.US_ASCII);
}
}
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java
index 46740b2a1..e32d2e653 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java
@@ -28,9 +28,11 @@ package org.apache.http.impl.auth;
import java.security.Principal;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthScope;
@@ -39,8 +41,6 @@ import org.apache.http.auth.Credentials;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.auth.NTCredentials;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
/**
* NTLM is a proprietary authentication scheme developed by Microsoft
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMSchemeFactory.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMSchemeFactory.java
index 5ca7f3217..1ddb515e9 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMSchemeFactory.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMSchemeFactory.java
@@ -27,10 +27,10 @@
package org.apache.http.impl.auth;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.protocol.HttpContext;
/**
* {@link AuthSchemeProvider} implementation that creates and initializes
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java
index edf626c0c..fa606ff1a 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoScheme.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.auth;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
import org.ietf.jgss.GSSException;
import org.ietf.jgss.Oid;
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoSchemeFactory.java b/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoSchemeFactory.java
index 99c81b0ce..36b9aee02 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoSchemeFactory.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/SPNegoSchemeFactory.java
@@ -26,10 +26,10 @@
*/
package org.apache.http.impl.auth;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.protocol.HttpContext;
/**
* {@link AuthSchemeProvider} implementation that creates and initializes
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java b/httpclient/src/main/java/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java
index 2d6b6ec84..cc754dca8 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.auth;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Authentication credentials required to respond to a authentication
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java b/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java
index dbf6275a6..796b5685f 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java
@@ -29,10 +29,10 @@ package org.apache.http.impl.client;
import java.util.HashMap;
import java.util.Map;
+import org.apache.hc.core5.pool.ConnPoolControl;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.BackoffManager;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.pool.ConnPoolControl;
-import org.apache.http.util.Args;
/**
* The {@code AIMDBackoffManager} applies an additive increase,
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/AbstractResponseHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/AbstractResponseHandler.java
index 290a88ce3..19fa385ea 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/AbstractResponseHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/AbstractResponseHandler.java
@@ -29,13 +29,13 @@ package org.apache.http.impl.client;
import java.io.IOException;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.StatusLine;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.StatusLine;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
-import org.apache.http.util.EntityUtils;
/**
* A generic {@link ResponseHandler} that works with the response entity
@@ -61,7 +61,7 @@ public abstract class AbstractResponseHandler implements ResponseHandler {
*/
@Override
public T handleResponse(final HttpResponse response)
- throws HttpResponseException, IOException {
+ throws IOException {
final StatusLine statusLine = response.getStatusLine();
final HttpEntity entity = response.getEntity();
if (statusLine.getStatusCode() >= 300) {
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java b/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
index 645d8579a..823d7a1da 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
@@ -37,14 +37,14 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthScheme;
import org.apache.http.client.AuthCache;
import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.UnsupportedSchemeException;
import org.apache.http.impl.conn.DefaultSchemePortResolver;
-import org.apache.http.util.Args;
/**
* Default implementation of {@link org.apache.http.client.AuthCache}. This implements
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java b/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
index 3514fecb8..8117fcc08 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
@@ -33,8 +33,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.TreeSet;
-import org.apache.http.annotation.GuardedBy;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.GuardedBy;
+import org.apache.hc.core5.annotation.ThreadSafe;
import org.apache.http.client.CookieStore;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieIdentityComparator;
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java b/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
index a2e0d4d2a..7cfff3310 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
@@ -29,11 +29,11 @@ package org.apache.http.impl.client;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.client.CredentialsStore;
-import org.apache.http.util.Args;
/**
* Default implementation of {@link CredentialsStore}.
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/BasicResponseHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/BasicResponseHandler.java
index 76766ea7e..0e6b93acf 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/BasicResponseHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/BasicResponseHandler.java
@@ -29,11 +29,12 @@ package org.apache.http.impl.client;
import java.io.IOException;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.HttpResponseException;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.http.client.ClientProtocolException;
/**
* A {@link org.apache.http.client.ResponseHandler} that returns the response body as a String
@@ -56,12 +57,16 @@ public class BasicResponseHandler extends AbstractResponseHandler {
*/
@Override
public String handleEntity(final HttpEntity entity) throws IOException {
- return EntityUtils.toString(entity);
+ try {
+ return EntityUtils.toString(entity);
+ } catch (ParseException ex) {
+ throw new ClientProtocolException(ex);
+ }
}
@Override
public String handleResponse(
- final HttpResponse response) throws HttpResponseException, IOException {
+ final HttpResponse response) throws IOException {
return super.handleResponse(response);
}
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java
index 16dfae215..3b24fe4ea 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java
@@ -33,19 +33,19 @@ import java.net.URI;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.utils.URIUtils;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.EntityUtils;
/**
* Base implementation of {@link HttpClient} that also implements {@link Closeable}.
@@ -58,7 +58,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
private final Log log = LogFactory.getLog(getClass());
protected abstract CloseableHttpResponse doExecute(HttpHost target, HttpRequest request,
- HttpContext context) throws IOException, ClientProtocolException;
+ HttpContext context) throws IOException;
/**
* {@inheritDoc}
@@ -67,7 +67,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
public CloseableHttpResponse execute(
final HttpHost target,
final HttpRequest request,
- final HttpContext context) throws IOException, ClientProtocolException {
+ final HttpContext context) throws IOException {
return doExecute(target, request, context);
}
@@ -77,7 +77,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
@Override
public CloseableHttpResponse execute(
final HttpUriRequest request,
- final HttpContext context) throws IOException, ClientProtocolException {
+ final HttpContext context) throws IOException {
Args.notNull(request, "HTTP request");
return doExecute(determineTarget(request), request, context);
}
@@ -103,7 +103,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
*/
@Override
public CloseableHttpResponse execute(
- final HttpUriRequest request) throws IOException, ClientProtocolException {
+ final HttpUriRequest request) throws IOException {
return execute(request, (HttpContext) null);
}
@@ -113,7 +113,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
@Override
public CloseableHttpResponse execute(
final HttpHost target,
- final HttpRequest request) throws IOException, ClientProtocolException {
+ final HttpRequest request) throws IOException {
return doExecute(target, request, null);
}
@@ -134,8 +134,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
*/
@Override
public T execute(final HttpUriRequest request,
- final ResponseHandler extends T> responseHandler) throws IOException,
- ClientProtocolException {
+ final ResponseHandler extends T> responseHandler) throws IOException {
return execute(request, responseHandler, null);
}
@@ -159,7 +158,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
@Override
public T execute(final HttpUriRequest request,
final ResponseHandler extends T> responseHandler, final HttpContext context)
- throws IOException, ClientProtocolException {
+ throws IOException {
final HttpHost target = determineTarget(request);
return execute(target, request, responseHandler, context);
}
@@ -185,8 +184,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
*/
@Override
public T execute(final HttpHost target, final HttpRequest request,
- final ResponseHandler extends T> responseHandler) throws IOException,
- ClientProtocolException {
+ final ResponseHandler extends T> responseHandler) throws IOException {
return execute(target, request, responseHandler, null);
}
@@ -214,7 +212,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
@Override
public T execute(final HttpHost target, final HttpRequest request,
final ResponseHandler extends T> responseHandler, final HttpContext context)
- throws IOException, ClientProtocolException {
+ throws IOException {
Args.notNull(responseHandler, "Response handler");
final CloseableHttpResponse response = execute(target, request, context);
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/CookieSpecRegistries.java b/httpclient/src/main/java/org/apache/http/impl/client/CookieSpecRegistries.java
index c437eb36c..d9bc3e1ff 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/CookieSpecRegistries.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/CookieSpecRegistries.java
@@ -27,9 +27,9 @@
package org.apache.http.impl.client;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.http.client.config.CookieSpecs;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.util.PublicSuffixMatcher;
import org.apache.http.conn.util.PublicSuffixMatcherLoader;
import org.apache.http.cookie.CookieSpecProvider;
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultAuthenticationStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultAuthenticationStrategy.java
index eb5b9d753..9869c14e9 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultAuthenticationStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultAuthenticationStrategy.java
@@ -37,7 +37,10 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
@@ -46,9 +49,6 @@ import org.apache.http.client.AuthenticationStrategy;
import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Lookup;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
/**
* Default implementation of {@link AuthenticationStrategy}
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultBackoffStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultBackoffStrategy.java
index 7a838af8d..396a83bbb 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultBackoffStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultBackoffStrategy.java
@@ -29,8 +29,8 @@ package org.apache.http.impl.client;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
import org.apache.http.client.ConnectionBackoffStrategy;
/**
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java
index 6e757d1ee..fd9673d74 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java
@@ -26,15 +26,16 @@
*/
package org.apache.http.impl.client;
-import org.apache.http.HeaderElement;
-import org.apache.http.HeaderElementIterator;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.Immutable;
+import java.util.Iterator;
+
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.message.BasicHeaderElementIterator;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
-import org.apache.http.message.BasicHeaderElementIterator;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
/**
* Default implementation of a strategy deciding duration
@@ -53,10 +54,10 @@ public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveSt
@Override
public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
Args.notNull(response, "HTTP response");
- final HeaderElementIterator it = new BasicHeaderElementIterator(
- response.headerIterator(HTTP.CONN_KEEP_ALIVE));
+ final Iterator it = new BasicHeaderElementIterator(
+ response.headerIterator(HeaderElements.KEEP_ALIVE));
while (it.hasNext()) {
- final HeaderElement he = it.nextElement();
+ final HeaderElement he = it.next();
final String param = he.getName();
final String value = he.getValue();
if (value != null && param.equalsIgnoreCase("timeout")) {
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
index 799df2efc..326120128 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
@@ -41,12 +41,12 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.net.ssl.SSLException;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
/**
* The default {@link HttpRequestRetryHandler} used by request executors.
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
index 67c6af909..b86b7847d 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
@@ -33,15 +33,19 @@ import java.util.Locale;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.Asserts;
+import org.apache.hc.core5.util.TextUtils;
import org.apache.http.client.CircularRedirectException;
import org.apache.http.client.RedirectStrategy;
import org.apache.http.client.config.RequestConfig;
@@ -51,10 +55,6 @@ import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.client.utils.URIUtils;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.Asserts;
-import org.apache.http.util.TextUtils;
/**
* Default implementation of {@link RedirectStrategy}. This strategy honors the restrictions
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java
index 6a4c8013c..39f78f1bc 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java
@@ -29,15 +29,15 @@ package org.apache.http.impl.client;
import java.util.Date;
-import org.apache.http.Header;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.ServiceUnavailableRetryStrategy;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
/**
* Default implementation of the {@link ServiceUnavailableRetryStrategy} interface.
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
index ee6e1e6c4..a4e2e786d 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
@@ -30,15 +30,15 @@ import java.security.Principal;
import javax.net.ssl.SSLSession;
-import org.apache.http.HttpConnection;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpConnection;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.AuthScheme;
import org.apache.http.client.UserTokenHandler;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.ManagedHttpClientConnection;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.protocol.HttpContext;
/**
* Default implementation of {@link UserTokenHandler}. This class will use
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java b/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java
index b81a5df24..b71920d4e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java
@@ -31,12 +31,12 @@ import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.concurrent.FutureCallback;
-import org.apache.http.protocol.HttpContext;
/**
* HttpAsyncClientWithFuture wraps calls to execute with a {@link HttpRequestFutureTask}
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
index 1e4dd603e..bb857041b 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
@@ -42,12 +42,30 @@ import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.ConnectionReuseStrategy;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.config.SocketConfig;
+import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessorBuilder;
+import org.apache.hc.core5.http.protocol.ImmutableHttpProcessor;
+import org.apache.hc.core5.http.protocol.RequestContent;
+import org.apache.hc.core5.http.protocol.RequestTargetHost;
+import org.apache.hc.core5.http.protocol.RequestUserAgent;
+import org.apache.hc.core5.ssl.SSLContexts;
+import org.apache.hc.core5.util.TextUtils;
+import org.apache.hc.core5.util.VersionInfo;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.client.AuthenticationStrategy;
@@ -69,10 +87,6 @@ import org.apache.http.client.protocol.RequestDefaultHeaders;
import org.apache.http.client.protocol.RequestExpectContinue;
import org.apache.http.client.protocol.ResponseContentEncoding;
import org.apache.http.client.protocol.ResponseProcessCookies;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.config.SocketConfig;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.SchemePortResolver;
@@ -85,8 +99,6 @@ import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.util.PublicSuffixMatcher;
import org.apache.http.conn.util.PublicSuffixMatcherLoader;
import org.apache.http.cookie.CookieSpecProvider;
-import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.NoConnectionReuseStrategy;
import org.apache.http.impl.auth.BasicSchemeFactory;
import org.apache.http.impl.auth.DigestSchemeFactory;
import org.apache.http.impl.auth.KerberosSchemeFactory;
@@ -104,16 +116,6 @@ import org.apache.http.impl.execchain.ProtocolExec;
import org.apache.http.impl.execchain.RedirectExec;
import org.apache.http.impl.execchain.RetryExec;
import org.apache.http.impl.execchain.ServiceUnavailableRetryExec;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpProcessorBuilder;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.RequestContent;
-import org.apache.http.protocol.RequestTargetHost;
-import org.apache.http.protocol.RequestUserAgent;
-import org.apache.http.ssl.SSLContexts;
-import org.apache.http.util.TextUtils;
-import org.apache.http.util.VersionInfo;
/**
* Builder for {@link CloseableHttpClient} instances.
@@ -448,7 +450,7 @@ public class HttpClientBuilder {
* Assigns {@code User-Agent} value.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
+ * org.apache.hc.core5.http.protocol.HttpProcessor)} method.
*
*/
public final HttpClientBuilder setUserAgent(final String userAgent) {
@@ -460,7 +462,7 @@ public class HttpClientBuilder {
* Assigns default request header values.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
+ * org.apache.hc.core5.http.protocol.HttpProcessor)} method.
*
*/
public final HttpClientBuilder setDefaultHeaders(final Collection extends Header> defaultHeaders) {
@@ -472,7 +474,7 @@ public class HttpClientBuilder {
* Adds this protocol interceptor to the head of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
+ * org.apache.hc.core5.http.protocol.HttpProcessor)} method.
*
*/
public final HttpClientBuilder addInterceptorFirst(final HttpResponseInterceptor itcp) {
@@ -490,7 +492,7 @@ public class HttpClientBuilder {
* Adds this protocol interceptor to the tail of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
+ * org.apache.hc.core5.http.protocol.HttpProcessor)} method.
*
*/
public final HttpClientBuilder addInterceptorLast(final HttpResponseInterceptor itcp) {
@@ -508,7 +510,7 @@ public class HttpClientBuilder {
* Adds this protocol interceptor to the head of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
+ * org.apache.hc.core5.http.protocol.HttpProcessor)} method.
*/
public final HttpClientBuilder addInterceptorFirst(final HttpRequestInterceptor itcp) {
if (itcp == null) {
@@ -525,7 +527,7 @@ public class HttpClientBuilder {
* Adds this protocol interceptor to the tail of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
+ * org.apache.hc.core5.http.protocol.HttpProcessor)} method.
*/
public final HttpClientBuilder addInterceptorLast(final HttpRequestInterceptor itcp) {
if (itcp == null) {
@@ -542,7 +544,7 @@ public class HttpClientBuilder {
* Disables state (cookie) management.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
+ * org.apache.hc.core5.http.protocol.HttpProcessor)} method.
*/
public final HttpClientBuilder disableCookieManagement() {
this.cookieManagementDisabled = true;
@@ -553,7 +555,7 @@ public class HttpClientBuilder {
* Disables automatic content decompression.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
+ * org.apache.hc.core5.http.protocol.HttpProcessor)} method.
*/
public final HttpClientBuilder disableContentCompression() {
contentCompressionDisabled = true;
@@ -564,7 +566,7 @@ public class HttpClientBuilder {
* Disables authentication scheme caching.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
+ * org.apache.hc.core5.http.protocol.HttpProcessor)} method.
*/
public final HttpClientBuilder disableAuthCaching() {
this.authCachingDisabled = true;
@@ -937,7 +939,13 @@ public class HttpClientBuilder {
if ("true".equalsIgnoreCase(s)) {
reuseStrategyCopy = DefaultConnectionReuseStrategy.INSTANCE;
} else {
- reuseStrategyCopy = NoConnectionReuseStrategy.INSTANCE;
+ reuseStrategyCopy = new ConnectionReuseStrategy() {
+ @Override
+ public boolean keepAlive(
+ final HttpRequest request, final HttpResponse response, final HttpContext context) {
+ return false;
+ }
+ };
}
} else {
reuseStrategyCopy = DefaultConnectionReuseStrategy.INSTANCE;
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java
index 569b047a6..b802a8309 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpClients.java
@@ -27,7 +27,7 @@
package org.apache.http.impl.client;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
index 47fb23803..2be0f9151 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
@@ -29,11 +29,11 @@ package org.apache.http.impl.client;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.concurrent.FutureCallback;
-import org.apache.http.protocol.HttpContext;
class HttpRequestTaskCallable implements Callable {
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java b/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java
index c871a4d6d..0002e51c7 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java
@@ -30,8 +30,8 @@ package org.apache.http.impl.client;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
+import org.apache.hc.core5.util.Args;
import org.apache.http.conn.HttpClientConnectionManager;
-import org.apache.http.util.Args;
/**
* This class maintains a background thread to enforce an eviction policy for expired / idle
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
index b2b6cbdbe..1639b0399 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
@@ -33,10 +33,14 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.client.ClientProtocolException;
@@ -47,15 +51,11 @@ import org.apache.http.client.methods.Configurable;
import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Lookup;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.cookie.CookieSpecProvider;
import org.apache.http.impl.execchain.ClientExecChain;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
/**
* Internal class.
@@ -131,7 +131,7 @@ class InternalHttpClient extends CloseableHttpClient implements Configurable {
protected CloseableHttpResponse doExecute(
final HttpHost target,
final HttpRequest request,
- final HttpContext context) throws IOException, ClientProtocolException {
+ final HttpContext context) throws IOException {
Args.notNull(request, "HTTP request");
HttpExecutionAware execAware = null;
if (request instanceof HttpExecutionAware) {
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
index d6a7e7550..39ac585a7 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
@@ -29,10 +29,15 @@ package org.apache.http.impl.client;
import java.io.IOException;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -42,12 +47,7 @@ import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.impl.execchain.MinimalClientExec;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.util.Args;
/**
* Internal class.
@@ -75,7 +75,7 @@ class MinimalHttpClient extends CloseableHttpClient {
protected CloseableHttpResponse doExecute(
final HttpHost target,
final HttpRequest request,
- final HttpContext context) throws IOException, ClientProtocolException {
+ final HttpContext context) throws IOException {
Args.notNull(target, "Target host");
Args.notNull(request, "HTTP request");
HttpExecutionAware execAware = null;
@@ -83,7 +83,7 @@ class MinimalHttpClient extends CloseableHttpClient {
execAware = (HttpExecutionAware) request;
}
try {
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(request);
+ final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(request, target);
final HttpClientContext localcontext = HttpClientContext.adapt(
context != null ? context : new BasicHttpContext());
final HttpRoute route = new HttpRoute(target);
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/NoopUserTokenHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/NoopUserTokenHandler.java
index 2ee74d5e6..54f180811 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/NoopUserTokenHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/NoopUserTokenHandler.java
@@ -26,10 +26,10 @@
*/
package org.apache.http.impl.client;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.UserTokenHandler;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.protocol.HttpContext;
/**
* Noop implementation of {@link UserTokenHandler} that always returns {@code null}.
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/NullBackoffStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/NullBackoffStrategy.java
index 0b0b2fc0d..c1042ab41 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/NullBackoffStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/NullBackoffStrategy.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.client;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponse;
import org.apache.http.client.ConnectionBackoffStrategy;
/**
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java b/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java
index 925665339..c11478dca 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java
@@ -30,14 +30,30 @@ package org.apache.http.impl.client;
import java.io.IOException;
import java.net.Socket;
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.ConnectionReuseStrategy;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.entity.BufferedHttpEntity;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ImmutableHttpProcessor;
+import org.apache.hc.core5.http.protocol.RequestTargetHost;
+import org.apache.hc.core5.http.protocol.RequestUserAgent;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.auth.AuthScope;
@@ -48,16 +64,11 @@ import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.protocol.RequestClientConnControl;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.HttpConnectionFactory;
import org.apache.http.conn.ManagedHttpClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.RouteInfo.LayerType;
import org.apache.http.conn.routing.RouteInfo.TunnelType;
-import org.apache.http.entity.BufferedHttpEntity;
-import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.impl.auth.BasicSchemeFactory;
import org.apache.http.impl.auth.DigestSchemeFactory;
import org.apache.http.impl.auth.HttpAuthenticator;
@@ -66,17 +77,6 @@ import org.apache.http.impl.auth.NTLMSchemeFactory;
import org.apache.http.impl.auth.SPNegoSchemeFactory;
import org.apache.http.impl.conn.ManagedHttpClientConnectionFactory;
import org.apache.http.impl.execchain.TunnelRefusedException;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpCoreContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.RequestTargetHost;
-import org.apache.http.protocol.RequestUserAgent;
-import org.apache.http.util.Args;
-import org.apache.http.util.EntityUtils;
/**
* ProxyClient can be used to establish a tunnel via an HTTP proxy.
@@ -189,7 +189,7 @@ public class ProxyClient {
if (this.authenticator.prepareAuthResponse(proxy, ChallengeType.PROXY, response,
this.proxyAuthStrategy, this.proxyAuthExchange, context)) {
// Retry request
- if (this.reuseStrategy.keepAlive(response, context)) {
+ if (this.reuseStrategy.keepAlive(connect, response, context)) {
// Consume response content
final HttpEntity entity = response.getEntity();
EntityUtils.consume(entity);
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java b/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java
index ae3b6659f..96c6d7708 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java
@@ -35,7 +35,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
/**
* This class represents a collection of {@link java.net.URI}s used
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
index 5c6a00727..883865b07 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
@@ -32,15 +32,15 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.NTCredentials;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsStore;
import org.apache.http.client.config.AuthSchemes;
-import org.apache.http.util.Args;
/**
* Implementation of {@link CredentialsStore} backed by standard
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
index 92ca64461..484990702 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
@@ -36,30 +36,30 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.GuardedBy;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.config.SocketConfig;
+import org.apache.hc.core5.annotation.GuardedBy;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.config.SocketConfig;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.Asserts;
+import org.apache.hc.core5.util.LangUtils;
import org.apache.http.conn.ConnectionRequest;
import org.apache.http.conn.DnsResolver;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.HttpClientConnectionOperator;
import org.apache.http.conn.HttpConnectionFactory;
-import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.ManagedHttpClientConnection;
+import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.Asserts;
-import org.apache.http.util.LangUtils;
/**
* A connection manager for a single connection. This connection manager maintains only one active
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
index 00238e9d9..b2d2509a6 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
@@ -31,11 +31,11 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.pool.io.AbstractConnPool;
+import org.apache.hc.core5.pool.io.ConnFactory;
import org.apache.http.conn.ManagedHttpClientConnection;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.pool.AbstractConnPool;
-import org.apache.http.pool.ConnFactory;
/**
* @since 4.3
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
index 71f918393..a2a653452 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
@@ -31,11 +31,11 @@ import java.util.Date;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.pool.PoolEntry;
import org.apache.http.conn.ManagedHttpClientConnection;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.pool.PoolEntry;
/**
* @since 4.3
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
index 27b7f8766..f65f4c4b6 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
@@ -27,20 +27,19 @@
package org.apache.http.impl.conn;
import java.io.IOException;
-import java.net.InetAddress;
import java.net.Socket;
+import java.net.SocketAddress;
import javax.net.ssl.SSLSession;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpConnectionMetrics;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpConnectionMetrics;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.conn.ManagedHttpClientConnection;
-import org.apache.http.protocol.HttpContext;
/**
* @since 4.3
@@ -148,8 +147,18 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
}
@Override
- public boolean isResponseAvailable(final int timeout) throws IOException {
- return getValidConnection().isResponseAvailable(timeout);
+ public boolean isConsistent() {
+ return getValidConnection().isConsistent();
+ }
+
+ @Override
+ public void terminateRequest(final HttpRequest request) throws HttpException, IOException {
+ getValidConnection().terminateRequest(request);
+ }
+
+ @Override
+ public boolean isDataAvailable(final int timeout) throws IOException {
+ return getValidConnection().isDataAvailable(timeout);
}
@Override
@@ -158,7 +167,7 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
}
@Override
- public void sendRequestEntity(final HttpEntityEnclosingRequest request) throws HttpException, IOException {
+ public void sendRequestEntity(final HttpRequest request) throws HttpException, IOException {
getValidConnection().sendRequestEntity(request);
}
@@ -183,25 +192,15 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
}
@Override
- public InetAddress getLocalAddress() {
+ public SocketAddress getLocalAddress() {
return getValidConnection().getLocalAddress();
}
@Override
- public int getLocalPort() {
- return getValidConnection().getLocalPort();
- }
-
- @Override
- public InetAddress getRemoteAddress() {
+ public SocketAddress getRemoteAddress() {
return getValidConnection().getRemoteAddress();
}
- @Override
- public int getRemotePort() {
- return getValidConnection().getRemotePort();
- }
-
@Override
public Object getAttribute(final String id) {
final ManagedHttpClientConnection conn = getValidConnection();
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java b/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java
index b0b6bb6ae..97a473908 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/ConnectionShutdownException.java
@@ -27,7 +27,7 @@
package org.apache.http.impl.conn;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Signals that the connection has been shut down or released back to the
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
index 582136408..628c7ffcd 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
@@ -36,11 +36,13 @@ import java.net.SocketTimeoutException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.SocketConfig;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.SocketConfig;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.DnsResolver;
import org.apache.http.conn.HttpClientConnectionOperator;
@@ -50,8 +52,6 @@ import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.UnsupportedSchemeException;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
/**
* Default implementation of {@link HttpClientConnectionOperator} used as default in Http client,
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java
deleted file mode 100644
index b11c5d187..000000000
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseFactory;
-import org.apache.http.NoHttpResponseException;
-import org.apache.http.ProtocolException;
-import org.apache.http.StatusLine;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.config.MessageConstraints;
-import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.impl.io.AbstractMessageParser;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.message.LineParser;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.util.CharArrayBuffer;
-
-/**
- * Lenient HTTP response parser implementation that can skip malformed data until
- * a valid HTTP response message head is encountered.
- *
- * @since 4.2
- */
-@NotThreadSafe
-public class DefaultHttpResponseParser extends AbstractMessageParser {
-
- private final Log log = LogFactory.getLog(getClass());
-
- private final HttpResponseFactory responseFactory;
- private final CharArrayBuffer lineBuf;
-
- /**
- * Creates new instance of DefaultHttpResponseParser.
- *
- * @param buffer the session input buffer.
- * @param lineParser the line parser. If {@code null}
- * {@link org.apache.http.message.BasicLineParser#INSTANCE} will be used.
- * @param responseFactory HTTP response factory. If {@code null}
- * {@link DefaultHttpResponseFactory#INSTANCE} will be used.
- * @param constraints the message constraints. If {@code null}
- * {@link MessageConstraints#DEFAULT} will be used.
- *
- * @since 4.3
- */
- public DefaultHttpResponseParser(
- final SessionInputBuffer buffer,
- final LineParser lineParser,
- final HttpResponseFactory responseFactory,
- final MessageConstraints constraints) {
- super(buffer, lineParser, constraints);
- this.responseFactory = responseFactory != null ? responseFactory :
- DefaultHttpResponseFactory.INSTANCE;
- this.lineBuf = new CharArrayBuffer(128);
- }
-
- /**
- * Creates new instance of DefaultHttpResponseParser.
- *
- * @param buffer the session input buffer.
- * @param constraints the message constraints. If {@code null}
- * {@link MessageConstraints#DEFAULT} will be used.
- *
- * @since 4.3
- */
- public DefaultHttpResponseParser(
- final SessionInputBuffer buffer, final MessageConstraints constraints) {
- this(buffer, null, null, constraints);
- }
-
- /**
- * Creates new instance of DefaultHttpResponseParser.
- *
- * @param buffer the session input buffer.
- *
- * @since 4.3
- */
- public DefaultHttpResponseParser(final SessionInputBuffer buffer) {
- this(buffer, null, null, MessageConstraints.DEFAULT);
- }
-
- @Override
- protected HttpResponse parseHead(
- final SessionInputBuffer sessionBuffer) throws IOException, HttpException {
- //read out the HTTP status string
- int count = 0;
- ParserCursor cursor = null;
- do {
- // clear the buffer
- this.lineBuf.clear();
- final int i = sessionBuffer.readLine(this.lineBuf);
- if (i == -1 && count == 0) {
- // The server just dropped connection on us
- throw new NoHttpResponseException("The target server failed to respond");
- }
- cursor = new ParserCursor(0, this.lineBuf.length());
- if (lineParser.hasProtocolVersion(this.lineBuf, cursor)) {
- // Got one
- break;
- } else if (i == -1 || reject(this.lineBuf, count)) {
- // Giving up
- throw new ProtocolException("The server failed to respond with a " +
- "valid HTTP response");
- }
- if (this.log.isDebugEnabled()) {
- this.log.debug("Garbage in response: " + this.lineBuf.toString());
- }
- count++;
- } while(true);
- //create the status line from the status string
- final StatusLine statusline = lineParser.parseStatusLine(this.lineBuf, cursor);
- return this.responseFactory.newHttpResponse(statusline, null);
- }
-
- protected boolean reject(final CharArrayBuffer line, final int count) {
- return false;
- }
-
-}
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParserFactory.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParserFactory.java
index f5c0af01f..cd2749e80 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParserFactory.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParserFactory.java
@@ -27,16 +27,15 @@
package org.apache.http.impl.conn;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseFactory;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.config.MessageConstraints;
-import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.io.HttpMessageParser;
-import org.apache.http.io.HttpMessageParserFactory;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.message.BasicLineParser;
-import org.apache.http.message.LineParser;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseFactory;
+import org.apache.hc.core5.http.config.MessageConstraints;
+import org.apache.hc.core5.http.impl.DefaultHttpResponseFactory;
+import org.apache.hc.core5.http.io.HttpMessageParser;
+import org.apache.hc.core5.http.io.HttpMessageParserFactory;
+import org.apache.hc.core5.http.message.BasicLineParser;
+import org.apache.hc.core5.http.message.LineParser;
/**
* Default factory for response message parsers.
@@ -56,12 +55,10 @@ public class DefaultHttpResponseParserFactory implements HttpMessageParserFactor
final HttpResponseFactory responseFactory) {
super();
this.lineParser = lineParser != null ? lineParser : BasicLineParser.INSTANCE;
- this.responseFactory = responseFactory != null ? responseFactory
- : DefaultHttpResponseFactory.INSTANCE;
+ this.responseFactory = responseFactory != null ? responseFactory : DefaultHttpResponseFactory.INSTANCE;
}
- public DefaultHttpResponseParserFactory(
- final HttpResponseFactory responseFactory) {
+ public DefaultHttpResponseParserFactory(final HttpResponseFactory responseFactory) {
this(null, responseFactory);
}
@@ -70,9 +67,8 @@ public class DefaultHttpResponseParserFactory implements HttpMessageParserFactor
}
@Override
- public HttpMessageParser create(final SessionInputBuffer buffer,
- final MessageConstraints constraints) {
- return new DefaultHttpResponseParser(buffer, lineParser, responseFactory, constraints);
+ public HttpMessageParser create(final MessageConstraints constraints) {
+ return new LenientHttpResponseParser(this.lineParser, this.responseFactory, constraints);
}
}
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
index 8b2d8148b..9881ea1ec 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
@@ -34,20 +34,21 @@ import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.config.MessageConstraints;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.ContentLengthStrategy;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.config.MessageConstraints;
+import org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection;
+import org.apache.hc.core5.http.io.HttpMessageParserFactory;
+import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.conn.ManagedHttpClientConnection;
-import org.apache.http.entity.ContentLengthStrategy;
-import org.apache.http.impl.DefaultBHttpClientConnection;
-import org.apache.http.io.HttpMessageParserFactory;
-import org.apache.http.io.HttpMessageWriterFactory;
-import org.apache.http.protocol.HttpContext;
/**
* Default {@link ManagedHttpClientConnection} implementation.
@@ -59,6 +60,7 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
private final String id;
private final Map attributes;
+ private final AtomicReference socketHolder;
private volatile boolean shutdown;
@@ -78,6 +80,7 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
requestWriterFactory, responseParserFactory);
this.id = id;
this.attributes = new ConcurrentHashMap<>();
+ this.socketHolder = new AtomicReference<>(null);
}
public DefaultManagedHttpClientConnection(
@@ -119,17 +122,19 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
// ...but if it doesn't, explicitly throw one ourselves.
throw new InterruptedIOException("Connection already shutdown");
}
- super.bind(socket);
+ if (!this.socketHolder.compareAndSet(socket, socket)) {
+ super.bind(socket);
+ }
}
@Override
public Socket getSocket() {
- return super.getSocket();
+ return this.socketHolder.get();
}
@Override
public SSLSession getSSLSession() {
- final Socket socket = super.getSocket();
+ final Socket socket = this.socketHolder.get();
if (socket instanceof SSLSocket) {
return ((SSLSocket) socket).getSession();
} else {
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java
index 376654a06..7dc2a67aa 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java
@@ -27,13 +27,13 @@
package org.apache.http.impl.conn;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.conn.SchemePortResolver;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
/**
* Implementation of an {@link org.apache.http.conn.routing.HttpRoutePlanner}
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
index b56d2f8ed..d58d24389 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
@@ -29,19 +29,19 @@ package org.apache.http.impl.conn;
import java.net.InetAddress;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.UnsupportedSchemeException;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRoutePlanner;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
/**
* Default implementation of an {@link HttpRoutePlanner}. It will not make use of
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultSchemePortResolver.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultSchemePortResolver.java
index c5d54ed9f..a601cea6b 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultSchemePortResolver.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultSchemePortResolver.java
@@ -26,11 +26,11 @@
*/
package org.apache.http.impl.conn;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.util.Args;
import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.UnsupportedSchemeException;
-import org.apache.http.util.Args;
/**
* Default {@link SchemePortResolver}.
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java b/httpclient/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java
index 8d6938ba6..9516d5e2e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java
@@ -34,8 +34,8 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.hc.core5.util.Args;
import org.apache.http.conn.DnsResolver;
-import org.apache.http.util.Args;
/**
* In-memory {@link DnsResolver} implementation.
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/LenientHttpResponseParser.java b/httpclient/src/main/java/org/apache/http/impl/conn/LenientHttpResponseParser.java
new file mode 100644
index 000000000..bd3c6f231
--- /dev/null
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/LenientHttpResponseParser.java
@@ -0,0 +1,95 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+
+package org.apache.http.impl.conn;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseFactory;
+import org.apache.hc.core5.http.config.MessageConstraints;
+import org.apache.hc.core5.http.impl.io.DefaultHttpResponseParser;
+import org.apache.hc.core5.http.message.LineParser;
+import org.apache.hc.core5.util.CharArrayBuffer;
+
+/**
+ * Lenient HTTP response parser implementation that can skip malformed data until
+ * a valid HTTP response message head is encountered.
+ *
+ * @since 4.2
+ */
+@NotThreadSafe
+public class LenientHttpResponseParser extends DefaultHttpResponseParser {
+
+ private final Log log = LogFactory.getLog(getClass());
+
+ /**
+ * Creates new instance of DefaultHttpResponseParser.
+ *
+ * @param lineParser the line parser. If {@code null}
+ * {@link org.apache.hc.core5.http.message.BasicLineParser#INSTANCE} will be used.
+ * @param responseFactory HTTP response factory. If {@code null}
+ * {@link org.apache.hc.core5.http.impl.DefaultHttpResponseFactory#INSTANCE} will be used.
+ * @param constraints the message constraints. If {@code null}
+ * {@link MessageConstraints#DEFAULT} will be used.
+ * @since 4.3
+ */
+ public LenientHttpResponseParser(
+ final LineParser lineParser,
+ final HttpResponseFactory responseFactory,
+ final MessageConstraints constraints) {
+ super(lineParser, responseFactory, constraints);
+ }
+
+ /**
+ * Creates new instance of DefaultHttpResponseParser.
+ *
+ * @param constraints the message constraints. If {@code null}
+ * {@link MessageConstraints#DEFAULT} will be used.
+ * @since 4.3
+ */
+ public LenientHttpResponseParser(final MessageConstraints constraints) {
+ this(null, null, constraints);
+ }
+
+ @Override
+ protected HttpResponse createMessage(final CharArrayBuffer buffer) throws IOException {
+ try {
+ return super.createMessage(buffer);
+ } catch (HttpException ex) {
+ if (this.log.isDebugEnabled()) {
+ this.log.debug("Garbage in response: " + buffer.toString());
+ }
+ return null;
+ }
+ }
+
+}
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java
index d42a18329..08d82e30f 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java
@@ -27,11 +27,11 @@
package org.apache.http.impl.conn;
-import org.apache.http.annotation.NotThreadSafe;
-
import java.io.IOException;
import java.io.InputStream;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+
/**
* Internal class.
*
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
index 2614b0c9b..ca3b1afcc 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
@@ -27,16 +27,6 @@
package org.apache.http.impl.conn;
-import org.apache.commons.logging.Log;
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.config.MessageConstraints;
-import org.apache.http.entity.ContentLengthStrategy;
-import org.apache.http.io.HttpMessageParserFactory;
-import org.apache.http.io.HttpMessageWriterFactory;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -44,6 +34,16 @@ import java.net.Socket;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
+import org.apache.commons.logging.Log;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.ContentLengthStrategy;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.config.MessageConstraints;
+import org.apache.hc.core5.http.io.HttpMessageParserFactory;
+import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
+
@NotThreadSafe
class LoggingManagedHttpClientConnection extends DefaultManagedHttpClientConnection {
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java
index c70cb1700..b339ef608 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java
@@ -27,11 +27,11 @@
package org.apache.http.impl.conn;
-import org.apache.http.annotation.NotThreadSafe;
-
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+
/**
* Internal class.
*
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java b/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
index 2d7d521dc..5603d75d2 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
@@ -35,19 +35,18 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.config.ConnectionConfig;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.ContentLengthStrategy;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
+import org.apache.hc.core5.http.impl.io.DefaultHttpRequestWriterFactory;
+import org.apache.hc.core5.http.io.HttpMessageParserFactory;
+import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
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;
/**
* Factory for {@link ManagedHttpClientConnection} instances.
@@ -84,9 +83,9 @@ public class ManagedHttpClientConnectionFactory
this.responseParserFactory = responseParserFactory != null ? responseParserFactory :
DefaultHttpResponseParserFactory.INSTANCE;
this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
- LaxContentLengthStrategy.INSTANCE;
+ DefaultContentLengthStrategy.INSTANCE;
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
- StrictContentLengthStrategy.INSTANCE;
+ DefaultContentLengthStrategy.INSTANCE;
}
public ManagedHttpClientConnectionFactory(
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
index e77402398..8c001b113 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
@@ -40,32 +40,32 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.config.SocketConfig;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.config.SocketConfig;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.pool.ConnPoolControl;
+import org.apache.hc.core5.pool.PoolStats;
+import org.apache.hc.core5.pool.io.ConnFactory;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.Asserts;
import org.apache.http.conn.ConnectionPoolTimeoutException;
import org.apache.http.conn.ConnectionRequest;
import org.apache.http.conn.DnsResolver;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.HttpClientConnectionOperator;
import org.apache.http.conn.HttpConnectionFactory;
-import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.ManagedHttpClientConnection;
+import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.pool.ConnFactory;
-import org.apache.http.pool.ConnPoolControl;
-import org.apache.http.pool.PoolStats;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.Asserts;
/**
* {@code ClientConnectionPoolManager} maintains a pool of
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java
index 6b872b9eb..c21885ef2 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java
@@ -34,12 +34,12 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.conn.SchemePortResolver;
-import org.apache.http.protocol.HttpContext;
/**
* {@link org.apache.http.conn.routing.HttpRoutePlanner} implementation
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java b/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
index e3bffd33f..083990cc8 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
@@ -31,17 +31,16 @@ import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.logging.Log;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
/**
* Logs data to the wire LOG.
- * TODO: make package private. Should not be part of the public API.
*
* @since 4.0
*/
@Immutable
-public class Wire {
+class Wire {
private final Log log;
private final String id;
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieAttributeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieAttributeHandler.java
index ccf12dd5b..8efd631dd 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieAttributeHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieAttributeHandler.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.cookie;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieAttributeHandler;
import org.apache.http.cookie.CookieOrigin;
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java
index d7d6c6fb1..dbdae8dcc 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/AbstractCookieSpec.java
@@ -32,11 +32,11 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.util.Asserts;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.CookieAttributeHandler;
import org.apache.http.cookie.CookieSpec;
-import org.apache.http.util.Asserts;
/**
* Abstract cookie specification which can delegate the job of parsing,
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java
index e45ed151d..3178ca5e7 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java
@@ -33,10 +33,10 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.util.Args;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.SetCookie;
-import org.apache.http.util.Args;
/**
* Default implementation of {@link SetCookie}.
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
index c527cccf8..41a0f8813 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
@@ -28,7 +28,9 @@ package org.apache.http.impl.cookie;
import java.util.Locale;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.TextUtils;
import org.apache.http.conn.util.InetAddressUtils;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie;
@@ -36,8 +38,6 @@ import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.CookieRestrictionViolationException;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SetCookie;
-import org.apache.http.util.Args;
-import org.apache.http.util.TextUtils;
/**
*
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java
index a3efaf6ab..d6ffe4985 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicExpiresHandler.java
@@ -28,13 +28,13 @@ package org.apache.http.impl.cookie;
import java.util.Date;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.utils.DateUtils;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SetCookie;
-import org.apache.http.util.Args;
/**
*
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java
index 90f9f7807..511091456 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicMaxAgeHandler.java
@@ -28,12 +28,12 @@ package org.apache.http.impl.cookie;
import java.util.Date;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SetCookie;
-import org.apache.http.util.Args;
/**
*
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
index da695660b..3974b632c 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
@@ -26,15 +26,15 @@
*/
package org.apache.http.impl.cookie;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.TextUtils;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.CookieRestrictionViolationException;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SetCookie;
-import org.apache.http.util.Args;
-import org.apache.http.util.TextUtils;
/**
*
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java
index 3e9526a38..88a35e22f 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java
@@ -26,13 +26,13 @@
*/
package org.apache.http.impl.cookie;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SetCookie;
-import org.apache.http.util.Args;
/**
*
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java b/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
index ce8ab765a..f6377d04e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
@@ -32,15 +32,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
-import org.apache.http.HeaderElement;
-import org.apache.http.NameValuePair;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.util.Args;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieAttributeHandler;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.util.Args;
/**
* Cookie management functions shared by all specification.
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java
index 4ee92a341..a151e7fb4 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpec.java
@@ -30,8 +30,8 @@ package org.apache.http.impl.cookie;
import java.util.Collections;
import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.Header;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.MalformedCookieException;
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java b/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java
index 97bedf6d1..39207ee48 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/IgnoreSpecProvider.java
@@ -27,10 +27,10 @@
package org.apache.http.impl.cookie;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.cookie.CookieSpec;
import org.apache.http.cookie.CookieSpecProvider;
-import org.apache.http.protocol.HttpContext;
/**
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that ignores all cookies.
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java
index 2a265ef0f..4cb1c50e1 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java
@@ -35,13 +35,13 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.message.ParserCursor;
+import org.apache.hc.core5.util.Args;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SetCookie;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.util.Args;
/**
*
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxMaxAgeHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxMaxAgeHandler.java
index a920c24b5..42ffbbc1f 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxMaxAgeHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxMaxAgeHandler.java
@@ -30,13 +30,13 @@ import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.TextUtils;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SetCookie;
-import org.apache.http.util.Args;
-import org.apache.http.util.TextUtils;
/**
*
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java
index cf3dfe624..45df892ba 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java
@@ -29,7 +29,8 @@ package org.apache.http.impl.cookie;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.util.Args;
import org.apache.http.conn.util.PublicSuffixList;
import org.apache.http.conn.util.PublicSuffixMatcher;
import org.apache.http.cookie.CommonCookieAttributeHandler;
@@ -37,7 +38,6 @@ import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SetCookie;
-import org.apache.http.util.Args;
/**
* Wraps a {@link org.apache.http.cookie.CookieAttributeHandler} and leverages its match method
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java
index 604200802..d7f1c0793 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpec.java
@@ -37,9 +37,15 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.http.FormattedHeader;
-import org.apache.http.Header;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.FormattedHeader;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.message.BufferedHeader;
+import org.apache.hc.core5.http.message.ParserCursor;
+import org.apache.hc.core5.http.message.TokenParser;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.CharArrayBuffer;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieAttributeHandler;
@@ -47,11 +53,6 @@ import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.CookiePriorityComparator;
import org.apache.http.cookie.CookieSpec;
import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.message.BufferedHeader;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.message.TokenParser;
-import org.apache.http.util.Args;
-import org.apache.http.util.CharArrayBuffer;
/**
* Cookie management functions shared by RFC C6265 compliant specification.
@@ -244,7 +245,11 @@ public class RFC6265CookieSpec implements CookieSpec {
}
}
final List headers = new ArrayList<>(1);
- headers.add(new BufferedHeader(buffer));
+ try {
+ headers.add(new BufferedHeader(buffer));
+ } catch (ParseException ignore) {
+ // should never happen
+ }
return headers;
}
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpecProvider.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpecProvider.java
index e4f24dc17..6fc99e04f 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpecProvider.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265CookieSpecProvider.java
@@ -27,14 +27,14 @@
package org.apache.http.impl.cookie;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.conn.util.PublicSuffixMatcher;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.CookieSpec;
import org.apache.http.cookie.CookieSpecProvider;
import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.protocol.HttpContext;
/**
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265LaxSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265LaxSpec.java
index 8455c8342..5d896af39 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265LaxSpec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265LaxSpec.java
@@ -27,7 +27,7 @@
package org.apache.http.impl.cookie;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
import org.apache.http.cookie.CommonCookieAttributeHandler;
/**
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265StrictSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265StrictSpec.java
index 1765d276f..52d1432a2 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265StrictSpec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC6265StrictSpec.java
@@ -27,7 +27,7 @@
package org.apache.http.impl.cookie;
-import org.apache.http.annotation.ThreadSafe;
+import org.apache.hc.core5.annotation.ThreadSafe;
import org.apache.http.client.utils.DateUtils;
import org.apache.http.cookie.CommonCookieAttributeHandler;
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java
index 7c9025b5b..cdb1fc38a 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java
@@ -30,8 +30,9 @@ package org.apache.http.impl.execchain;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
-import org.apache.http.HttpException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.BackoffManager;
import org.apache.http.client.ConnectionBackoffStrategy;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -39,7 +40,6 @@ import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.util.Args;
/**
* @since 4.3
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ClientExecChain.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ClientExecChain.java
index 25cea9a87..88c29eca4 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/ClientExecChain.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ClientExecChain.java
@@ -29,7 +29,7 @@ package org.apache.http.impl.execchain;
import java.io.IOException;
-import org.apache.http.HttpException;
+import org.apache.hc.core5.http.HttpException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpRequestWrapper;
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
index 0f6e4f3e8..92cf63649 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
@@ -33,9 +33,9 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.logging.Log;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.concurrent.Cancellable;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.concurrent.Cancellable;
+import org.apache.hc.core5.http.io.HttpClientConnection;
import org.apache.http.conn.ConnectionReleaseTrigger;
import org.apache.http.conn.HttpClientConnectionManager;
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/HttpResponseProxy.java b/httpclient/src/main/java/org/apache/http/impl/execchain/HttpResponseProxy.java
index 0184ec250..71cd7e26d 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/HttpResponseProxy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/HttpResponseProxy.java
@@ -28,20 +28,19 @@
package org.apache.http.impl.execchain;
import java.io.IOException;
+import java.util.Iterator;
import java.util.Locale;
-import org.apache.http.Header;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.StatusLine;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.StatusLine;
import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.params.HttpParams;
/**
- * A proxy class for {@link org.apache.http.HttpResponse} that can be used to release client connection
+ * A proxy class for {@link org.apache.hc.core5.http.HttpResponse} that can be used to release client connection
* associated with the original response.
*
* @since 4.3
@@ -70,6 +69,11 @@ class HttpResponseProxy implements CloseableHttpResponse {
return original.getStatusLine();
}
+ @Override
+ public int getCode() {
+ return original.getCode();
+ }
+
@Override
public void setStatusLine(final StatusLine statusline) {
original.setStatusLine(statusline);
@@ -120,6 +124,11 @@ class HttpResponseProxy implements CloseableHttpResponse {
return original.getProtocolVersion();
}
+ @Override
+ public int containsHeaders(final String name) {
+ return original.containsHeaders(name);
+ }
+
@Override
public boolean containsHeader(final String name) {
return original.containsHeader(name);
@@ -151,7 +160,7 @@ class HttpResponseProxy implements CloseableHttpResponse {
}
@Override
- public void addHeader(final String name, final String value) {
+ public void addHeader(final String name, final Object value) {
original.addHeader(name, value);
}
@@ -161,7 +170,7 @@ class HttpResponseProxy implements CloseableHttpResponse {
}
@Override
- public void setHeader(final String name, final String value) {
+ public void setHeader(final String name, final Object value) {
original.setHeader(name, value);
}
@@ -181,27 +190,15 @@ class HttpResponseProxy implements CloseableHttpResponse {
}
@Override
- public HeaderIterator headerIterator() {
+ public Iterator headerIterator() {
return original.headerIterator();
}
@Override
- public HeaderIterator headerIterator(final String name) {
+ public Iterator headerIterator(final String name) {
return original.headerIterator(name);
}
- @Override
- @Deprecated
- public HttpParams getParams() {
- return original.getParams();
- }
-
- @Override
- @Deprecated
- public void setParams(final HttpParams params) {
- original.setParams(params);
- }
-
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("HttpResponseProxy{");
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
index 581da3d3b..89d1fae9e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
@@ -34,16 +34,24 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.ConnectionReuseStrategy;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.entity.BufferedHttpEntity;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ImmutableHttpProcessor;
+import org.apache.hc.core5.http.protocol.RequestTargetHost;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.ChallengeType;
import org.apache.http.client.AuthenticationStrategy;
@@ -61,17 +69,8 @@ import org.apache.http.conn.routing.BasicRouteDirector;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRouteDirector;
import org.apache.http.conn.routing.RouteTracker;
-import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.impl.auth.HttpAuthenticator;
import org.apache.http.impl.conn.ConnectionShutdownException;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.HttpCoreContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.RequestTargetHost;
-import org.apache.http.util.Args;
-import org.apache.http.util.EntityUtils;
/**
* The last request executor in the HTTP request execution chain
@@ -154,9 +153,7 @@ public class MainClientExec implements ClientExecChain {
Args.notNull(request, "HTTP request");
Args.notNull(context, "HTTP context");
- if (request instanceof HttpEntityEnclosingRequest) {
- RequestEntityProxy.enhance((HttpEntityEnclosingRequest) request);
- }
+ RequestEntityProxy.enhance(request);
Object userToken = context.getUserToken();
@@ -254,7 +251,7 @@ public class MainClientExec implements ClientExecChain {
response = requestExecutor.execute(request, managedConn, context);
// The connection is in or can be brought to a re-usable state.
- if (reuseStrategy.keepAlive(response, context)) {
+ if (reuseStrategy.keepAlive(request, response, context)) {
// Set the idle duration of this connection
final long duration = keepAliveStrategy.getKeepAliveDuration(response, context);
if (this.log.isDebugEnabled()) {
@@ -463,7 +460,7 @@ public class MainClientExec implements ClientExecChain {
if (this.authenticator.prepareAuthResponse(proxy, ChallengeType.PROXY, response,
this.proxyAuthStrategy, proxyAuthExchange, context)) {
// Retry request
- if (this.reuseStrategy.keepAlive(response, context)) {
+ if (this.reuseStrategy.keepAlive(request, response, context)) {
this.log.debug("Connection kept alive");
// Consume response content
final HttpEntity entity = response.getEntity();
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java
index 625b5a335..5800521d3 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java
@@ -36,15 +36,24 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.ConnectionReuseStrategy;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ImmutableHttpProcessor;
+import org.apache.hc.core5.http.protocol.RequestContent;
+import org.apache.hc.core5.http.protocol.RequestTargetHost;
+import org.apache.hc.core5.http.protocol.RequestUserAgent;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.VersionInfo;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpExecutionAware;
@@ -58,15 +67,6 @@ import org.apache.http.conn.ConnectionRequest;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.conn.ConnectionShutdownException;
-import org.apache.http.protocol.HttpCoreContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.RequestContent;
-import org.apache.http.protocol.RequestTargetHost;
-import org.apache.http.protocol.RequestUserAgent;
-import org.apache.http.util.Args;
-import org.apache.http.util.VersionInfo;
/**
* Request executor that implements the most fundamental aspects of
@@ -214,7 +214,7 @@ public class MinimalClientExec implements ClientExecChain {
httpProcessor.process(response, context);
// The connection is in or can be brought to a re-usable state.
- if (reuseStrategy.keepAlive(response, context)) {
+ if (reuseStrategy.keepAlive(request, response, context)) {
// Set the idle duration of this connection
final long duration = keepAliveStrategy.getKeepAliveDuration(response, context);
releaseTrigger.setValidFor(duration, TimeUnit.MILLISECONDS);
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java
index 299c333be..77333eb66 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java
@@ -33,11 +33,14 @@ import java.net.URISyntaxException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.auth.UsernamePasswordCredentials;
@@ -49,9 +52,6 @@ import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.protocol.HttpCoreContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.util.Args;
/**
* Request executor in the request execution chain that is responsible
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
index 6c4a7eaeb..0895cf004 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
@@ -33,14 +33,15 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.auth.AuthScheme;
+import org.apache.hc.core5.annotation.ThreadSafe;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.util.Args;
import org.apache.http.auth.AuthExchange;
+import org.apache.http.auth.AuthScheme;
import org.apache.http.client.RedirectException;
import org.apache.http.client.RedirectStrategy;
import org.apache.http.client.config.RequestConfig;
@@ -51,8 +52,6 @@ import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRoutePlanner;
-import org.apache.http.util.Args;
-import org.apache.http.util.EntityUtils;
/**
* Request executor in the request execution chain that is responsible
@@ -124,11 +123,8 @@ public class RedirectExec implements ClientExecChain {
final HttpRequest original = request.getOriginal();
redirect.setHeaders(original.getAllHeaders());
}
- currentRequest = HttpRequestWrapper.wrap(redirect);
-
- if (currentRequest instanceof HttpEntityEnclosingRequest) {
- RequestEntityProxy.enhance((HttpEntityEnclosingRequest) currentRequest);
- }
+ currentRequest = HttpRequestWrapper.wrap(redirect, currentRequest.getTarget());
+ RequestEntityProxy.enhance(currentRequest);
final URI uri = currentRequest.getURI();
final HttpHost newTarget = URIUtils.extractHost(uri);
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestAbortedException.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestAbortedException.java
index 2a3d0a5f3..08472de03 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestAbortedException.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestAbortedException.java
@@ -29,7 +29,7 @@ package org.apache.http.impl.execchain;
import java.io.InterruptedIOException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
/**
* Signals that the request has been aborted.
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java
index e4ed35b66..dd786c4e5 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java
@@ -29,22 +29,22 @@ package org.apache.http.impl.execchain;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.Set;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.TrailerSupplier;
/**
- * A Proxy class for {@link org.apache.http.HttpEntity} enclosed in a request message.
+ * A Proxy class for {@link org.apache.hc.core5.http.HttpEntity} enclosed in a request message.
*
* @since 4.3
*/
@NotThreadSafe
class RequestEntityProxy implements HttpEntity {
- static void enhance(final HttpEntityEnclosingRequest request) {
+ static void enhance(final HttpRequest request) {
final HttpEntity entity = request.getEntity();
if (entity != null && !entity.isRepeatable() && !isEnhanced(entity)) {
request.setEntity(new RequestEntityProxy(entity));
@@ -56,17 +56,15 @@ class RequestEntityProxy implements HttpEntity {
}
static boolean isRepeatable(final HttpRequest request) {
- if (request instanceof HttpEntityEnclosingRequest) {
- final HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
- if (entity != null) {
- if (isEnhanced(entity)) {
- final RequestEntityProxy proxy = (RequestEntityProxy) entity;
- if (!proxy.isConsumed()) {
- return true;
- }
+ final HttpEntity entity = request.getEntity();
+ if (entity != null) {
+ if (isEnhanced(entity)) {
+ final RequestEntityProxy proxy = (RequestEntityProxy) entity;
+ if (!proxy.isConsumed()) {
+ return true;
}
- return entity.isRepeatable();
}
+ return entity.isRepeatable();
}
return true;
}
@@ -103,12 +101,12 @@ class RequestEntityProxy implements HttpEntity {
}
@Override
- public Header getContentType() {
+ public String getContentType() {
return original.getContentType();
}
@Override
- public Header getContentEncoding() {
+ public String getContentEncoding() {
return original.getContentEncoding();
}
@@ -129,10 +127,13 @@ class RequestEntityProxy implements HttpEntity {
}
@Override
- @Deprecated
- public void consumeContent() throws IOException {
- consumed = true;
- original.consumeContent();
+ public TrailerSupplier getTrailers() {
+ return original.getTrailers();
+ }
+
+ @Override
+ public Set getTrailerNames() {
+ return original.getTrailerNames();
}
@Override
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java
index 7f2c42d35..54dfdf65a 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java
@@ -32,12 +32,12 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.SocketException;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.hc.core5.annotation.NotThreadSafe;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.entity.HttpEntityWrapper;
import org.apache.http.conn.EofSensorInputStream;
import org.apache.http.conn.EofSensorWatcher;
-import org.apache.http.entity.HttpEntityWrapper;
/**
* A wrapper class for {@link HttpEntity} enclosed in a response message.
@@ -86,24 +86,15 @@ class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher
@Override
public InputStream getContent() throws IOException {
- return new EofSensorInputStream(this.wrappedEntity.getContent(), this);
- }
-
- @Deprecated
- @Override
- public void consumeContent() throws IOException {
- releaseConnection();
+ return new EofSensorInputStream(super.getContent(), this);
}
@Override
public void writeTo(final OutputStream outstream) throws IOException {
try {
- this.wrappedEntity.writeTo(outstream);
+ super.writeTo(outstream);
releaseConnection();
- } catch (IOException ex) {
- abortConnection();
- throw ex;
- } catch (RuntimeException ex) {
+ } catch (IOException | RuntimeException ex) {
abortConnection();
throw ex;
} finally {
@@ -118,10 +109,7 @@ class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher
// reading trailers after the response body:
wrapped.close();
releaseConnection();
- } catch (IOException ex) {
- abortConnection();
- throw ex;
- } catch (RuntimeException ex) {
+ } catch (IOException | RuntimeException ex) {
abortConnection();
throw ex;
} finally {
@@ -144,10 +132,7 @@ class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher
throw ex;
}
}
- } catch (IOException ex) {
- abortConnection();
- throw ex;
- } catch (RuntimeException ex) {
+ } catch (IOException | RuntimeException ex) {
abortConnection();
throw ex;
} finally {
@@ -162,12 +147,4 @@ class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher
return false;
}
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder("ResponseEntityProxy{");
- sb.append(wrappedEntity);
- sb.append('}');
- return sb.toString();
- }
-
}
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java
index 01cb1ce0c..f5656c55d 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java
@@ -31,10 +31,11 @@ import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.NoHttpResponseException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.NoHttpResponseException;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.NonRepeatableRequestException;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -42,7 +43,6 @@ import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.util.Args;
/**
* Request executor in the request execution chain that is responsible
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java
index 977ecf38f..d7104d8db 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java
@@ -32,16 +32,16 @@ import java.io.InterruptedIOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.util.Args;
import org.apache.http.client.ServiceUnavailableRetryStrategy;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.util.Args;
/**
* Request executor in the request execution chain that is responsible
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/TunnelRefusedException.java b/httpclient/src/main/java/org/apache/http/impl/execchain/TunnelRefusedException.java
index cff1e0797..591224bfb 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/TunnelRefusedException.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/TunnelRefusedException.java
@@ -27,9 +27,9 @@
package org.apache.http.impl.execchain;
-import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.Immutable;
+import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpResponse;
/**
* Signals that the tunnel request was rejected by the proxy host.
diff --git a/httpclient/src/test/java/org/apache/http/auth/TestAuthChallenge.java b/httpclient/src/test/java/org/apache/http/auth/TestAuthChallenge.java
index a2700e61f..537090236 100644
--- a/httpclient/src/test/java/org/apache/http/auth/TestAuthChallenge.java
+++ b/httpclient/src/test/java/org/apache/http/auth/TestAuthChallenge.java
@@ -29,7 +29,7 @@ package org.apache.http.auth;
import java.util.Arrays;
-import org.apache.http.message.BasicNameValuePair;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/auth/TestAuthScope.java b/httpclient/src/test/java/org/apache/http/auth/TestAuthScope.java
index ce8f28dd1..06feb5012 100644
--- a/httpclient/src/test/java/org/apache/http/auth/TestAuthScope.java
+++ b/httpclient/src/test/java/org/apache/http/auth/TestAuthScope.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.auth;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/auth/util/TestByteArrayBuilder.java b/httpclient/src/test/java/org/apache/http/auth/util/TestByteArrayBuilder.java
index 3ab527ab6..d986391d8 100644
--- a/httpclient/src/test/java/org/apache/http/auth/util/TestByteArrayBuilder.java
+++ b/httpclient/src/test/java/org/apache/http/auth/util/TestByteArrayBuilder.java
@@ -27,8 +27,8 @@
package org.apache.http.auth.util;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.Consts;
import org.junit.Assert;
import org.junit.Test;
@@ -126,7 +126,7 @@ public class TestByteArrayBuilder {
final byte[] bytes = buffer.toByteArray();
Assert.assertNotNull(bytes);
- Assert.assertEquals("123456789abcdef", new String(bytes, Consts.ASCII));
+ Assert.assertEquals("123456789abcdef", new String(bytes, StandardCharsets.US_ASCII));
}
@Test
@@ -176,13 +176,13 @@ public class TestByteArrayBuilder {
final byte[] bytes1 = buffer.toByteArray();
Assert.assertNotNull(bytes1);
- Assert.assertEquals("abcdef", new String(bytes1, Consts.ASCII));
+ Assert.assertEquals("abcdef", new String(bytes1, StandardCharsets.US_ASCII));
buffer.reset();
final byte[] bytes2 = buffer.toByteArray();
Assert.assertNotNull(bytes2);
- Assert.assertEquals("", new String(bytes2, Consts.ASCII));
+ Assert.assertEquals("", new String(bytes2, StandardCharsets.US_ASCII));
}
@Test
@@ -200,15 +200,15 @@ public class TestByteArrayBuilder {
final byte[] bytes1 = buffer.toByteArray();
Assert.assertNotNull(bytes1);
- Assert.assertEquals("?-?-?", new String(bytes1, Consts.ASCII));
+ Assert.assertEquals("?-?-?", new String(bytes1, StandardCharsets.US_ASCII));
buffer.reset();
- buffer.charset(Consts.UTF_8);
+ buffer.charset(StandardCharsets.UTF_8);
buffer.append(umlauts);
final byte[] bytes2 = buffer.toByteArray();
Assert.assertNotNull(bytes2);
- Assert.assertEquals(umlauts, new String(bytes2, Consts.UTF_8));
+ Assert.assertEquals(umlauts, new String(bytes2, StandardCharsets.UTF_8));
}
}
diff --git a/httpclient/src/test/java/org/apache/http/client/config/TestRequestConfig.java b/httpclient/src/test/java/org/apache/http/client/config/TestRequestConfig.java
index c0b0745db..5d60166db 100644
--- a/httpclient/src/test/java/org/apache/http/client/config/TestRequestConfig.java
+++ b/httpclient/src/test/java/org/apache/http/client/config/TestRequestConfig.java
@@ -30,7 +30,7 @@ package org.apache.http.client.config;
import java.net.InetAddress;
import java.util.Arrays;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java b/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java
index 347d99d74..0e2312177 100644
--- a/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java
+++ b/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java
@@ -31,15 +31,15 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.zip.CRC32;
import java.util.zip.CheckedInputStream;
import java.util.zip.Checksum;
-import org.apache.http.Consts;
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.entity.StringEntity;
import org.junit.Assert;
import org.junit.Test;
@@ -48,7 +48,7 @@ public class TestDecompressingEntity {
@Test
public void testNonStreaming() throws Exception {
final CRC32 crc32 = new CRC32();
- final StringEntity wrapped = new StringEntity("1234567890", "ASCII");
+ final StringEntity wrapped = new StringEntity("1234567890", StandardCharsets.US_ASCII);
final ChecksumEntity entity = new ChecksumEntity(wrapped, crc32);
Assert.assertFalse(entity.isStreaming());
final String s = EntityUtils.toString(entity);
@@ -62,7 +62,7 @@ public class TestDecompressingEntity {
@Test
public void testStreaming() throws Exception {
final CRC32 crc32 = new CRC32();
- final ByteArrayInputStream in = new ByteArrayInputStream("1234567890".getBytes(Consts.ASCII));
+ final ByteArrayInputStream in = new ByteArrayInputStream("1234567890".getBytes(StandardCharsets.US_ASCII));
final InputStreamEntity wrapped = new InputStreamEntity(in, -1);
final ChecksumEntity entity = new ChecksumEntity(wrapped, crc32);
Assert.assertTrue(entity.isStreaming());
@@ -79,14 +79,14 @@ public class TestDecompressingEntity {
@Test
public void testWriteToStream() throws Exception {
final CRC32 crc32 = new CRC32();
- final StringEntity wrapped = new StringEntity("1234567890", "ASCII");
+ final StringEntity wrapped = new StringEntity("1234567890", StandardCharsets.US_ASCII);
final ChecksumEntity entity = new ChecksumEntity(wrapped, crc32);
Assert.assertFalse(entity.isStreaming());
final ByteArrayOutputStream out = new ByteArrayOutputStream();
entity.writeTo(out);
- final String s = new String(out.toByteArray(), "ASCII");
+ final String s = new String(out.toByteArray(), StandardCharsets.US_ASCII);
Assert.assertEquals("1234567890", s);
Assert.assertEquals(639479525L, crc32.getValue());
}
diff --git a/httpclient/src/test/java/org/apache/http/client/entity/TestDeflate.java b/httpclient/src/test/java/org/apache/http/client/entity/TestDeflate.java
index 6cded07b7..47de73ccc 100644
--- a/httpclient/src/test/java/org/apache/http/client/entity/TestDeflate.java
+++ b/httpclient/src/test/java/org/apache/http/client/entity/TestDeflate.java
@@ -27,12 +27,12 @@
package org.apache.http.client.entity;
+import java.nio.charset.StandardCharsets;
import java.util.zip.Deflater;
-import org.apache.http.Consts;
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -42,7 +42,7 @@ public class TestDeflate {
public void testCompressDecompress() throws Exception {
final String s = "some kind of text";
- final byte[] input = s.getBytes(Consts.ASCII);
+ final byte[] input = s.getBytes(StandardCharsets.US_ASCII);
// Compress the bytes
final byte[] compressed = new byte[input.length * 2];
diff --git a/httpclient/src/test/java/org/apache/http/client/entity/TestEntityBuilder.java b/httpclient/src/test/java/org/apache/http/client/entity/TestEntityBuilder.java
index 595ae69a8..d3500217b 100644
--- a/httpclient/src/test/java/org/apache/http/client/entity/TestEntityBuilder.java
+++ b/httpclient/src/test/java/org/apache/http/client/entity/TestEntityBuilder.java
@@ -30,9 +30,9 @@ package org.apache.http.client.entity;
import java.io.File;
import java.io.InputStream;
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
@@ -52,7 +52,7 @@ public class TestEntityBuilder {
Assert.assertNotNull(entity);
Assert.assertNotNull(entity.getContent());
Assert.assertNotNull(entity.getContentType());
- Assert.assertEquals("text/plain; charset=ISO-8859-1", entity.getContentType().getValue());
+ Assert.assertEquals("text/plain; charset=ISO-8859-1", entity.getContentType());
}
@Test
@@ -61,7 +61,7 @@ public class TestEntityBuilder {
Assert.assertNotNull(entity);
Assert.assertNotNull(entity.getContent());
Assert.assertNotNull(entity.getContentType());
- Assert.assertEquals("application/octet-stream", entity.getContentType().getValue());
+ Assert.assertEquals("application/octet-stream", entity.getContentType());
}
@Test
@@ -72,7 +72,7 @@ public class TestEntityBuilder {
Assert.assertNotNull(entity.getContent());
Assert.assertNotNull(entity.getContentType());
Assert.assertEquals(-1, entity.getContentLength());
- Assert.assertEquals("application/octet-stream", entity.getContentType().getValue());
+ Assert.assertEquals("application/octet-stream", entity.getContentType());
}
@Test
@@ -81,7 +81,7 @@ public class TestEntityBuilder {
Assert.assertNotNull(entity);
Assert.assertNotNull(entity.getContent());
Assert.assertNotNull(entity.getContentType());
- Assert.assertEquals("application/octet-stream", entity.getContentType().getValue());
+ Assert.assertEquals("application/octet-stream", entity.getContentType());
}
@Test
@@ -90,7 +90,7 @@ public class TestEntityBuilder {
final HttpEntity entity = EntityBuilder.create().setFile(file).build();
Assert.assertNotNull(entity);
Assert.assertNotNull(entity.getContentType());
- Assert.assertEquals("application/octet-stream", entity.getContentType().getValue());
+ Assert.assertEquals("application/octet-stream", entity.getContentType());
}
@Test
@@ -102,9 +102,9 @@ public class TestEntityBuilder {
.setText("{\"stuff\"}").build();
Assert.assertNotNull(entity);
Assert.assertNotNull(entity.getContentType());
- Assert.assertEquals("application/json; charset=UTF-8", entity.getContentType().getValue());
+ Assert.assertEquals("application/json; charset=UTF-8", entity.getContentType());
Assert.assertNotNull(entity.getContentEncoding());
- Assert.assertEquals("identity", entity.getContentEncoding().getValue());
+ Assert.assertEquals("identity", entity.getContentEncoding());
Assert.assertEquals("{\"stuff\"}", EntityUtils.toString(entity));
}
@@ -120,9 +120,9 @@ public class TestEntityBuilder {
final HttpEntity entity = EntityBuilder.create().setText("stuff").gzipCompress().build();
Assert.assertNotNull(entity);
Assert.assertNotNull(entity.getContentType());
- Assert.assertEquals("text/plain; charset=ISO-8859-1", entity.getContentType().getValue());
+ Assert.assertEquals("text/plain; charset=ISO-8859-1", entity.getContentType());
Assert.assertNotNull(entity.getContentEncoding());
- Assert.assertEquals("gzip", entity.getContentEncoding().getValue());
+ Assert.assertEquals("gzip", entity.getContentEncoding());
}
}
diff --git a/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java b/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
index adc53403f..656c3d98a 100644
--- a/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
+++ b/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
@@ -30,13 +30,13 @@ package org.apache.http.client.entity;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.Consts;
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
@@ -52,7 +52,7 @@ public class TestGZip {
Assert.assertTrue(gzipe.isChunked());
Assert.assertEquals(-1, gzipe.getContentLength());
Assert.assertNotNull(gzipe.getContentEncoding());
- Assert.assertEquals("gzip", gzipe.getContentEncoding().getValue());
+ Assert.assertEquals("gzip", gzipe.getContentEncoding());
}
@Test
@@ -63,7 +63,7 @@ public class TestGZip {
gzipe.writeTo(buf);
final ByteArrayEntity out = new ByteArrayEntity(buf.toByteArray());
final GzipDecompressingEntity gunzipe = new GzipDecompressingEntity(out);
- Assert.assertEquals("some kind of text", EntityUtils.toString(gunzipe, Consts.ASCII));
+ Assert.assertEquals("some kind of text", EntityUtils.toString(gunzipe, StandardCharsets.US_ASCII));
}
@Test
diff --git a/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java b/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java
index 5d67ad096..53234b44c 100644
--- a/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java
+++ b/httpclient/src/test/java/org/apache/http/client/methods/TestHttpOptions.java
@@ -29,9 +29,9 @@ package org.apache.http.client.methods;
import java.util.Set;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.message.BasicStatusLine;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.message.BasicStatusLine;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java b/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
index 51a794e09..516c411b1 100644
--- a/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
+++ b/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
@@ -27,13 +27,7 @@
package org.apache.http.client.methods;
-import java.io.ByteArrayInputStream;
-
-import org.apache.http.Header;
-import org.apache.http.HttpVersion;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.util.LangUtils;
+import org.apache.hc.core5.http.HttpVersion;
import org.junit.Assert;
import org.junit.Test;
@@ -53,55 +47,4 @@ public class TestHttpRequestBase {
Assert.assertEquals("/", httpget.getRequestLine().getUri());
}
- @Test
- public void testCloneBasicRequests() throws Exception {
- final HttpGet httpget = new HttpGet("http://host/path");
- httpget.addHeader("h1", "this header");
- httpget.addHeader("h2", "that header");
- httpget.addHeader("h3", "all sorts of headers");
- final HttpGet clone = (HttpGet) httpget.clone();
-
- Assert.assertEquals(httpget.getMethod(), clone.getMethod());
- Assert.assertEquals(httpget.getURI(), clone.getURI());
-
- final Header[] headers1 = httpget.getAllHeaders();
- final Header[] headers2 = clone.getAllHeaders();
-
- Assert.assertTrue(LangUtils.equals(headers1, headers2));
- }
-
- @Test
- public void testCloneEntityEnclosingRequests() throws Exception {
- final HttpPost httppost = new HttpPost("http://host/path");
- httppost.addHeader("h1", "this header");
- httppost.addHeader("h2", "that header");
- httppost.addHeader("h3", "all sorts of headers");
- HttpPost clone = (HttpPost) httppost.clone();
-
- Assert.assertEquals(httppost.getMethod(), clone.getMethod());
- Assert.assertEquals(httppost.getURI(), clone.getURI());
-
- final Header[] headers1 = httppost.getAllHeaders();
- final Header[] headers2 = clone.getAllHeaders();
-
- Assert.assertTrue(LangUtils.equals(headers1, headers2));
-
- Assert.assertNull(clone.getEntity());
-
- final StringEntity e1 = new StringEntity("stuff");
- httppost.setEntity(e1);
- clone = (HttpPost) httppost.clone();
- Assert.assertTrue(clone.getEntity() instanceof StringEntity);
- Assert.assertFalse(clone.getEntity().equals(e1));
- }
-
- @Test(expected=CloneNotSupportedException.class)
- public void testCloneStreamingEntityEnclosingRequests() throws Exception {
- final ByteArrayInputStream instream = new ByteArrayInputStream(new byte[] {});
- final InputStreamEntity e2 = new InputStreamEntity(instream, -1);
- final HttpPost httppost = new HttpPost("http://host/path");
- httppost.setEntity(e2);
- httppost.clone();
- }
-
}
diff --git a/httpclient/src/test/java/org/apache/http/client/methods/TestRequestBuilder.java b/httpclient/src/test/java/org/apache/http/client/methods/TestRequestBuilder.java
index 84fea770d..ae8396d21 100644
--- a/httpclient/src/test/java/org/apache/http/client/methods/TestRequestBuilder.java
+++ b/httpclient/src/test/java/org/apache/http/client/methods/TestRequestBuilder.java
@@ -30,19 +30,18 @@ package org.apache.http.client.methods;
import java.net.URI;
import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpVersion;
-import org.apache.http.NameValuePair;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.entity.BasicHttpEntity;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
import org.apache.http.client.config.RequestConfig;
-import org.apache.http.entity.BasicHttpEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -55,7 +54,6 @@ public class TestRequestBuilder {
Assert.assertEquals("GET", request.getMethod());
Assert.assertEquals(URI.create("/"), request.getURI());
Assert.assertEquals(HttpVersion.HTTP_1_1, request.getProtocolVersion());
- Assert.assertFalse(request instanceof HttpEntityEnclosingRequest);
}
@Test
@@ -75,8 +73,7 @@ public class TestRequestBuilder {
Assert.assertEquals("POST", request.getMethod());
Assert.assertEquals(URI.create("/"), request.getURI());
Assert.assertEquals(HttpVersion.HTTP_1_1, request.getProtocolVersion());
- Assert.assertTrue(request instanceof HttpEntityEnclosingRequest);
- Assert.assertSame(entity, ((HttpEntityEnclosingRequest) request).getEntity());
+ Assert.assertSame(entity, request.getEntity());
}
@Test
@@ -87,8 +84,7 @@ public class TestRequestBuilder {
Assert.assertEquals("GET", request.getMethod());
Assert.assertEquals(URI.create("/"), request.getURI());
Assert.assertEquals(HttpVersion.HTTP_1_1, request.getProtocolVersion());
- Assert.assertTrue(request instanceof HttpEntityEnclosingRequest);
- Assert.assertSame(entity, ((HttpEntityEnclosingRequest) request).getEntity());
+ Assert.assertSame(entity, request.getEntity());
}
@Test
@@ -97,7 +93,6 @@ public class TestRequestBuilder {
.addParameter("p1", "this")
.addParameter("p2", "that")
.build();
- Assert.assertFalse(request instanceof HttpEntityEnclosingRequest);
Assert.assertEquals(new URI("/?p1=this&p2=that"), request.getURI());
}
@@ -107,7 +102,6 @@ public class TestRequestBuilder {
.addParameter("p1", "this")
.addParameters(new BasicNameValuePair("p2", "that"))
.build();
- Assert.assertFalse(request instanceof HttpEntityEnclosingRequest);
Assert.assertEquals(new URI("/?p1=this&p2=that"), request.getURI());
}
@@ -117,8 +111,7 @@ public class TestRequestBuilder {
.addParameter("p1", "this")
.addParameter("p2", "that")
.build();
- Assert.assertTrue(request instanceof HttpEntityEnclosingRequest);
- final HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
+ final HttpEntity entity = request.getEntity();
Assert.assertNotNull(entity);
Assert.assertEquals(new URI("/"), request.getURI());
Assert.assertEquals("p1=this&p2=that", EntityUtils.toString(entity));
@@ -132,7 +125,6 @@ public class TestRequestBuilder {
.addParameter("p2", "that")
.setEntity(new StringEntity("blah"))
.build();
- Assert.assertTrue(request instanceof HttpEntityEnclosingRequest);
Assert.assertEquals(new URI("http://targethost/?blah&p1=this&p2=that"), request.getURI());
}
@@ -152,13 +144,11 @@ public class TestRequestBuilder {
Assert.assertEquals("PUT", request.getMethod());
Assert.assertEquals(URI.create("/stuff"), request.getURI());
Assert.assertEquals(HttpVersion.HTTP_1_0, request.getProtocolVersion());
- Assert.assertTrue(request instanceof HttpEntityEnclosingRequest);
final HttpUriRequest copy = RequestBuilder.copy(request).setUri("/other-stuff").build();
Assert.assertEquals("PUT", copy.getMethod());
Assert.assertEquals(URI.create("/other-stuff"), copy.getURI());
- Assert.assertTrue(copy instanceof HttpEntityEnclosingRequest);
- Assert.assertSame(entity, ((HttpEntityEnclosingRequest) copy).getEntity());
+ Assert.assertSame(entity, copy.getEntity());
Assert.assertTrue(copy instanceof Configurable);
Assert.assertSame(config, ((Configurable) copy).getConfig());
}
@@ -181,12 +171,20 @@ public class TestRequestBuilder {
final List parameters = builder.getParameters();
Assert.assertNotNull(parameters);
Assert.assertEquals(2, parameters.size());
- Assert.assertEquals(new BasicNameValuePair("p1", "this"), parameters.get(0));
- Assert.assertEquals(new BasicNameValuePair("p2", "that"), parameters.get(1));
+ assertNameValuePair(new BasicNameValuePair("p1", "this"), parameters.get(0));
+ assertNameValuePair(new BasicNameValuePair("p2", "that"), parameters.get(1));
Assert.assertEquals(new URI("/stuff?p1=wtf"), builder.getUri());
Assert.assertNull(builder.getEntity());
}
+ private static void assertNameValuePair (
+ final NameValuePair expected,
+ final NameValuePair result) {
+ Assert.assertNotNull(result);
+ Assert.assertEquals(expected.getName(), result.getName());
+ Assert.assertEquals(expected.getValue(), result.getValue());
+ }
+
@Test
public void testCopyWithStringEntity() throws Exception {
final HttpPost post = new HttpPost("/stuff?p1=wtf");
diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAcceptEncoding.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAcceptEncoding.java
index f9ba97dd8..ed3931727 100644
--- a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAcceptEncoding.java
+++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAcceptEncoding.java
@@ -26,12 +26,12 @@
*/
package org.apache.http.client.protocol;
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
index e3079f246..055a3d7b1 100644
--- a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
+++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
@@ -28,15 +28,17 @@ package org.apache.http.client.protocol;
import java.util.Date;
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.http.client.CookieStore;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.RouteInfo.LayerType;
import org.apache.http.conn.routing.RouteInfo.TunnelType;
@@ -48,8 +50,6 @@ import org.apache.http.impl.cookie.BasicClientCookie;
import org.apache.http.impl.cookie.IgnoreSpecProvider;
import org.apache.http.impl.cookie.RFC6265CookieSpecProvider;
import org.apache.http.impl.cookie.RFC6265StrictSpec;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.HttpCoreContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java
index fc0390fd1..53de222fc 100644
--- a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java
+++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java
@@ -26,9 +26,11 @@
*/
package org.apache.http.client.protocol;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
@@ -38,8 +40,6 @@ import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.HttpCoreContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestClientConnControl.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestClientConnControl.java
index 521b34a28..eb282f8a0 100644
--- a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestClientConnControl.java
+++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestClientConnControl.java
@@ -26,15 +26,16 @@
*/
package org.apache.http.client.protocol;
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.RouteInfo.LayerType;
import org.apache.http.conn.routing.RouteInfo.TunnelType;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.HTTP;
import org.junit.Assert;
import org.junit.Test;
@@ -56,8 +57,8 @@ public class TestRequestClientConnControl {
interceptor.process(request, context);
final Header header1 = request.getFirstHeader("Proxy-Connection");
Assert.assertNotNull(header1);
- Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header1.getValue());
- final Header header2 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
+ Assert.assertEquals(HeaderElements.KEEP_ALIVE, header1.getValue());
+ final Header header2 = request.getFirstHeader(HttpHeaders.CONNECTION);
Assert.assertNull(header2);
}
@@ -74,9 +75,9 @@ public class TestRequestClientConnControl {
final HttpRequestInterceptor interceptor = new RequestClientConnControl();
interceptor.process(request, context);
- final Header header1 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
+ final Header header1 = request.getFirstHeader(HttpHeaders.CONNECTION);
Assert.assertNotNull(header1);
- Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header1.getValue());
+ Assert.assertEquals(HeaderElements.KEEP_ALIVE, header1.getValue());
final Header header2 = request.getFirstHeader("Proxy-Connection");
Assert.assertNull(header2);
}
@@ -96,9 +97,9 @@ public class TestRequestClientConnControl {
final HttpRequestInterceptor interceptor = new RequestClientConnControl();
interceptor.process(request, context);
- final Header header1 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
+ final Header header1 = request.getFirstHeader(HttpHeaders.CONNECTION);
Assert.assertNotNull(header1);
- Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header1.getValue());
+ Assert.assertEquals(HeaderElements.KEEP_ALIVE, header1.getValue());
final Header header2 = request.getFirstHeader("Proxy-Connection");
Assert.assertNull(header2);
}
@@ -120,15 +121,15 @@ public class TestRequestClientConnControl {
final Header header1 = request.getFirstHeader("Proxy-Connection");
Assert.assertNotNull(header1);
- Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header1.getValue());
- final Header header2 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
+ Assert.assertEquals(HeaderElements.KEEP_ALIVE, header1.getValue());
+ final Header header2 = request.getFirstHeader(HttpHeaders.CONNECTION);
Assert.assertNull(header2);
}
@Test
public void testPreserveCustomConnectionHeader() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
- request.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
+ request.addHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE);
final HttpClientContext context = HttpClientContext.create();
final HttpHost target = new HttpHost("localhost", 443, "https");
@@ -141,9 +142,9 @@ public class TestRequestClientConnControl {
final HttpRequestInterceptor interceptor = new RequestClientConnControl();
interceptor.process(request, context);
- final Header header1 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
+ final Header header1 = request.getFirstHeader(HttpHeaders.CONNECTION);
Assert.assertNotNull(header1);
- Assert.assertEquals(HTTP.CONN_CLOSE, header1.getValue());
+ Assert.assertEquals(HeaderElements.CLOSE, header1.getValue());
final Header header2 = request.getFirstHeader("Proxy-Connection");
Assert.assertNull(header2);
}
@@ -151,7 +152,7 @@ public class TestRequestClientConnControl {
@Test
public void testPreserveCustomProxyConnectionHeader() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
- request.addHeader("Proxy-Connection", HTTP.CONN_CLOSE);
+ request.addHeader("Proxy-Connection", HeaderElements.CLOSE);
final HttpClientContext context = HttpClientContext.create();
final HttpHost target = new HttpHost("localhost", 80, "http");
@@ -166,7 +167,7 @@ public class TestRequestClientConnControl {
final Header header1 = request.getFirstHeader("Proxy-Connection");
Assert.assertNotNull(header1);
- Assert.assertEquals(HTTP.CONN_CLOSE, header1.getValue());
+ Assert.assertEquals(HeaderElements.CLOSE, header1.getValue());
}
}
diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestDefaultHeaders.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestDefaultHeaders.java
index 69661a6d1..9f860d42e 100644
--- a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestDefaultHeaders.java
+++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestDefaultHeaders.java
@@ -29,13 +29,13 @@ package org.apache.http.client.protocol;
import java.util.ArrayList;
import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestExpectContinue.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestExpectContinue.java
index f35267314..1be6716fa 100644
--- a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestExpectContinue.java
+++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestExpectContinue.java
@@ -27,15 +27,17 @@
package org.apache.http.client.protocol;
-import org.apache.http.Header;
-import org.apache.http.HttpVersion;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.config.RequestConfig;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Test;
@@ -46,15 +48,15 @@ public class TestRequestExpectContinue {
final HttpClientContext context = HttpClientContext.create();
final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
- final BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+ final BasicHttpRequest request = new BasicHttpRequest("POST", "/");
final String s = "whatever";
- final StringEntity entity = new StringEntity(s, "US-ASCII");
+ final StringEntity entity = new StringEntity(s, StandardCharsets.US_ASCII);
request.setEntity(entity);
final RequestExpectContinue interceptor = new RequestExpectContinue();
interceptor.process(request, context);
- final Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
+ final Header header = request.getFirstHeader(HttpHeaders.EXPECT);
Assert.assertNotNull(header);
- Assert.assertEquals(HTTP.EXPECT_CONTINUE, header.getValue());
+ Assert.assertEquals(HeaderElements.CONTINUE, header.getValue());
}
@Test
@@ -62,13 +64,13 @@ public class TestRequestExpectContinue {
final HttpContext context = new BasicHttpContext(null);
final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(false).build();
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
- final BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+ final BasicHttpRequest request = new BasicHttpRequest("POST", "/");
final String s = "whatever";
- final StringEntity entity = new StringEntity(s, "US-ASCII");
+ final StringEntity entity = new StringEntity(s, StandardCharsets.US_ASCII);
request.setEntity(entity);
final RequestExpectContinue interceptor = new RequestExpectContinue();
interceptor.process(request, context);
- final Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
+ final Header header = request.getFirstHeader(HeaderElements.CONTINUE);
Assert.assertNull(header);
}
@@ -77,14 +79,14 @@ public class TestRequestExpectContinue {
final HttpContext context = new BasicHttpContext(null);
final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
- final BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
+ final BasicHttpRequest request = new BasicHttpRequest(
"POST", "/", HttpVersion.HTTP_1_0);
final String s = "whatever";
- final StringEntity entity = new StringEntity(s, "US-ASCII");
+ final StringEntity entity = new StringEntity(s, StandardCharsets.US_ASCII);
request.setEntity(entity);
final RequestExpectContinue interceptor = new RequestExpectContinue();
interceptor.process(request, context);
- final Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
+ final Header header = request.getFirstHeader(HeaderElements.CONTINUE);
Assert.assertNull(header);
}
@@ -93,13 +95,13 @@ public class TestRequestExpectContinue {
final HttpContext context = new BasicHttpContext(null);
final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
- final BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
+ final BasicHttpRequest request = new BasicHttpRequest("POST", "/");
final String s = "";
- final StringEntity entity = new StringEntity(s, "US-ASCII");
+ final StringEntity entity = new StringEntity(s, StandardCharsets.US_ASCII);
request.setEntity(entity);
final RequestExpectContinue interceptor = new RequestExpectContinue();
interceptor.process(request, context);
- final Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
+ final Header header = request.getFirstHeader(HeaderElements.CONTINUE);
Assert.assertNull(header);
}
diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseContentEncoding.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseContentEncoding.java
index 83f988637..01ae5f03d 100644
--- a/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseContentEncoding.java
+++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseContentEncoding.java
@@ -26,18 +26,18 @@
*/
package org.apache.http.client.protocol;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.DecompressingEntity;
import org.apache.http.client.entity.GzipDecompressingEntity;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseProcessCookies.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseProcessCookies.java
index e639bdaa4..8a9ff02ad 100644
--- a/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseProcessCookies.java
+++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseProcessCookies.java
@@ -28,16 +28,16 @@ package org.apache.http.client.protocol;
import java.util.List;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.CookieStore;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.CookieSpec;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.cookie.RFC6265LaxSpec;
-import org.apache.http.message.BasicHttpResponse;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java b/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
index b1fa88d72..b2a24b388 100644
--- a/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
+++ b/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
@@ -29,8 +29,8 @@ package org.apache.http.client.utils;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpResponse;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.CloseableHttpClient;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/client/utils/TestRequestBuilder.java b/httpclient/src/test/java/org/apache/http/client/utils/TestRequestBuilder.java
index d71c018b3..7973dacd7 100644
--- a/httpclient/src/test/java/org/apache/http/client/utils/TestRequestBuilder.java
+++ b/httpclient/src/test/java/org/apache/http/client/utils/TestRequestBuilder.java
@@ -27,27 +27,27 @@
package org.apache.http.client.utils;
-import org.apache.http.Consts;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.methods.RequestBuilder;
-import org.apache.http.message.BasicNameValuePair;
-import org.junit.Assert;
-import org.junit.Test;
-
import java.net.URLEncoder;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.methods.RequestBuilder;
+import org.junit.Assert;
+import org.junit.Test;
public class TestRequestBuilder {
@Test
public void testBuildGETwithUTF8() throws Exception {
- assertBuild(Consts.UTF_8);
+ assertBuild(StandardCharsets.UTF_8);
}
@Test
public void testBuildGETwithISO88591() throws Exception {
- assertBuild(Consts.ISO_8859_1);
+ assertBuild(StandardCharsets.ISO_8859_1);
}
private void assertBuild(final Charset charset) throws Exception {
diff --git a/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java b/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java
index 284baca48..d4094e2da 100644
--- a/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java
+++ b/httpclient/src/test/java/org/apache/http/client/utils/TestURIBuilder.java
@@ -29,12 +29,12 @@ package org.apache.http.client.utils;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
-import org.apache.http.Consts;
-import org.apache.http.NameValuePair;
-import org.apache.http.message.BasicNameValuePair;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
import org.junit.Assert;
import org.junit.Test;
@@ -241,12 +241,12 @@ public class TestURIBuilder {
@Test
public void testBuildAddParametersUTF8() throws Exception {
- assertAddParameters(Consts.UTF_8);
+ assertAddParameters(StandardCharsets.UTF_8);
}
@Test
public void testBuildAddParametersISO88591() throws Exception {
- assertAddParameters(Consts.ISO_8859_1);
+ assertAddParameters(StandardCharsets.ISO_8859_1);
}
public void assertAddParameters(final Charset charset) throws Exception {
@@ -259,12 +259,12 @@ public class TestURIBuilder {
@Test
public void testBuildSetParametersUTF8() throws Exception {
- assertSetParameters(Consts.UTF_8);
+ assertSetParameters(StandardCharsets.UTF_8);
}
@Test
public void testBuildSetParametersISO88591() throws Exception {
- assertSetParameters(Consts.ISO_8859_1);
+ assertSetParameters(StandardCharsets.ISO_8859_1);
}
public void assertSetParameters(final Charset charset) throws Exception {
diff --git a/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java b/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
index e33477fce..68c314f45 100644
--- a/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
+++ b/httpclient/src/test/java/org/apache/http/client/utils/TestURIUtils.java
@@ -29,7 +29,7 @@ package org.apache.http.client.utils;
import java.net.URI;
import java.util.Arrays;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.apache.http.conn.routing.HttpRoute;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java b/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java
index 9e79c5a38..547e9c699 100644
--- a/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java
+++ b/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java
@@ -28,15 +28,14 @@
package org.apache.http.client.utils;
import java.net.URI;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
-import org.apache.http.Consts;
-import org.apache.http.NameValuePair;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.protocol.HTTP;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
import org.junit.Assert;
import org.junit.Test;
@@ -209,13 +208,13 @@ public class TestURLEncodedUtils {
parameters.add(new BasicNameValuePair("russian", ru_hello));
parameters.add(new BasicNameValuePair("swiss", ch_hello));
- final String s = URLEncodedUtils.format(parameters, Consts.UTF_8);
+ final String s = URLEncodedUtils.format(parameters, StandardCharsets.UTF_8);
Assert.assertEquals("russian=%D0%92%D1%81%D0%B5%D0%BC_%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82" +
"&swiss=Gr%C3%BCezi_z%C3%A4m%C3%A4", s);
final StringEntity entity = new StringEntity(s, ContentType.create(
- URLEncodedUtils.CONTENT_TYPE, Consts.UTF_8));
+ URLEncodedUtils.CONTENT_TYPE, StandardCharsets.UTF_8));
final List result = URLEncodedUtils.parse(entity);
Assert.assertEquals(2, result.size());
assertNameValuePair(result.get(0), "russian", ru_hello);
@@ -230,9 +229,9 @@ public class TestURLEncodedUtils {
parameters.add(new BasicNameValuePair("russian", ru_hello));
parameters.add(new BasicNameValuePair("swiss", ch_hello));
- final String s = URLEncodedUtils.format(parameters, Consts.UTF_8);
+ final String s = URLEncodedUtils.format(parameters, StandardCharsets.UTF_8);
- final List result = URLEncodedUtils.parse(s, Consts.UTF_8);
+ final List result = URLEncodedUtils.parse(s, StandardCharsets.UTF_8);
Assert.assertEquals(2, result.size());
assertNameValuePair(result.get(0), "russian", ru_hello);
assertNameValuePair(result.get(1), "swiss", ch_hello);
@@ -255,15 +254,17 @@ public class TestURLEncodedUtils {
parameters.add(new BasicNameValuePair("russian", ru_hello));
parameters.add(new BasicNameValuePair("swiss", ch_hello));
- final String s = URLEncodedUtils.format(parameters, parameterSeparator, Consts.UTF_8);
+ final String s = URLEncodedUtils.format(parameters, parameterSeparator, StandardCharsets.UTF_8);
- final List result1 = URLEncodedUtils.parse(s, Consts.UTF_8);
+ final List result1 = URLEncodedUtils.parse(s, StandardCharsets.UTF_8);
Assert.assertEquals(2, result1.size());
assertNameValuePair(result1.get(0), "russian", ru_hello);
assertNameValuePair(result1.get(1), "swiss", ch_hello);
- final List result2 = URLEncodedUtils.parse(s, Consts.UTF_8, parameterSeparator);
- Assert.assertEquals(result1, result2);
+ final List result2 = URLEncodedUtils.parse(s, StandardCharsets.UTF_8, parameterSeparator);
+ Assert.assertEquals(2, result2.size());
+ assertNameValuePair(result2.get(0), "russian", ru_hello);
+ assertNameValuePair(result2.get(1), "swiss", ch_hello);
}
@Test
@@ -274,12 +275,12 @@ public class TestURLEncodedUtils {
parameters.add(new BasicNameValuePair("english", us_hello));
parameters.add(new BasicNameValuePair("swiss", ch_hello));
- final String s = URLEncodedUtils.format(parameters, HTTP.DEF_CONTENT_CHARSET);
+ final String s = URLEncodedUtils.format(parameters, StandardCharsets.ISO_8859_1);
Assert.assertEquals("english=hi+there&swiss=Gr%FCezi_z%E4m%E4", s);
final StringEntity entity = new StringEntity(s, ContentType.create(
- URLEncodedUtils.CONTENT_TYPE, HTTP.DEF_CONTENT_CHARSET));
+ URLEncodedUtils.CONTENT_TYPE, StandardCharsets.ISO_8859_1));
final List result = URLEncodedUtils.parse(entity);
Assert.assertEquals(2, result.size());
assertNameValuePair(result.get(0), "english", us_hello);
@@ -303,48 +304,48 @@ public class TestURLEncodedUtils {
@Test
public void testFormat() throws Exception {
final List params = new ArrayList<>();
- Assert.assertEquals(0, URLEncodedUtils.format(params, Consts.ASCII).length());
+ Assert.assertEquals(0, URLEncodedUtils.format(params, StandardCharsets.US_ASCII).length());
params.clear();
params.add(new BasicNameValuePair("Name0", null));
- Assert.assertEquals("Name0", URLEncodedUtils.format(params, Consts.ASCII));
+ Assert.assertEquals("Name0", URLEncodedUtils.format(params, StandardCharsets.US_ASCII));
params.clear();
params.add(new BasicNameValuePair("Name1", "Value1"));
- Assert.assertEquals("Name1=Value1", URLEncodedUtils.format(params, Consts.ASCII));
+ Assert.assertEquals("Name1=Value1", URLEncodedUtils.format(params, StandardCharsets.US_ASCII));
params.clear();
params.add(new BasicNameValuePair("Name2", ""));
- Assert.assertEquals("Name2=", URLEncodedUtils.format(params, Consts.ASCII));
+ Assert.assertEquals("Name2=", URLEncodedUtils.format(params, StandardCharsets.US_ASCII));
params.clear();
params.add(new BasicNameValuePair("Name4", "Value 4&"));
- Assert.assertEquals("Name4=Value+4%26", URLEncodedUtils.format(params, Consts.ASCII));
+ Assert.assertEquals("Name4=Value+4%26", URLEncodedUtils.format(params, StandardCharsets.US_ASCII));
params.clear();
params.add(new BasicNameValuePair("Name4", "Value+4&"));
- Assert.assertEquals("Name4=Value%2B4%26", URLEncodedUtils.format(params, Consts.ASCII));
+ Assert.assertEquals("Name4=Value%2B4%26", URLEncodedUtils.format(params, StandardCharsets.US_ASCII));
params.clear();
params.add(new BasicNameValuePair("Name4", "Value 4& =4"));
- Assert.assertEquals("Name4=Value+4%26+%3D4", URLEncodedUtils.format(params, Consts.ASCII));
+ Assert.assertEquals("Name4=Value+4%26+%3D4", URLEncodedUtils.format(params, StandardCharsets.US_ASCII));
params.clear();
params.add(new BasicNameValuePair("Name5", "aaa"));
params.add(new BasicNameValuePair("Name6", "bbb"));
- Assert.assertEquals("Name5=aaa&Name6=bbb", URLEncodedUtils.format(params, Consts.ASCII));
+ Assert.assertEquals("Name5=aaa&Name6=bbb", URLEncodedUtils.format(params, StandardCharsets.US_ASCII));
params.clear();
params.add(new BasicNameValuePair("Name7", "aaa"));
params.add(new BasicNameValuePair("Name7", "b,b"));
params.add(new BasicNameValuePair("Name7", "ccc"));
- Assert.assertEquals("Name7=aaa&Name7=b%2Cb&Name7=ccc", URLEncodedUtils.format(params, Consts.ASCII));
- Assert.assertEquals("Name7=aaa&Name7=b%2Cb&Name7=ccc", URLEncodedUtils.format(params, '&', Consts.ASCII));
- Assert.assertEquals("Name7=aaa;Name7=b%2Cb;Name7=ccc", URLEncodedUtils.format(params, ';', Consts.ASCII));
+ Assert.assertEquals("Name7=aaa&Name7=b%2Cb&Name7=ccc", URLEncodedUtils.format(params, StandardCharsets.US_ASCII));
+ Assert.assertEquals("Name7=aaa&Name7=b%2Cb&Name7=ccc", URLEncodedUtils.format(params, '&', StandardCharsets.US_ASCII));
+ Assert.assertEquals("Name7=aaa;Name7=b%2Cb;Name7=ccc", URLEncodedUtils.format(params, ';', StandardCharsets.US_ASCII));
params.clear();
params.add(new BasicNameValuePair("Name8", "xx, yy ,zz"));
- Assert.assertEquals("Name8=xx%2C++yy++%2Czz", URLEncodedUtils.format(params, Consts.ASCII));
+ Assert.assertEquals("Name8=xx%2C++yy++%2Czz", URLEncodedUtils.format(params, StandardCharsets.US_ASCII));
}
@Test
@@ -393,7 +394,7 @@ public class TestURLEncodedUtils {
}
private List parse (final String params) {
- return URLEncodedUtils.parse(params, Consts.UTF_8);
+ return URLEncodedUtils.parse(params, StandardCharsets.UTF_8);
}
private List parseString (final String uri) throws Exception {
diff --git a/httpclient/src/test/java/org/apache/http/conn/TestExceptions.java b/httpclient/src/test/java/org/apache/http/conn/TestExceptions.java
index 7b13e65e8..16f88ec14 100644
--- a/httpclient/src/test/java/org/apache/http/conn/TestExceptions.java
+++ b/httpclient/src/test/java/org/apache/http/conn/TestExceptions.java
@@ -27,13 +27,13 @@
package org.apache.http.conn;
-import org.apache.http.HttpHost;
-import org.junit.Assert;
-import org.junit.Test;
-
import java.io.IOException;
import java.net.InetAddress;
+import org.apache.hc.core5.http.HttpHost;
+import org.junit.Assert;
+import org.junit.Test;
+
/**
* Unit tests for exceptions.
* Trivial, but it looks better in the Clover reports.
diff --git a/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java b/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java
index d55efffd0..c16de8402 100644
--- a/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java
+++ b/httpclient/src/test/java/org/apache/http/conn/routing/TestHttpRoute.java
@@ -32,7 +32,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.apache.http.conn.routing.RouteInfo.LayerType;
import org.apache.http.conn.routing.RouteInfo.TunnelType;
import org.junit.Assert;
diff --git a/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteDirector.java b/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteDirector.java
index 802ab9578..e9b7e66c1 100644
--- a/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteDirector.java
+++ b/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteDirector.java
@@ -29,7 +29,7 @@ package org.apache.http.conn.routing;
import java.net.InetAddress;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.apache.http.conn.routing.RouteInfo.LayerType;
import org.apache.http.conn.routing.RouteInfo.TunnelType;
import org.junit.Assert;
diff --git a/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java b/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java
index 35298f7f3..2fa399ca7 100644
--- a/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java
+++ b/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java
@@ -31,7 +31,7 @@ import java.net.InetAddress;
import java.util.HashSet;
import java.util.Set;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.apache.http.conn.routing.RouteInfo.LayerType;
import org.apache.http.conn.routing.RouteInfo.TunnelType;
import org.junit.Assert;
diff --git a/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java b/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
index a7c5f4af8..30b1bada3 100644
--- a/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
+++ b/httpclient/src/test/java/org/apache/http/conn/ssl/TestSSLSocketFactory.java
@@ -41,15 +41,16 @@ import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
-import org.apache.http.HttpHost;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.SSLServerSetupHandler;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.bootstrap.io.HttpServer;
+import org.apache.hc.core5.http.bootstrap.io.SSLServerSetupHandler;
+import org.apache.hc.core5.http.bootstrap.io.ServerBootstrap;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.ssl.SSLContexts;
+import org.apache.hc.core5.ssl.TrustStrategy;
import org.apache.http.localserver.LocalServerTestBase;
import org.apache.http.localserver.SSLTestContexts;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.ssl.SSLContexts;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/conn/util/TestPublicSuffixListParser.java b/httpclient/src/test/java/org/apache/http/conn/util/TestPublicSuffixListParser.java
index 35ac9d57b..bc0096374 100644
--- a/httpclient/src/test/java/org/apache/http/conn/util/TestPublicSuffixListParser.java
+++ b/httpclient/src/test/java/org/apache/http/conn/util/TestPublicSuffixListParser.java
@@ -29,11 +29,11 @@ package org.apache.http.conn.util;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.apache.http.Consts;
import org.junit.Assert;
import org.junit.Test;
@@ -47,7 +47,7 @@ public class TestPublicSuffixListParser {
final PublicSuffixList suffixList;
try {
final PublicSuffixListParser parser = new PublicSuffixListParser();
- suffixList = parser.parse(new InputStreamReader(in, Consts.UTF_8));
+ suffixList = parser.parse(new InputStreamReader(in, StandardCharsets.UTF_8));
} finally {
in.close();
}
@@ -64,7 +64,7 @@ public class TestPublicSuffixListParser {
final List suffixLists;
try {
final PublicSuffixListParser parser = new PublicSuffixListParser();
- suffixLists = parser.parseByType(new InputStreamReader(in, Consts.UTF_8));
+ suffixLists = parser.parseByType(new InputStreamReader(in, StandardCharsets.UTF_8));
} finally {
in.close();
}
diff --git a/httpclient/src/test/java/org/apache/http/conn/util/TestPublicSuffixMatcher.java b/httpclient/src/test/java/org/apache/http/conn/util/TestPublicSuffixMatcher.java
index 8c124fff8..15ef98826 100644
--- a/httpclient/src/test/java/org/apache/http/conn/util/TestPublicSuffixMatcher.java
+++ b/httpclient/src/test/java/org/apache/http/conn/util/TestPublicSuffixMatcher.java
@@ -29,8 +29,8 @@ package org.apache.http.conn.util;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.Consts;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -49,7 +49,7 @@ public class TestPublicSuffixMatcher {
final PublicSuffixList suffixList;
try {
final PublicSuffixListParser parser = new PublicSuffixListParser();
- suffixList = parser.parse(new InputStreamReader(in, Consts.UTF_8));
+ suffixList = parser.parse(new InputStreamReader(in, StandardCharsets.UTF_8));
} finally {
in.close();
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/auth/TestAuthChallengeParser.java b/httpclient/src/test/java/org/apache/http/impl/auth/TestAuthChallengeParser.java
index ac7259452..a60b2cf15 100644
--- a/httpclient/src/test/java/org/apache/http/impl/auth/TestAuthChallengeParser.java
+++ b/httpclient/src/test/java/org/apache/http/impl/auth/TestAuthChallengeParser.java
@@ -28,12 +28,12 @@ package org.apache.http.impl.auth;
import java.util.List;
-import org.apache.http.NameValuePair;
-import org.apache.http.ParseException;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
+import org.apache.hc.core5.http.message.ParserCursor;
+import org.apache.hc.core5.util.CharArrayBuffer;
import org.apache.http.auth.AuthChallenge;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.util.CharArrayBuffer;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -160,7 +160,7 @@ public class TestAuthChallengeParser {
final List params = challenge1.getParams();
Assert.assertNotNull(params);
Assert.assertEquals(1, params.size());
- Assert.assertEquals(new BasicNameValuePair("realm", "blah"), params.get(0));
+ assertNameValuePair(new BasicNameValuePair("realm", "blah"), params.get(0));
}
@Test
@@ -177,7 +177,7 @@ public class TestAuthChallengeParser {
final List params = challenge1.getParams();
Assert.assertNotNull(params);
Assert.assertEquals(1, params.size());
- Assert.assertEquals(new BasicNameValuePair("realm", "blah"), params.get(0));
+ assertNameValuePair(new BasicNameValuePair("realm", "blah"), params.get(0));
}
@Test
@@ -217,9 +217,9 @@ public class TestAuthChallengeParser {
final List params1 = challenge1.getParams();
Assert.assertNotNull(params1);
Assert.assertEquals(3, params1.size());
- Assert.assertEquals(new BasicNameValuePair("realm", "blah"), params1.get(0));
- Assert.assertEquals(new BasicNameValuePair("param1", "this"), params1.get(1));
- Assert.assertEquals(new BasicNameValuePair("param2", "that"), params1.get(2));
+ assertNameValuePair(new BasicNameValuePair("realm", "blah"), params1.get(0));
+ assertNameValuePair(new BasicNameValuePair("param1", "this"), params1.get(1));
+ assertNameValuePair(new BasicNameValuePair("param2", "that"), params1.get(2));
final AuthChallenge challenge2 = challenges.get(1);
Assert.assertEquals("Basic", challenge2.getScheme());
@@ -227,10 +227,10 @@ public class TestAuthChallengeParser {
final List params2 = challenge2.getParams();
Assert.assertNotNull(params2);
Assert.assertEquals(4, params2.size());
- Assert.assertEquals(new BasicNameValuePair("realm", "\"yada\""), params2.get(0));
- Assert.assertEquals(new BasicNameValuePair("this", null), params2.get(1));
- Assert.assertEquals(new BasicNameValuePair("that", ""), params2.get(2));
- Assert.assertEquals(new BasicNameValuePair("this-and-that", null), params2.get(3));
+ assertNameValuePair(new BasicNameValuePair("realm", "\"yada\""), params2.get(0));
+ assertNameValuePair(new BasicNameValuePair("this", null), params2.get(1));
+ assertNameValuePair(new BasicNameValuePair("that", ""), params2.get(2));
+ assertNameValuePair(new BasicNameValuePair("this-and-that", null), params2.get(3));
}
@Test
@@ -302,8 +302,16 @@ public class TestAuthChallengeParser {
final List params1 = challenge1.getParams();
Assert.assertNotNull(params1);
Assert.assertEquals(2, params1.size());
- Assert.assertEquals(new BasicNameValuePair("blah", null), params1.get(0));
- Assert.assertEquals(new BasicNameValuePair("blah", null), params1.get(1));
+ assertNameValuePair(new BasicNameValuePair("blah", null), params1.get(0));
+ assertNameValuePair(new BasicNameValuePair("blah", null), params1.get(1));
+ }
+
+ private static void assertNameValuePair (
+ final NameValuePair expected,
+ final NameValuePair result) {
+ Assert.assertNotNull(result);
+ Assert.assertEquals(expected.getName(), result.getName());
+ Assert.assertEquals(expected.getValue(), result.getValue());
}
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java b/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java
index b94f5261e..b4365c642 100644
--- a/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java
+++ b/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java
@@ -30,21 +30,21 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.nio.charset.StandardCharsets;
import java.util.List;
import org.apache.commons.codec.binary.Base64;
-import org.apache.http.Consts;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.ParserCursor;
+import org.apache.hc.core5.util.CharArrayBuffer;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.util.CharArrayBuffer;
-import org.apache.http.util.EncodingUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -53,7 +53,7 @@ import org.junit.Test;
*/
public class TestBasicScheme {
- private static AuthChallenge parse(final String s) {
+ private static AuthChallenge parse(final String s) throws ParseException {
final CharArrayBuffer buffer = new CharArrayBuffer(s.length());
buffer.append(s);
final ParserCursor cursor = new ParserCursor(0, buffer.length());
@@ -84,7 +84,7 @@ public class TestBasicScheme {
final UsernamePasswordCredentials creds = new UsernamePasswordCredentials("dh", buffer.toString().toCharArray());
final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(authScope, creds);
- final BasicScheme authscheme = new BasicScheme(Consts.ISO_8859_1);
+ final BasicScheme authscheme = new BasicScheme(StandardCharsets.ISO_8859_1);
Assert.assertTrue(authscheme.isResponseReady(host, credentialsProvider, null));
final HttpRequest request = new BasicHttpRequest("GET", "/");
@@ -109,8 +109,9 @@ public class TestBasicScheme {
Assert.assertTrue(authscheme.isResponseReady(host, credentialsProvider, null));
final String authResponse = authscheme.generateAuthResponse(host, request, null);
- final String expected = "Basic " + EncodingUtils.getAsciiString(
- Base64.encodeBase64(EncodingUtils.getAsciiBytes("testuser:testpass")));
+ final String expected = "Basic " + new String(
+ Base64.encodeBase64("testuser:testpass".getBytes(StandardCharsets.US_ASCII)),
+ StandardCharsets.US_ASCII);
Assert.assertEquals(expected, authResponse);
Assert.assertEquals("test", authscheme.getRealm());
Assert.assertTrue(authscheme.isChallengeComplete());
@@ -134,8 +135,9 @@ public class TestBasicScheme {
Assert.assertTrue(authscheme.isResponseReady(host, credentialsProvider, null));
final String authResponse = authscheme.generateAuthResponse(host, request, null);
- final String expected = "Basic " + EncodingUtils.getAsciiString(
- Base64.encodeBase64(EncodingUtils.getAsciiBytes("testuser:testpass")));
+ final String expected = "Basic " + new String(
+ Base64.encodeBase64("testuser:testpass".getBytes(StandardCharsets.US_ASCII)),
+ StandardCharsets.US_ASCII);
Assert.assertEquals(expected, authResponse);
Assert.assertEquals("test", authscheme.getRealm());
Assert.assertTrue(authscheme.isChallengeComplete());
diff --git a/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java b/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
index 555f6e2e8..cff223e7e 100644
--- a/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
+++ b/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
@@ -31,15 +31,22 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.message.BasicHeaderValueParser;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.ParserCursor;
+import org.apache.hc.core5.util.CharArrayBuffer;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthScope;
@@ -47,15 +54,7 @@ import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.message.BasicHeaderValueParser;
-import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.CharArrayBuffer;
import org.junit.Assert;
import org.junit.Test;
@@ -64,7 +63,7 @@ import org.junit.Test;
*/
public class TestDigestScheme {
- private static AuthChallenge parse(final String s) {
+ private static AuthChallenge parse(final String s) throws ParseException {
final CharArrayBuffer buffer = new CharArrayBuffer(s.length());
buffer.append(s);
final ParserCursor cursor = new ParserCursor(0, buffer.length());
@@ -434,11 +433,13 @@ public class TestDigestScheme {
Assert.assertFalse(authscheme.isChallengeComplete());
}
- private static Map parseAuthResponse(final String authResponse) {
+ private static Map parseAuthResponse(final String authResponse) throws ParseException {
if (!authResponse.startsWith("Digest ")) {
return null;
}
- final HeaderElement[] elements = BasicHeaderValueParser.parseElements(authResponse.substring(7), null);
+ final String s = authResponse.substring(7);
+ final ParserCursor cursor = new ParserCursor(0, s.length());
+ final HeaderElement[] elements = BasicHeaderValueParser.INSTANCE.parseElements(s, cursor);
final Map map = new HashMap<>(elements.length);
for (final HeaderElement element : elements) {
map.put(element.getName(), element.getValue());
@@ -582,8 +583,8 @@ public class TestDigestScheme {
@Test
public void testDigestAuthenticationQopAuthInt() throws Exception {
- final HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("Post", "/");
- request.setEntity(new StringEntity("abc\u00e4\u00f6\u00fcabc", HTTP.DEF_CONTENT_CHARSET));
+ final HttpRequest request = new BasicHttpRequest("Post", "/");
+ request.setEntity(new StringEntity("abc\u00e4\u00f6\u00fcabc", StandardCharsets.ISO_8859_1));
final HttpHost host = new HttpHost("somehost", 80);
final AuthScope authScope = new AuthScope(host, "realm1", null);
final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
@@ -610,7 +611,7 @@ public class TestDigestScheme {
@Test
public void testDigestAuthenticationQopAuthIntNullEntity() throws Exception {
- final HttpRequest request = new BasicHttpEntityEnclosingRequest("Post", "/");
+ final HttpRequest request = new BasicHttpRequest("Post", "/");
final HttpHost host = new HttpHost("somehost", 80);
final AuthScope authScope = new AuthScope(host, "realm1", null);
final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
@@ -618,7 +619,7 @@ public class TestDigestScheme {
credentialsProvider.setCredentials(authScope, creds);
final String challenge = "Digest realm=\"realm1\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\", " +
- "qop=\"auth,auth-int\"";
+ "qop=\"auth-int\"";
final AuthChallenge authChallenge = parse(challenge);
final DigestScheme authscheme = new DigestScheme();
authscheme.processChallenge(authChallenge, null);
@@ -637,7 +638,7 @@ public class TestDigestScheme {
@Test
public void testDigestAuthenticationQopAuthOrAuthIntNonRepeatableEntity() throws Exception {
- final HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("Post", "/");
+ final HttpRequest request = new BasicHttpRequest("Post", "/");
request.setEntity(new InputStreamEntity(new ByteArrayInputStream(new byte[] {'a'}), -1));
final HttpHost host = new HttpHost("somehost", 80);
final AuthScope authScope = new AuthScope(host, "realm1", null);
@@ -686,7 +687,7 @@ public class TestDigestScheme {
@Test(expected=AuthenticationException.class)
public void testDigestAuthenticationQopIntOnlyNonRepeatableEntity() throws Exception {
- final HttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("Post", "/");
+ final HttpRequest request = new BasicHttpRequest("Post", "/");
request.setEntity(new InputStreamEntity(new ByteArrayInputStream(new byte[] {'a'}), -1));
final HttpHost host = new HttpHost("somehost", 80);
final AuthScope authScope = new AuthScope(host, "realm1", null);
diff --git a/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java b/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java
index c2b3b8b51..819f66ec1 100644
--- a/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java
+++ b/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java
@@ -29,16 +29,24 @@ package org.apache.http.impl.auth;
import java.util.LinkedList;
import java.util.Queue;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.ChallengeType;
import org.apache.http.auth.Credentials;
@@ -46,15 +54,7 @@ import org.apache.http.auth.CredentialsProvider;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.RegistryBuilder;
import org.apache.http.impl.client.DefaultAuthenticationStrategy;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpCoreContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java b/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java
index 1d7ab90d3..6cc776055 100644
--- a/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java
+++ b/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java
@@ -26,7 +26,8 @@
*/
package org.apache.http.impl.auth;
-import org.apache.http.Consts;
+import java.nio.charset.StandardCharsets;
+
import org.junit.Assert;
import org.junit.Test;
@@ -70,7 +71,7 @@ public class TestNTLMEngineImpl {
static void checkMD4(final String input, final String hexOutput) throws Exception {
NTLMEngineImpl.MD4 md4;
md4 = new NTLMEngineImpl.MD4();
- md4.update(input.getBytes(Consts.ASCII));
+ md4.update(input.getBytes(StandardCharsets.US_ASCII));
final byte[] answer = md4.getOutput();
final byte[] correctAnswer = toBytes(hexOutput);
if (answer.length != correctAnswer.length) {
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java b/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
index a4529258d..7dcec597d 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
@@ -29,9 +29,9 @@ package org.apache.http.impl.client;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.apache.hc.core5.pool.ConnPoolControl;
+import org.apache.hc.core5.pool.PoolStats;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.pool.ConnPoolControl;
-import org.apache.http.pool.PoolStats;
public final class MockConnPoolControl implements ConnPoolControl {
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java b/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java
index 06dec0f06..7f0141b81 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java
@@ -31,7 +31,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Random;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.apache.http.client.BackoffManager;
import org.apache.http.conn.routing.HttpRoute;
import org.junit.Before;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestAbstractResponseHandler.java b/httpclient/src/test/java/org/apache/http/impl/client/TestAbstractResponseHandler.java
index 6a2930c5c..ba24a7633 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestAbstractResponseHandler.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestAbstractResponseHandler.java
@@ -30,14 +30,14 @@ package org.apache.http.impl.client;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
-import org.apache.http.StatusLine;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.StatusLine;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.message.BasicStatusLine;
import org.apache.http.client.HttpResponseException;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.message.BasicStatusLine;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
@@ -59,7 +59,7 @@ public class TestAbstractResponseHandler {
@Override
public Integer handleEntity(final HttpEntity entity) throws IOException {
- return Integer.valueOf(EntityUtils.toString(entity));
+ return Integer.valueOf(new String(EntityUtils.toByteArray(entity)));
}
};
final Integer number = handler.handleResponse(response);
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestAuthenticationStrategy.java b/httpclient/src/test/java/org/apache/http/impl/client/TestAuthenticationStrategy.java
index 5b1cdd62a..5489c8d9d 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestAuthenticationStrategy.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestAuthenticationStrategy.java
@@ -32,6 +32,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
@@ -41,13 +44,10 @@ import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.auth.BasicSchemeFactory;
import org.apache.http.impl.auth.DigestScheme;
import org.apache.http.impl.auth.DigestSchemeFactory;
-import org.apache.http.message.BasicNameValuePair;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestBasicAuthCache.java b/httpclient/src/test/java/org/apache/http/impl/client/TestBasicAuthCache.java
index 702ca82c5..178837460 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestBasicAuthCache.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestBasicAuthCache.java
@@ -27,7 +27,7 @@
package org.apache.http.impl.client;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.apache.http.auth.AuthScheme;
import org.apache.http.conn.SchemePortResolver;
import org.apache.http.impl.auth.BasicScheme;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java b/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java
index c899cb550..ae091a305 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestBasicCredentialsProvider.java
@@ -26,7 +26,7 @@
*/
package org.apache.http.impl.client;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java b/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java
index 8a4f0ed61..c66a65744 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestBasicResponseHandler.java
@@ -29,13 +29,13 @@ package org.apache.http.impl.client;
import java.io.InputStream;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
-import org.apache.http.StatusLine;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.StatusLine;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.message.BasicStatusLine;
import org.apache.http.client.HttpResponseException;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.message.BasicStatusLine;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestCloseableHttpClient.java b/httpclient/src/test/java/org/apache/http/impl/client/TestCloseableHttpClient.java
index 766f2338d..19598fcac 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestCloseableHttpClient.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestCloseableHttpClient.java
@@ -29,15 +29,15 @@ package org.apache.http.impl.client;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -55,7 +55,7 @@ public class TestCloseableHttpClient {
protected CloseableHttpResponse doExecute(
final HttpHost target,
final HttpRequest request,
- final HttpContext context) throws IOException, ClientProtocolException {
+ final HttpContext context) throws IOException {
return null;
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java b/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java
index 36228ddf5..ea2fb81ef 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java
@@ -32,12 +32,12 @@ import static org.junit.Assert.assertTrue;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.ConnectionBackoffStrategy;
import org.apache.http.conn.ConnectionPoolTimeoutException;
-import org.apache.http.message.BasicHttpResponse;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java b/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java
index 479fdd44b..db732391c 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultConnKeepAliveStrategy.java
@@ -26,14 +26,14 @@
*/
package org.apache.http.impl.client;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.message.BasicStatusLine;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.message.BasicStatusLine;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultRedirectStrategy.java b/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultRedirectStrategy.java
index eeb27bcc7..bc5454573 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultRedirectStrategy.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultRedirectStrategy.java
@@ -29,15 +29,19 @@ package org.apache.http.impl.client;
import java.net.URI;
import java.util.List;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolException;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.entity.BasicHttpEntity;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
@@ -45,11 +49,6 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpTrace;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.entity.BasicHttpEntity;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpCoreContext;
import org.junit.Assert;
import org.junit.Test;
@@ -355,8 +354,7 @@ public class TestDefaultRedirectStrategy {
final HttpUriRequest redirect2 = redirectStrategy.getRedirect(
httppost, response, context2);
Assert.assertEquals("POST", redirect2.getMethod());
- Assert.assertTrue(redirect2 instanceof HttpEntityEnclosingRequest);
- Assert.assertSame(entity, ((HttpEntityEnclosingRequest) redirect2).getEntity());
+ Assert.assertSame(entity, redirect2.getEntity());
}
@Test
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultServiceUnavailableRetryStrategy.java b/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultServiceUnavailableRetryStrategy.java
index 0b2f2652e..0b659acd1 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultServiceUnavailableRetryStrategy.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultServiceUnavailableRetryStrategy.java
@@ -28,11 +28,11 @@ package org.apache.http.impl.client;
import java.util.Date;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.utils.DateUtils;
-import org.apache.http.message.BasicHttpResponse;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java b/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java
index 0714b0234..69718a89f 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestFutureRequestExecutionService.java
@@ -39,19 +39,18 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
+import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.bootstrap.io.HttpServer;
+import org.apache.hc.core5.http.bootstrap.io.ServerBootstrap;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.concurrent.FutureCallback;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -189,7 +188,7 @@ public class TestFutureRequestExecutionService {
private final class OkidokiHandler implements ResponseHandler {
@Override
public Boolean handleResponse(
- final HttpResponse response) throws ClientProtocolException, IOException {
+ final HttpResponse response) throws IOException {
return response.getStatusLine().getStatusCode() == 200;
}
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestInternalHttpClient.java b/httpclient/src/test/java/org/apache/http/impl/client/TestInternalHttpClient.java
index a8d68f31f..439bf45e7 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestInternalHttpClient.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestInternalHttpClient.java
@@ -30,8 +30,9 @@ import java.io.Closeable;
import java.io.IOException;
import java.util.Arrays;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.Lookup;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.client.ClientProtocolException;
@@ -40,7 +41,6 @@ import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Lookup;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRoutePlanner;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestNullBackoffStrategy.java b/httpclient/src/test/java/org/apache/http/impl/client/TestNullBackoffStrategy.java
index a83340fca..48c4f705c 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/TestNullBackoffStrategy.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/TestNullBackoffStrategy.java
@@ -28,10 +28,10 @@ package org.apache.http.impl.client;
import static org.junit.Assert.assertFalse;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
index 4758c7144..6206cbce5 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
@@ -33,30 +33,30 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolVersion;
+import org.apache.hc.core5.concurrent.Cancellable;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.io.UriHttpRequestHandlerMapper;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.concurrent.Cancellable;
import org.apache.http.conn.ConnectionPoolTimeoutException;
import org.apache.http.conn.ConnectionRequest;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.protocol.UriHttpRequestHandlerMapper;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestBasicConnectionManager.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestBasicConnectionManager.java
index 11bccb016..9aae1d2cb 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestBasicConnectionManager.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestBasicConnectionManager.java
@@ -26,12 +26,12 @@
*/
package org.apache.http.impl.client.integration;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
index 05342c043..750f625eb 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthentication.java
@@ -28,19 +28,35 @@ package org.apache.http.impl.client.integration;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.http.Consts;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpInetConnection;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.HttpConnection;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
+import org.apache.hc.core5.http.protocol.HttpExpectationVerifier;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessorBuilder;
+import org.apache.hc.core5.http.protocol.ResponseConnControl;
+import org.apache.hc.core5.http.protocol.ResponseContent;
+import org.apache.hc.core5.http.protocol.ResponseDate;
+import org.apache.hc.core5.http.protocol.ResponseServer;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthScope;
@@ -56,8 +72,6 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.StringEntity;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProvider;
@@ -66,19 +80,6 @@ import org.apache.http.localserver.BasicAuthTokenExtractor;
import org.apache.http.localserver.LocalServerTestBase;
import org.apache.http.localserver.RequestBasicAuth;
import org.apache.http.localserver.ResponseBasicUnauthorized;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpCoreContext;
-import org.apache.http.protocol.HttpExpectationVerifier;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpProcessorBuilder;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.protocol.ResponseConnControl;
-import org.apache.http.protocol.ResponseContent;
-import org.apache.http.protocol.ResponseDate;
-import org.apache.http.protocol.ResponseServer;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -113,7 +114,7 @@ public class TestClientAuthentication extends LocalServerTestBase {
response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
} else {
response.setStatusCode(HttpStatus.SC_OK);
- final StringEntity entity = new StringEntity("success", Consts.ASCII);
+ final StringEntity entity = new StringEntity("success", StandardCharsets.US_ASCII);
response.setEntity(entity);
}
}
@@ -303,7 +304,7 @@ public class TestClientAuthentication extends LocalServerTestBase {
final HttpHost target = start();
final HttpPost httppost = new HttpPost("/");
- httppost.setEntity(new StringEntity("some important stuff", Consts.ASCII));
+ httppost.setEntity(new StringEntity("some important stuff", StandardCharsets.US_ASCII));
final HttpClientContext context = HttpClientContext.create();
final TestCredentialsProvider credsProvider = new TestCredentialsProvider(
@@ -425,7 +426,7 @@ public class TestClientAuthentication extends LocalServerTestBase {
response.addHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"" + this.realm + "\"");
} else {
response.setStatusCode(HttpStatus.SC_OK);
- final StringEntity entity = new StringEntity("success", Consts.ASCII);
+ final StringEntity entity = new StringEntity("success", StandardCharsets.US_ASCII);
response.setEntity(entity);
}
}
@@ -523,9 +524,10 @@ public class TestClientAuthentication extends LocalServerTestBase {
final HttpRequest request,
final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
- final HttpInetConnection conn = (HttpInetConnection) context.getAttribute(HttpCoreContext.HTTP_CONNECTION);
- final String localhost = conn.getLocalAddress().getHostName();
- final int port = conn.getLocalPort();
+ final HttpConnection conn = (HttpConnection) context.getAttribute(HttpCoreContext.HTTP_CONNECTION);
+ final InetSocketAddress socketAddress = (InetSocketAddress) conn.getLocalAddress();
+ final String localhost = socketAddress.getHostName();
+ final int port = socketAddress.getPort();
response.setStatusCode(HttpStatus.SC_MOVED_PERMANENTLY);
response.addHeader(new BasicHeader("Location",
"http://test:test@" + localhost + ":" + port + "/"));
@@ -570,7 +572,7 @@ public class TestClientAuthentication extends LocalServerTestBase {
response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
} else {
response.setStatusCode(HttpStatus.SC_OK);
- final StringEntity entity = new StringEntity("success", Consts.ASCII);
+ final StringEntity entity = new StringEntity("success", StandardCharsets.US_ASCII);
response.setEntity(entity);
}
}
@@ -643,7 +645,7 @@ public class TestClientAuthentication extends LocalServerTestBase {
response.setStatusCode(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
} else {
response.setStatusCode(HttpStatus.SC_OK);
- final StringEntity entity = new StringEntity("success", Consts.ASCII);
+ final StringEntity entity = new StringEntity("success", StandardCharsets.US_ASCII);
response.setEntity(entity);
}
}
@@ -680,9 +682,9 @@ public class TestClientAuthentication extends LocalServerTestBase {
response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
} else {
response.setStatusCode(HttpStatus.SC_OK);
- final StringEntity entity = new StringEntity("success", Consts.ASCII);
+ final StringEntity entity = new StringEntity("success", StandardCharsets.US_ASCII);
response.setEntity(entity);
- response.setHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
+ response.setHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE);
}
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFakeNTLM.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFakeNTLM.java
index 64585fcfd..dad2bec3d 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFakeNTLM.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFakeNTLM.java
@@ -28,13 +28,17 @@ package org.apache.http.impl.client.integration;
import java.io.IOException;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.message.BasicStatusLine;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.NTCredentials;
import org.apache.http.client.methods.HttpGet;
@@ -42,10 +46,6 @@ import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.message.BasicStatusLine;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java
index 10d51ab08..f15f99968 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientAuthenticationFallBack.java
@@ -27,34 +27,34 @@
package org.apache.http.impl.client.integration;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.Consts;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessorBuilder;
+import org.apache.hc.core5.http.protocol.ResponseConnControl;
+import org.apache.hc.core5.http.protocol.ResponseContent;
+import org.apache.hc.core5.http.protocol.ResponseDate;
+import org.apache.hc.core5.http.protocol.ResponseServer;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.entity.StringEntity;
import org.apache.http.localserver.LocalServerTestBase;
import org.apache.http.localserver.RequestBasicAuth;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpProcessorBuilder;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.protocol.ResponseConnControl;
-import org.apache.http.protocol.ResponseContent;
-import org.apache.http.protocol.ResponseDate;
-import org.apache.http.protocol.ResponseServer;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -100,7 +100,7 @@ public class TestClientAuthenticationFallBack extends LocalServerTestBase {
response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
} else {
response.setStatusCode(HttpStatus.SC_OK);
- final StringEntity entity = new StringEntity("success", Consts.ASCII);
+ final StringEntity entity = new StringEntity("success", StandardCharsets.US_ASCII);
response.setEntity(entity);
}
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java
index 97848b601..d81f5e20f 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientReauthentication.java
@@ -27,18 +27,30 @@
package org.apache.http.impl.client.integration;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.http.Consts;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessorBuilder;
+import org.apache.hc.core5.http.protocol.ResponseConnControl;
+import org.apache.hc.core5.http.protocol.ResponseContent;
+import org.apache.hc.core5.http.protocol.ResponseDate;
+import org.apache.hc.core5.http.protocol.ResponseServer;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.auth.AuthScope;
@@ -49,22 +61,10 @@ import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.entity.StringEntity;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.auth.BasicSchemeFactory;
import org.apache.http.localserver.LocalServerTestBase;
import org.apache.http.localserver.RequestBasicAuth;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpProcessorBuilder;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.protocol.ResponseConnControl;
-import org.apache.http.protocol.ResponseContent;
-import org.apache.http.protocol.ResponseDate;
-import org.apache.http.protocol.ResponseServer;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -115,7 +115,7 @@ public class TestClientReauthentication extends LocalServerTestBase {
response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
} else {
response.setStatusCode(HttpStatus.SC_OK);
- final StringEntity entity = new StringEntity("success", Consts.ASCII);
+ final StringEntity entity = new StringEntity("success", StandardCharsets.US_ASCII);
response.setEntity(entity);
}
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java
index a41a89d36..f2afa0013 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java
@@ -31,14 +31,21 @@ import java.io.IOException;
import java.net.URI;
import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.NonRepeatableRequestException;
@@ -47,14 +54,7 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.client.utils.URIUtils;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.StringEntity;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java
index a4de80da2..a42d063bc 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionAutoRelease.java
@@ -32,25 +32,25 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.TimeUnit;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.MalformedChunkCodingException;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.MalformedChunkCodingException;
+import org.apache.hc.core5.http.entity.BasicHttpEntity;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.impl.io.DefaultBHttpServerConnection;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
+import org.apache.hc.core5.pool.PoolStats;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.ConnectionPoolTimeoutException;
import org.apache.http.conn.ConnectionRequest;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.entity.BasicHttpEntity;
-import org.apache.http.impl.DefaultBHttpServerConnection;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.pool.PoolStats;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpCoreContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
index e990d7a20..dbd38e18a 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
@@ -37,16 +37,25 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ImmutableHttpProcessor;
+import org.apache.hc.core5.http.protocol.RequestConnControl;
+import org.apache.hc.core5.http.protocol.RequestContent;
+import org.apache.hc.core5.http.protocol.RequestTargetHost;
import org.apache.http.conn.ConnectionPoolTimeoutException;
import org.apache.http.conn.ConnectionRequest;
import org.apache.http.conn.HttpClientConnectionManager;
@@ -55,16 +64,6 @@ import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpCoreContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.RequestConnControl;
-import org.apache.http.protocol.RequestContent;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -114,7 +113,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, target);
final HttpProcessor httpProcessor = new ImmutableHttpProcessor(
- new HttpRequestInterceptor[] { new RequestContent(), new RequestConnControl() });
+ new RequestTargetHost(), new RequestContent(), new RequestConnControl());
final HttpRequestExecutor exec = new HttpRequestExecutor();
exec.preProcess(request, httpProcessor, context);
@@ -203,7 +202,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, target);
final HttpProcessor httpProcessor = new ImmutableHttpProcessor(
- new HttpRequestInterceptor[] { new RequestContent(), new RequestConnControl() });
+ new RequestTargetHost(), new RequestContent(), new RequestConnControl());
final HttpRequestExecutor exec = new HttpRequestExecutor();
exec.preProcess(request, httpProcessor, context);
@@ -401,7 +400,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, target);
final HttpProcessor httpProcessor = new ImmutableHttpProcessor(
- new HttpRequestInterceptor[] { new RequestContent(), new RequestConnControl() });
+ new RequestTargetHost(), new RequestContent(), new RequestConnControl());
final HttpRequestExecutor exec = new HttpRequestExecutor();
exec.preProcess(request, httpProcessor, context);
@@ -654,7 +653,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
final HttpHost host,
final InetSocketAddress remoteAddress,
final InetSocketAddress localAddress,
- final HttpContext context) throws IOException, ConnectTimeoutException {
+ final HttpContext context) throws IOException {
if(waitPolicy == WaitPolicy.BEFORE_CONNECT) {
latch();
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionReuse.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionReuse.java
index b30ff0038..2b5ece43d 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionReuse.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionReuse.java
@@ -30,24 +30,25 @@ package org.apache.http.impl.client.integration;
import java.io.IOException;
import java.net.URI;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElements;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpProcessorBuilder;
+import org.apache.hc.core5.http.protocol.ResponseConnControl;
+import org.apache.hc.core5.http.protocol.ResponseContent;
+import org.apache.hc.core5.http.protocol.ResponseDate;
+import org.apache.hc.core5.http.protocol.ResponseServer;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.localserver.LocalServerTestBase;
import org.apache.http.localserver.RandomHandler;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpProcessorBuilder;
-import org.apache.http.protocol.ResponseConnControl;
-import org.apache.http.protocol.ResponseContent;
-import org.apache.http.protocol.ResponseDate;
-import org.apache.http.protocol.ResponseServer;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -99,7 +100,7 @@ public class TestConnectionReuse extends LocalServerTestBase {
public void process(
final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
- response.setHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
+ response.setHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE);
}
}
@@ -282,10 +283,10 @@ public class TestConnectionReuse extends LocalServerTestBase {
@Override
public void process(final HttpResponse response, final HttpContext context)
throws HttpException, IOException {
- final Header connection = response.getFirstHeader(HTTP.CONN_DIRECTIVE);
+ final Header connection = response.getFirstHeader(HttpHeaders.CONNECTION);
if(connection != null) {
if(!connection.getValue().equalsIgnoreCase("Close")) {
- response.addHeader(HTTP.CONN_KEEP_ALIVE, "timeout=1");
+ response.addHeader(HeaderElements.KEEP_ALIVE, "timeout=1");
}
}
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java
index cf6002cd8..aef9945aa 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java
@@ -31,6 +31,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -39,23 +40,22 @@ import java.util.concurrent.Executors;
import java.util.zip.Deflater;
import java.util.zip.GZIPOutputStream;
-import org.apache.http.Consts;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -305,7 +305,7 @@ public class TestContentCodings extends LocalServerTestBase {
// response.setEntity(new InputStreamEntity(new DeflaterInputStream(new
// ByteArrayInputStream(
// entityText.getBytes("utf-8"))), -1));
- final byte[] uncompressed = entityText.getBytes(Consts.UTF_8);
+ final byte[] uncompressed = entityText.getBytes(StandardCharsets.UTF_8);
final Deflater compressor = new Deflater(Deflater.DEFAULT_COMPRESSION, rfc1951);
compressor.setInput(uncompressed);
compressor.finish();
@@ -363,7 +363,7 @@ public class TestContentCodings extends LocalServerTestBase {
final OutputStream out = new GZIPOutputStream(bytes);
final ByteArrayInputStream uncompressed = new ByteArrayInputStream(
- entityText.getBytes(Consts.UTF_8));
+ entityText.getBytes(StandardCharsets.UTF_8));
final byte[] buf = new byte[60];
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookieVirtualHost.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookieVirtualHost.java
index fb14ffa40..592d578d3 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookieVirtualHost.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestCookieVirtualHost.java
@@ -30,12 +30,16 @@ import java.io.IOException;
import java.net.URI;
import java.util.List;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.CookieStore;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
@@ -43,10 +47,6 @@ import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestIdleConnectionEviction.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestIdleConnectionEviction.java
index eee9d36b0..6edecfb39 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestIdleConnectionEviction.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestIdleConnectionEviction.java
@@ -29,15 +29,15 @@ package org.apache.http.impl.client.integration;
import java.util.concurrent.TimeUnit;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.IdleConnectionEvictor;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.util.EntityUtils;
import org.junit.Test;
public class TestIdleConnectionEviction extends LocalServerTestBase {
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMalformedServerResponse.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMalformedServerResponse.java
index f6fe2b084..de5182531 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMalformedServerResponse.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMalformedServerResponse.java
@@ -29,20 +29,20 @@ package org.apache.http.impl.client.integration;
import java.io.IOException;
import java.net.Socket;
-import org.apache.http.HttpConnectionFactory;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.impl.io.DefaultBHttpServerConnection;
+import org.apache.hc.core5.http.io.HttpConnectionFactory;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.DefaultBHttpServerConnection;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMinimalClientRequestExecution.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMinimalClientRequestExecution.java
index c7a4f5872..8732780bf 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMinimalClientRequestExecution.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestMinimalClientRequestExecution.java
@@ -31,20 +31,20 @@ import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java
index 22af22922..225bc46cc 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java
@@ -27,18 +27,27 @@
package org.apache.http.impl.client.integration;
import java.io.IOException;
+import java.net.InetSocketAddress;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpInetConnection;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolException;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpConnection;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.io.UriHttpRequestHandlerMapper;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.http.client.CircularRedirectException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CookieStore;
@@ -48,17 +57,9 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URIUtils;
-import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpCoreContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.protocol.UriHttpRequestHandlerMapper;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -85,12 +86,13 @@ public class TestRedirects extends LocalServerTestBase {
final HttpRequest request,
final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
- final HttpInetConnection conn = (HttpInetConnection) context.getAttribute(HttpCoreContext.HTTP_CONNECTION);
- String localhost = conn.getLocalAddress().getHostName();
+ final HttpConnection conn = (HttpConnection) context.getAttribute(HttpCoreContext.HTTP_CONNECTION);
+ final InetSocketAddress socketAddress = (InetSocketAddress) conn.getLocalAddress();
+ String localhost = socketAddress.getHostName();
if (localhost.equals("127.0.0.1")) {
localhost = "localhost";
}
- final int port = conn.getLocalPort();
+ final int port = socketAddress.getPort();
final String uri = request.getRequestLine().getUri();
if (uri.equals("/oldlocation/")) {
response.setStatusCode(this.statuscode);
@@ -684,7 +686,7 @@ public class TestRedirects extends LocalServerTestBase {
@Test
public void testDefaultHeadersRedirect() throws Exception {
- this.clientBuilder.setDefaultHeaders(Arrays.asList(new BasicHeader(HTTP.USER_AGENT, "my-test-client")));
+ this.clientBuilder.setDefaultHeaders(Arrays.asList(new BasicHeader(HttpHeaders.USER_AGENT, "my-test-client")));
this.serverBootstrap.registerHandler("*", new BasicRedirectService());
@@ -703,7 +705,7 @@ public class TestRedirects extends LocalServerTestBase {
Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
- final Header header = reqWrapper.getFirstHeader(HTTP.USER_AGENT);
+ final Header header = reqWrapper.getFirstHeader(HttpHeaders.USER_AGENT);
Assert.assertEquals("my-test-client", header.getValue());
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java
index 35ae72205..87d584d5f 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestSPNegoScheme.java
@@ -29,28 +29,28 @@ package org.apache.http.impl.client.integration;
import java.io.IOException;
import java.security.Principal;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.config.Registry;
+import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.entity.StringEntity;
import org.apache.http.impl.auth.SPNegoScheme;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSManager;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java
index b3e32e163..0e5729c2a 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestStatefulConnManagement.java
@@ -28,23 +28,23 @@ package org.apache.http.impl.client.integration;
import java.io.IOException;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.HttpClient;
import org.apache.http.client.UserTokenHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.entity.StringEntity;
import org.apache.http.localserver.LocalServerTestBase;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/SessionInputBufferMock.java b/httpclient/src/test/java/org/apache/http/impl/conn/SessionInputBufferMock.java
index 15c9f20ce..c137cb511 100644
--- a/httpclient/src/test/java/org/apache/http/impl/conn/SessionInputBufferMock.java
+++ b/httpclient/src/test/java/org/apache/http/impl/conn/SessionInputBufferMock.java
@@ -28,17 +28,16 @@
package org.apache.http.impl.conn;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
-import org.apache.http.config.MessageConstraints;
-import org.apache.http.impl.io.HttpTransportMetricsImpl;
-import org.apache.http.impl.io.SessionInputBufferImpl;
+import org.apache.hc.core5.http.config.MessageConstraints;
+import org.apache.hc.core5.http.impl.io.HttpTransportMetricsImpl;
+import org.apache.hc.core5.http.impl.io.SessionInputBufferImpl;
/**
- * {@link org.apache.http.io.SessionInputBuffer} mockup implementation.
+ * {@link org.apache.hc.core5.http.io.SessionInputBuffer} mockup implementation.
*/
public class SessionInputBufferMock extends SessionInputBufferImpl {
@@ -102,9 +101,4 @@ public class SessionInputBufferMock extends SessionInputBufferImpl {
this(s.getBytes(charset), charset);
}
- @Override
- public boolean isDataAvailable(final int timeout) throws IOException {
- return true;
- }
-
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java b/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java
index b64bb7e52..7b8f5d192 100644
--- a/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java
+++ b/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java
@@ -32,12 +32,13 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.concurrent.TimeUnit;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.SocketConfig;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.SocketConfig;
import org.apache.http.conn.ConnectionRequest;
import org.apache.http.conn.DnsResolver;
import org.apache.http.conn.HttpConnectionFactory;
@@ -46,7 +47,6 @@ import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java b/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
index 207cddc30..05102581d 100644
--- a/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
+++ b/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultHttpResponseParser.java
@@ -27,24 +27,26 @@
package org.apache.http.impl.conn;
-import org.apache.http.Consts;
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
-import org.apache.http.NoHttpResponseException;
-import org.apache.http.ProtocolException;
-import org.apache.http.io.HttpMessageParser;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.util.CharArrayBuffer;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.MessageConstraintException;
+import org.apache.hc.core5.http.NoHttpResponseException;
+import org.apache.hc.core5.http.config.MessageConstraints;
+import org.apache.hc.core5.http.io.HttpMessageParser;
+import org.apache.hc.core5.http.io.SessionInputBuffer;
import org.junit.Assert;
+import org.junit.Ignore;
import org.junit.Test;
/**
- * Tests for {@link DefaultResponseParser}.
+ * Tests for {@link LenientHttpResponseParser}.
*/
public class TestDefaultHttpResponseParser {
- @Test
+ @Test @Ignore(value = "Requires a fix in DefaultHttpResponseParser")
public void testResponseParsingWithSomeGarbage() throws Exception {
final String s =
"garbage\r\n" +
@@ -55,10 +57,11 @@ public class TestDefaultHttpResponseParser {
"header2: value2\r\n" +
"\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
- final HttpMessageParser parser = new DefaultHttpResponseParser(inbuffer);
+ final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, StandardCharsets.US_ASCII);
+ final MessageConstraints messageConstraints = MessageConstraints.custom().setMaxEmptyLineCount(Integer.MAX_VALUE).build();
+ final HttpMessageParser parser = new LenientHttpResponseParser(messageConstraints);
- final HttpResponse response = parser.parse();
+ final HttpResponse response = parser.parse(inbuffer);
Assert.assertNotNull(response);
Assert.assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
@@ -70,7 +73,7 @@ public class TestDefaultHttpResponseParser {
Assert.assertEquals("header2", headers[1].getName());
}
- @Test(expected=ProtocolException.class)
+ @Test(expected=MessageConstraintException.class)
public void testResponseParsingWithTooMuchGarbage() throws Exception {
final String s =
"garbage\r\n" +
@@ -81,35 +84,29 @@ public class TestDefaultHttpResponseParser {
"header2: value2\r\n" +
"\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
- final HttpMessageParser parser = new DefaultHttpResponseParser(inbuffer) {
-
- @Override
- protected boolean reject(final CharArrayBuffer line, final int count) {
- return count >= 2;
- }
-
- };
- parser.parse();
+ final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, StandardCharsets.US_ASCII);
+ final MessageConstraints messageConstraints = MessageConstraints.custom().setMaxEmptyLineCount(2).build();
+ final HttpMessageParser parser = new LenientHttpResponseParser(messageConstraints);
+ parser.parse(inbuffer);
}
@Test(expected=NoHttpResponseException.class)
public void testResponseParsingNoResponse() throws Exception {
- final SessionInputBuffer inbuffer = new SessionInputBufferMock("", Consts.ASCII);
- final HttpMessageParser parser = new DefaultHttpResponseParser(inbuffer);
- parser.parse();
+ final SessionInputBuffer inbuffer = new SessionInputBufferMock("", StandardCharsets.US_ASCII);
+ final HttpMessageParser parser = new LenientHttpResponseParser(MessageConstraints.DEFAULT);
+ parser.parse(inbuffer);
}
- @Test(expected=ProtocolException.class)
+ @Test(expected=MessageConstraintException.class)
public void testResponseParsingOnlyGarbage() throws Exception {
final String s =
"garbage\r\n" +
"garbage\r\n" +
"more garbage\r\n" +
"a lot more garbage\r\n";
- final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
- final HttpMessageParser parser = new DefaultHttpResponseParser(inbuffer);
- parser.parse();
+ final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, StandardCharsets.US_ASCII);
+ final HttpMessageParser parser = new LenientHttpResponseParser(MessageConstraints.DEFAULT);
+ parser.parse(inbuffer);
}
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultProxyRoutePlanner.java b/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultProxyRoutePlanner.java
index 6c78ab1ee..e46aaf22d 100644
--- a/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultProxyRoutePlanner.java
+++ b/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultProxyRoutePlanner.java
@@ -27,16 +27,16 @@
package org.apache.http.impl.conn;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultRoutePlanner.java b/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultRoutePlanner.java
index 611d0e721..9c0c8dada 100644
--- a/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultRoutePlanner.java
+++ b/httpclient/src/test/java/org/apache/http/impl/conn/TestDefaultRoutePlanner.java
@@ -27,17 +27,17 @@
package org.apache.http.impl.conn;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java b/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
index 42aa33704..230364c45 100644
--- a/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
+++ b/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
@@ -33,19 +33,19 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
-import org.apache.http.HttpHost;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.SocketConfig;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.SocketConfig;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.DnsResolver;
import org.apache.http.conn.HttpHostConnectException;
-import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.ManagedHttpClientConnection;
+import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.UnsupportedSchemeException;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java b/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java
index 5b379d3a3..601745df8 100644
--- a/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java
+++ b/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java
@@ -35,21 +35,21 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.SocketConfig;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.SocketConfig;
import org.apache.http.conn.ConnectionPoolTimeoutException;
import org.apache.http.conn.ConnectionRequest;
import org.apache.http.conn.DnsResolver;
-import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.ManagedHttpClientConnection;
+import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/TestSystemDefaultRoutePlanner.java b/httpclient/src/test/java/org/apache/http/impl/conn/TestSystemDefaultRoutePlanner.java
index 7936aab51..bded28db7 100644
--- a/httpclient/src/test/java/org/apache/http/impl/conn/TestSystemDefaultRoutePlanner.java
+++ b/httpclient/src/test/java/org/apache/http/impl/conn/TestSystemDefaultRoutePlanner.java
@@ -35,14 +35,14 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.List;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.BasicHttpContext;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.conn.SchemePortResolver;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/cookie/TestPublicSuffixListParser.java b/httpclient/src/test/java/org/apache/http/impl/cookie/TestPublicSuffixListParser.java
index 07b705307..d7b3fb022 100644
--- a/httpclient/src/test/java/org/apache/http/impl/cookie/TestPublicSuffixListParser.java
+++ b/httpclient/src/test/java/org/apache/http/impl/cookie/TestPublicSuffixListParser.java
@@ -29,8 +29,8 @@ package org.apache.http.impl.cookie;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.Consts;
import org.apache.http.conn.util.PublicSuffixList;
import org.apache.http.conn.util.PublicSuffixMatcher;
import org.apache.http.cookie.Cookie;
@@ -53,7 +53,7 @@ public class TestPublicSuffixListParser {
final PublicSuffixList suffixList;
try {
final org.apache.http.conn.util.PublicSuffixListParser parser = new org.apache.http.conn.util.PublicSuffixListParser();
- suffixList = parser.parse(new InputStreamReader(in, Consts.UTF_8));
+ suffixList = parser.parse(new InputStreamReader(in, StandardCharsets.UTF_8));
} finally {
in.close();
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java b/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java
index 4fdb9217b..986e712a6 100644
--- a/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java
+++ b/httpclient/src/test/java/org/apache/http/impl/cookie/TestRFC6265CookieSpec.java
@@ -30,13 +30,13 @@ package org.apache.http.impl.cookie;
import java.util.Arrays;
import java.util.List;
-import org.apache.http.Header;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.http.cookie.CommonCookieAttributeHandler;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SetCookie;
-import org.apache.http.message.BasicHeader;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestConnectionHolder.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestConnectionHolder.java
index a90814102..ba5efcca1 100644
--- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestConnectionHolder.java
+++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestConnectionHolder.java
@@ -30,7 +30,7 @@ import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
-import org.apache.http.HttpClientConnection;
+import org.apache.hc.core5.http.io.HttpClientConnection;
import org.apache.http.conn.HttpClientConnectionManager;
import org.junit.Assert;
import org.junit.Before;
diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java
index 543d35cd3..2cda03ebb 100644
--- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java
+++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java
@@ -36,15 +36,21 @@ import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.concurrent.Cancellable;
+import org.apache.hc.core5.http.ConnectionReuseStrategy;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.entity.StringEntity;
+import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.http.auth.AuthChallenge;
import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.AuthScheme;
@@ -62,22 +68,15 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.concurrent.Cancellable;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.ConnectionRequest;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.RouteInfo;
-import org.apache.http.entity.StringEntity;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.auth.NTLMScheme;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.conn.ConnectionShutdownException;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -142,7 +141,7 @@ public class TestMainClientExec {
.setConnectionRequestTimeout(345)
.build();
context.setRequestConfig(config);
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(requestExecutor.execute(
Mockito.same(request),
@@ -172,7 +171,7 @@ public class TestMainClientExec {
public void testExecRequestPersistentConnection() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
@@ -182,6 +181,7 @@ public class TestMainClientExec {
Mockito.any(),
Mockito.any())).thenReturn(response);
Mockito.when(reuseStrategy.keepAlive(
+ Mockito.same(request),
Mockito.same(response),
Mockito.any())).thenReturn(Boolean.TRUE);
Mockito.when(keepAliveStrategy.getKeepAliveDuration(
@@ -204,7 +204,7 @@ public class TestMainClientExec {
public void testExecRequestPersistentStatefulConnection() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
@@ -214,6 +214,7 @@ public class TestMainClientExec {
Mockito.any(),
Mockito.any())).thenReturn(response);
Mockito.when(reuseStrategy.keepAlive(
+ Mockito.same(request),
Mockito.same(response),
Mockito.any())).thenReturn(Boolean.TRUE);
Mockito.when(userTokenHandler.getUserToken(
@@ -234,7 +235,7 @@ public class TestMainClientExec {
public void testExecRequestConnectionRelease() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
// The entity is streaming
response.setEntity(EntityBuilder.create()
@@ -248,6 +249,7 @@ public class TestMainClientExec {
Mockito.any(),
Mockito.any())).thenReturn(response);
Mockito.when(reuseStrategy.keepAlive(
+ Mockito.same(request),
Mockito.same(response),
Mockito.any())).thenReturn(Boolean.FALSE);
@@ -277,7 +279,7 @@ public class TestMainClientExec {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
final RequestConfig config = RequestConfig.custom().setSocketTimeout(3000).build();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
context.setRequestConfig(config);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(managedConn.isOpen()).thenReturn(true);
@@ -294,7 +296,7 @@ public class TestMainClientExec {
public void testSocketTimeoutReset() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
Mockito.when(requestExecutor.execute(
@@ -310,7 +312,7 @@ public class TestMainClientExec {
public void testExecAbortedPriorToConnectionLease() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.FALSE);
Mockito.when(execAware.isAborted()).thenReturn(Boolean.TRUE);
@@ -326,7 +328,7 @@ public class TestMainClientExec {
public void testExecAbortedPriorToConnectionSetup() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.FALSE);
Mockito.when(execAware.isAborted()).thenReturn(Boolean.FALSE, Boolean.TRUE);
@@ -348,7 +350,7 @@ public class TestMainClientExec {
public void testExecAbortedPriorToRequestExecution() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.FALSE);
Mockito.when(execAware.isAborted()).thenReturn(Boolean.FALSE, Boolean.FALSE, Boolean.TRUE);
@@ -369,7 +371,7 @@ public class TestMainClientExec {
public void testExecConnectionRequestFailed() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(connRequest.get(Mockito.anyInt(), Mockito.any()))
.thenThrow(new ExecutionException("Opppsie", null));
@@ -380,7 +382,7 @@ public class TestMainClientExec {
public void testExecRequestRetryOnAuthChallenge() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 401, "Huh?");
response1.setHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=test");
final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
@@ -404,6 +406,7 @@ public class TestMainClientExec {
Mockito.any(),
Mockito.any())).thenReturn(response1, response2);
Mockito.when(reuseStrategy.keepAlive(
+ Mockito.same(request),
Mockito.any(),
Mockito.any())).thenReturn(Boolean.TRUE);
Mockito.when(targetAuthStrategy.select(
@@ -424,7 +427,7 @@ public class TestMainClientExec {
@Test
public void testExecEntityEnclosingRequestRetryOnAuthChallenge() throws Exception {
final HttpRoute route = new HttpRoute(target, proxy);
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 401, "Huh?");
response1.setHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=test");
final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
@@ -455,6 +458,7 @@ public class TestMainClientExec {
Mockito.any(),
Mockito.any())).thenReturn(response1, response2);
Mockito.when(reuseStrategy.keepAlive(
+ Mockito.same(request),
Mockito.any(),
Mockito.any())).thenReturn(Boolean.FALSE);
@@ -483,7 +487,7 @@ public class TestMainClientExec {
post.setEntity(EntityBuilder.create()
.setStream(instream0)
.build());
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(post);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(post, target);
final HttpResponse response1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 401, "Huh?");
response1.setHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=test");
@@ -506,13 +510,14 @@ public class TestMainClientExec {
@Override
public HttpResponse answer(final InvocationOnMock invocationOnMock) throws Throwable {
final Object[] args = invocationOnMock.getArguments();
- final HttpEntityEnclosingRequest requestEE = (HttpEntityEnclosingRequest) args[0];
+ final HttpRequest requestEE = (HttpRequest) args[0];
requestEE.getEntity().writeTo(new ByteArrayOutputStream());
return response1;
}
});
Mockito.when(reuseStrategy.keepAlive(
+ Mockito.same(request),
Mockito.any(),
Mockito.any())).thenReturn(Boolean.TRUE);
@@ -528,7 +533,7 @@ public class TestMainClientExec {
public void testExecConnectionShutDown() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(requestExecutor.execute(
Mockito.any(),
@@ -542,7 +547,7 @@ public class TestMainClientExec {
public void testExecRuntimeException() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(requestExecutor.execute(
Mockito.any(),
@@ -562,7 +567,7 @@ public class TestMainClientExec {
public void testExecHttpException() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(requestExecutor.execute(
Mockito.any(),
@@ -582,7 +587,7 @@ public class TestMainClientExec {
public void testExecIOException() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(requestExecutor.execute(
Mockito.any(),
@@ -602,7 +607,7 @@ public class TestMainClientExec {
public void testEstablishDirectRoute() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
@@ -616,7 +621,7 @@ public class TestMainClientExec {
public void testEstablishRouteDirectProxy() throws Exception {
final HttpRoute route = new HttpRoute(target, null, proxy, false);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
@@ -634,7 +639,7 @@ public class TestMainClientExec {
.setConnectTimeout(321)
.build();
context.setRequestConfig(config);
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
@@ -663,7 +668,7 @@ public class TestMainClientExec {
public void testEstablishRouteViaProxyTunnelUnexpectedResponse() throws Exception {
final HttpRoute route = new HttpRoute(target, null, proxy, true);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 101, "Lost");
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
@@ -679,7 +684,7 @@ public class TestMainClientExec {
public void testEstablishRouteViaProxyTunnelFailure() throws Exception {
final HttpRoute route = new HttpRoute(target, null, proxy, true);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 500, "Boom");
response.setEntity(new StringEntity("Ka-boom"));
@@ -705,7 +710,7 @@ public class TestMainClientExec {
public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengePersistentConnection() throws Exception {
final HttpRoute route = new HttpRoute(target, null, proxy, true);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 407, "Huh?");
response1.setHeader(HttpHeaders.PROXY_AUTHENTICATE, "Basic realm=test");
final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
@@ -720,6 +725,7 @@ public class TestMainClientExec {
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
Mockito.when(reuseStrategy.keepAlive(
+ Mockito.same(request),
Mockito.any(),
Mockito.any())).thenReturn(Boolean.TRUE);
Mockito.when(requestExecutor.execute(
@@ -743,7 +749,7 @@ public class TestMainClientExec {
public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengeNonPersistentConnection() throws Exception {
final HttpRoute route = new HttpRoute(target, null, proxy, true);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, 407, "Huh?");
response1.setHeader(HttpHeaders.PROXY_AUTHENTICATE, "Basic realm=test");
final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
@@ -758,6 +764,7 @@ public class TestMainClientExec {
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
Mockito.when(reuseStrategy.keepAlive(
+ Mockito.same(request),
Mockito.any(),
Mockito.any())).thenReturn(Boolean.FALSE);
Mockito.when(requestExecutor.execute(
@@ -785,7 +792,7 @@ public class TestMainClientExec {
final HttpRoute route = new HttpRoute(target, null, new HttpHost[] {proxy1, proxy2},
true, RouteInfo.TunnelType.TUNNELLED, RouteInfo.LayerType.LAYERED);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestMinimalClientExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestMinimalClientExec.java
index 9a96ba686..fb34549ee 100644
--- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestMinimalClientExec.java
+++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestMinimalClientExec.java
@@ -32,13 +32,16 @@ import java.io.InterruptedIOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
+import org.apache.hc.core5.concurrent.Cancellable;
+import org.apache.hc.core5.http.ConnectionReuseStrategy;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
+import org.apache.hc.core5.http.io.HttpClientConnection;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.EntityBuilder;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -46,14 +49,11 @@ import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.concurrent.Cancellable;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.ConnectionRequest;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.conn.ConnectionShutdownException;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.protocol.HttpRequestExecutor;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -106,7 +106,7 @@ public class TestMinimalClientExec {
.setConnectionRequestTimeout(345)
.build();
context.setRequestConfig(config);
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(requestExecutor.execute(
Mockito.same(request),
@@ -135,7 +135,7 @@ public class TestMinimalClientExec {
public void testExecRequestPersistentConnection() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
@@ -145,6 +145,7 @@ public class TestMinimalClientExec {
Mockito.any(),
Mockito.any())).thenReturn(response);
Mockito.when(reuseStrategy.keepAlive(
+ Mockito.same(request),
Mockito.same(response),
Mockito.any())).thenReturn(Boolean.TRUE);
Mockito.when(keepAliveStrategy.getKeepAliveDuration(
@@ -167,7 +168,7 @@ public class TestMinimalClientExec {
public void testExecRequestConnectionRelease() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
// The entity is streaming
response.setEntity(EntityBuilder.create()
@@ -181,6 +182,7 @@ public class TestMinimalClientExec {
Mockito.any(),
Mockito.any())).thenReturn(response);
Mockito.when(reuseStrategy.keepAlive(
+ Mockito.same(request),
Mockito.same(response),
Mockito.any())).thenReturn(Boolean.FALSE);
@@ -210,7 +212,7 @@ public class TestMinimalClientExec {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
final RequestConfig config = RequestConfig.custom().setSocketTimeout(3000).build();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
context.setRequestConfig(config);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(managedConn.isOpen()).thenReturn(true);
@@ -227,7 +229,7 @@ public class TestMinimalClientExec {
public void testSocketTimeoutReset() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.TRUE);
Mockito.when(requestExecutor.execute(
@@ -243,7 +245,7 @@ public class TestMinimalClientExec {
public void testExecAbortedPriorToConnectionLease() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(managedConn.isOpen()).thenReturn(Boolean.FALSE);
Mockito.when(execAware.isAborted()).thenReturn(Boolean.TRUE);
@@ -259,7 +261,7 @@ public class TestMinimalClientExec {
public void testExecConnectionRequestFailed() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(connRequest.get(Mockito.anyInt(), Mockito.any()))
.thenThrow(new ExecutionException("Opppsie", null));
@@ -270,7 +272,7 @@ public class TestMinimalClientExec {
public void testExecConnectionShutDown() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(requestExecutor.execute(
Mockito.any(),
@@ -284,7 +286,7 @@ public class TestMinimalClientExec {
public void testExecRuntimeException() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(requestExecutor.execute(
Mockito.any(),
@@ -304,7 +306,7 @@ public class TestMinimalClientExec {
public void testExecHttpException() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(requestExecutor.execute(
Mockito.any(),
@@ -324,7 +326,7 @@ public class TestMinimalClientExec {
public void testExecIOException() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
Mockito.when(requestExecutor.execute(
Mockito.any(),
@@ -344,7 +346,7 @@ public class TestMinimalClientExec {
public void absoluteUriIsRewrittenToRelativeBeforeBeingPassedInRequestLine() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"), target);
final HttpResponse response = Mockito.mock(HttpResponse.class);
Mockito.when(requestExecutor.execute(
diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestProtocolExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestProtocolExec.java
index c7e763b2c..5d972fd80 100644
--- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestProtocolExec.java
+++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestProtocolExec.java
@@ -29,8 +29,11 @@ package org.apache.http.impl.execchain;
import java.io.IOException;
import java.net.URI;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.CredentialsProvider;
@@ -41,9 +44,6 @@ import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -76,7 +76,7 @@ public class TestProtocolExec {
@Test
public void testFundamentals() throws Exception {
final HttpRoute route = new HttpRoute(target);
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"), target);
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
@@ -104,7 +104,7 @@ public class TestProtocolExec {
public void testRewriteAbsoluteRequestURI() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(
- new HttpGet("http://foo/test"));
+ new HttpGet("http://foo/test"), target);
protocolExec.rewriteRequestURI(request, route);
Assert.assertEquals(new URI("/test"), request.getURI());
}
@@ -113,7 +113,7 @@ public class TestProtocolExec {
public void testRewriteEmptyRequestURI() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(
- new HttpGet(""));
+ new HttpGet(""), target);
protocolExec.rewriteRequestURI(request, route);
Assert.assertEquals(new URI("/"), request.getURI());
}
@@ -122,7 +122,7 @@ public class TestProtocolExec {
public void testRewriteAbsoluteRequestURIViaPRoxy() throws Exception {
final HttpRoute route = new HttpRoute(target, proxy);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(
- new HttpGet("http://foo/test"));
+ new HttpGet("http://foo/test"), target);
protocolExec.rewriteRequestURI(request, route);
Assert.assertEquals(new URI("http://foo/test"), request.getURI());
}
@@ -131,7 +131,7 @@ public class TestProtocolExec {
public void testRewriteRelativeRequestURIViaPRoxy() throws Exception {
final HttpRoute route = new HttpRoute(target, proxy);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(
- new HttpGet("/test"));
+ new HttpGet("/test"), target);
protocolExec.rewriteRequestURI(request, route);
Assert.assertEquals(new URI("http://foo:80/test"), request.getURI());
}
@@ -140,7 +140,7 @@ public class TestProtocolExec {
public void testHostHeaderUriRequest() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(
- new HttpGet("http://bar/test"));
+ new HttpGet("http://bar/test"), target);
final HttpClientContext context = HttpClientContext.create();
protocolExec.execute(route, request, context, execAware);
// ProtocolExect should have extracted the host from request URI
@@ -151,7 +151,7 @@ public class TestProtocolExec {
public void testHostHeaderWhenNonUriRequest() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "http://bar/test"));
+ new BasicHttpRequest("GET", "http://bar/test"), target);
final HttpClientContext context = HttpClientContext.create();
protocolExec.execute(route, request, context, execAware);
// ProtocolExect should have extracted the host from request URI
@@ -162,7 +162,7 @@ public class TestProtocolExec {
public void testHostHeaderWhenNonUriRequestAndInvalidUri() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpRequestWrapper request = HttpRequestWrapper.wrap(
- new BasicHttpRequest("GET", "http://bar/test|"));
+ new BasicHttpRequest("GET", "http://bar/test|"), target);
final HttpClientContext context = HttpClientContext.create();
protocolExec.execute(route, request, context, execAware);
// ProtocolExect should have fall back to physical host as request URI
@@ -172,19 +172,19 @@ public class TestProtocolExec {
@Test
public void testHostHeaderImplicitHost() throws Exception {
- final HttpRoute route = new HttpRoute(new HttpHost("somehost", 8080));
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(
- new HttpGet("/test"));
+ final HttpHost somehost = new HttpHost("somehost", 8080);
+ final HttpRoute route = new HttpRoute(somehost);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"), somehost);
final HttpClientContext context = HttpClientContext.create();
protocolExec.execute(route, request, context, execAware);
- Assert.assertEquals(new HttpHost("somehost", 8080), context.getTargetHost());
+ Assert.assertEquals(somehost, context.getTargetHost());
}
@Test
public void testUserInfoInRequestURI() throws Exception {
final HttpRoute route = new HttpRoute(new HttpHost("somehost", 8080));
final HttpRequestWrapper request = HttpRequestWrapper.wrap(
- new HttpGet("http://somefella:secret@bar/test"));
+ new HttpGet("http://somefella:secret@bar/test"), target);
final HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(new BasicCredentialsProvider());
protocolExec.execute(route, request, context, execAware);
@@ -199,7 +199,7 @@ public class TestProtocolExec {
@Test(expected = HttpException.class)
public void testPostProcessHttpException() throws Exception {
final HttpRoute route = new HttpRoute(target);
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"), target);
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
@@ -222,7 +222,7 @@ public class TestProtocolExec {
@Test(expected = IOException.class)
public void testPostProcessIOException() throws Exception {
final HttpRoute route = new HttpRoute(target);
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"), target);
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
@@ -244,7 +244,7 @@ public class TestProtocolExec {
@Test(expected = RuntimeException.class)
public void testPostProcessRuntimeException() throws Exception {
final HttpRoute route = new HttpRoute(target);
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"), target);
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
index 70865ccdb..6225efa5e 100644
--- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
+++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
@@ -30,13 +30,13 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.List;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolException;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.ProtocolException;
import org.apache.http.auth.AuthExchange;
import org.apache.http.client.RedirectException;
import org.apache.http.client.RedirectStrategy;
@@ -89,7 +89,7 @@ public class TestRedirectExec {
final HttpGet get = new HttpGet("/test");
get.addHeader("header", "this");
get.addHeader("header", "that");
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(get, target);
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response1 = Mockito.mock(CloseableHttpResponse.class);
@@ -160,7 +160,7 @@ public class TestRedirectExec {
public void testMaxRedirect() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpGet get = new HttpGet("/test");
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(get, target);
final HttpClientContext context = HttpClientContext.create();
final RequestConfig config = RequestConfig.custom()
.setRedirectsEnabled(true)
@@ -196,7 +196,7 @@ public class TestRedirectExec {
public void testRelativeRedirect() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpGet get = new HttpGet("/test");
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(get, target);
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response1 = Mockito.mock(CloseableHttpResponse.class);
@@ -234,7 +234,7 @@ public class TestRedirectExec {
final HttpHost proxy = new HttpHost("proxy");
final HttpRoute route = new HttpRoute(target, proxy);
final HttpGet get = new HttpGet("/test");
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(get, target);
final HttpClientContext context = HttpClientContext.create();
final AuthExchange targetAuthExchange = new AuthExchange();
@@ -288,7 +288,7 @@ public class TestRedirectExec {
public void testRedirectRuntimeException() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpGet get = new HttpGet("/test");
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(get, target);
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response1 = Mockito.mock(CloseableHttpResponse.class);
@@ -318,7 +318,7 @@ public class TestRedirectExec {
public void testRedirectProtocolException() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpGet get = new HttpGet("/test");
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(get, target);
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response1 = Mockito.mock(CloseableHttpResponse.class);
diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestResponseEntityWrapper.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestResponseEntityWrapper.java
index 803cb94cd..58b5bc671 100644
--- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestResponseEntityWrapper.java
+++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestResponseEntityWrapper.java
@@ -31,8 +31,8 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.SocketException;
-import org.apache.http.HttpEntity;
-import org.apache.http.util.EntityUtils;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestRetryExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestRetryExec.java
index cfa8833dd..776439035 100644
--- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestRetryExec.java
+++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestRetryExec.java
@@ -26,10 +26,14 @@
*/
package org.apache.http.impl.execchain;
-import org.apache.http.Header;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.NonRepeatableRequestException;
import org.apache.http.client.entity.EntityBuilder;
@@ -39,7 +43,6 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.protocol.HttpContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -49,10 +52,6 @@ import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
@SuppressWarnings({"boxing","static-access"}) // test code
public class TestRetryExec {
@@ -79,7 +78,7 @@ public class TestRetryExec {
final HttpGet get = new HttpGet("/test");
get.addHeader("header", "this");
get.addHeader("header", "that");
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(get, target);
final HttpClientContext context = HttpClientContext.create();
Mockito.when(requestExecutor.execute(
@@ -122,7 +121,7 @@ public class TestRetryExec {
public void testAbortedRequest() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpGet get = new HttpGet("/test");
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(get, target);
final HttpClientContext context = HttpClientContext.create();
Mockito.when(requestExecutor.execute(
@@ -157,7 +156,7 @@ public class TestRetryExec {
post.setEntity(EntityBuilder.create()
.setStream(new ByteArrayInputStream(new byte[]{}))
.build());
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(post);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(post, target);
final HttpClientContext context = HttpClientContext.create();
Mockito.when(requestExecutor.execute(
@@ -169,7 +168,7 @@ public class TestRetryExec {
@Override
public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
final Object[] args = invocationOnMock.getArguments();
- final HttpEntityEnclosingRequest req = (HttpEntityEnclosingRequest) args[1];
+ final HttpRequest req = (HttpRequest) args[1];
req.getEntity().writeTo(new ByteArrayOutputStream());
throw new IOException("Ka-boom");
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestServiceUnavailableRetryExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestServiceUnavailableRetryExec.java
index b08275090..c51493b72 100644
--- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestServiceUnavailableRetryExec.java
+++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestServiceUnavailableRetryExec.java
@@ -26,8 +26,9 @@
*/
package org.apache.http.impl.execchain;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.http.client.ServiceUnavailableRetryStrategy;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpExecutionAware;
@@ -35,7 +36,6 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.protocol.HttpContext;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -66,7 +66,7 @@ public class TestServiceUnavailableRetryExec {
public void testFundamentals() throws Exception {
final HttpRoute route = new HttpRoute(target);
final HttpGet get = new HttpGet("/test");
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(get, target);
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
@@ -97,7 +97,7 @@ public class TestServiceUnavailableRetryExec {
@Test(expected = RuntimeException.class)
public void testStrategyRuntimeException() throws Exception {
final HttpRoute route = new HttpRoute(target);
- final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"));
+ final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("/test"), target);
final HttpClientContext context = HttpClientContext.create();
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
diff --git a/httpclient/src/test/java/org/apache/http/localserver/BasicAuthTokenExtractor.java b/httpclient/src/test/java/org/apache/http/localserver/BasicAuthTokenExtractor.java
index 8e037bd4b..0bbdde152 100644
--- a/httpclient/src/test/java/org/apache/http/localserver/BasicAuthTokenExtractor.java
+++ b/httpclient/src/test/java/org/apache/http/localserver/BasicAuthTokenExtractor.java
@@ -27,15 +27,16 @@
package org.apache.http.localserver;
+import java.nio.charset.StandardCharsets;
+
import org.apache.commons.codec.BinaryDecoder;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Base64;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpRequest;
-import org.apache.http.ProtocolException;
-import org.apache.http.util.EncodingUtils;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.ProtocolException;
public class BasicAuthTokenExtractor {
@@ -59,9 +60,9 @@ public class BasicAuthTokenExtractor {
if (authscheme.equalsIgnoreCase("basic")) {
final String s = auth.substring(i + 1).trim();
try {
- final byte[] credsRaw = EncodingUtils.getAsciiBytes(s);
+ final byte[] credsRaw = s.getBytes(StandardCharsets.US_ASCII);
final BinaryDecoder codec = new Base64();
- auth = EncodingUtils.getAsciiString(codec.decode(credsRaw));
+ auth = new String(codec.decode(credsRaw), StandardCharsets.US_ASCII);
} catch (final DecoderException ex) {
throw new ProtocolException("Malformed BASIC credentials");
}
diff --git a/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java b/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java
index 380607e40..9c2c32028 100644
--- a/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java
+++ b/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java
@@ -30,31 +30,21 @@ package org.apache.http.localserver;
import java.io.IOException;
import java.util.Locale;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.MethodNotSupportedException;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
-import org.apache.http.util.EntityUtils;
-
-
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.MethodNotSupportedException;
+import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* A handler that echos the incoming request entity.
- *
- *
- *
- *
*/
-public class EchoHandler
- implements HttpRequestHandler {
-
- // public default constructor
+public class EchoHandler implements HttpRequestHandler {
/**
* Handles a request by echoing the incoming request entity.
@@ -82,10 +72,7 @@ public class EchoHandler
(method + " not supported by " + getClass().getName());
}
- HttpEntity entity = null;
- if (request instanceof HttpEntityEnclosingRequest) {
- entity = ((HttpEntityEnclosingRequest)request).getEntity();
- }
+ HttpEntity entity = request.getEntity();
// For some reason, just putting the incoming entity into
// the response will not work. We have to buffer the message.
@@ -104,8 +91,6 @@ public class EchoHandler
response.setStatusCode(HttpStatus.SC_OK);
response.setEntity(entity);
+ }
- } // handle
-
-
-} // class EchoHandler
+}
diff --git a/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java b/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java
index 38833e29d..692888d6b 100644
--- a/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java
+++ b/httpclient/src/test/java/org/apache/http/localserver/LocalServerTestBase.java
@@ -29,10 +29,10 @@ package org.apache.http.localserver;
import java.util.concurrent.TimeUnit;
-import org.apache.http.HttpHost;
-import org.apache.http.config.SocketConfig;
-import org.apache.http.impl.bootstrap.HttpServer;
-import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.bootstrap.io.HttpServer;
+import org.apache.hc.core5.http.bootstrap.io.ServerBootstrap;
+import org.apache.hc.core5.http.config.SocketConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
@@ -40,8 +40,7 @@ import org.junit.After;
import org.junit.Before;
/**
- * Base class for tests using {@link LocalTestServer}. The server will not be started
- * per default.
+ * Base class for tests using local test server. The server will not be started per default.
*/
public abstract class LocalServerTestBase {
diff --git a/httpclient/src/test/java/org/apache/http/localserver/RandomHandler.java b/httpclient/src/test/java/org/apache/http/localserver/RandomHandler.java
index b1195ab50..828890bee 100644
--- a/httpclient/src/test/java/org/apache/http/localserver/RandomHandler.java
+++ b/httpclient/src/test/java/org/apache/http/localserver/RandomHandler.java
@@ -30,17 +30,17 @@ package org.apache.http.localserver;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
import java.util.Locale;
-import org.apache.http.Consts;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.MethodNotSupportedException;
-import org.apache.http.entity.AbstractHttpEntity;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestHandler;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.MethodNotSupportedException;
+import org.apache.hc.core5.http.entity.AbstractHttpEntity;
+import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
/**
* A handler that generates random data.
@@ -123,7 +123,7 @@ public class RandomHandler implements HttpRequestHandler {
/** The range from which to generate random data. */
private final static byte[] RANGE = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
- .getBytes(Consts.ASCII);
+ .getBytes(StandardCharsets.US_ASCII);
/** The length of the random data to generate. */
protected final long length;
diff --git a/httpclient/src/test/java/org/apache/http/localserver/RequestBasicAuth.java b/httpclient/src/test/java/org/apache/http/localserver/RequestBasicAuth.java
index 5723bd677..dba665953 100644
--- a/httpclient/src/test/java/org/apache/http/localserver/RequestBasicAuth.java
+++ b/httpclient/src/test/java/org/apache/http/localserver/RequestBasicAuth.java
@@ -29,10 +29,10 @@ package org.apache.http.localserver;
import java.io.IOException;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.protocol.HttpContext;
public class RequestBasicAuth implements HttpRequestInterceptor {
diff --git a/httpclient/src/test/java/org/apache/http/localserver/ResponseBasicUnauthorized.java b/httpclient/src/test/java/org/apache/http/localserver/ResponseBasicUnauthorized.java
index d4f1210c6..1cf7f8415 100644
--- a/httpclient/src/test/java/org/apache/http/localserver/ResponseBasicUnauthorized.java
+++ b/httpclient/src/test/java/org/apache/http/localserver/ResponseBasicUnauthorized.java
@@ -29,12 +29,12 @@ package org.apache.http.localserver;
import java.io.IOException;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpStatus;
-import org.apache.http.protocol.HttpContext;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.protocol.HttpContext;
public class ResponseBasicUnauthorized implements HttpResponseInterceptor {
diff --git a/httpclient/src/test/java/org/apache/http/localserver/SSLTestContexts.java b/httpclient/src/test/java/org/apache/http/localserver/SSLTestContexts.java
index 2bfb5af21..361a3ab9d 100644
--- a/httpclient/src/test/java/org/apache/http/localserver/SSLTestContexts.java
+++ b/httpclient/src/test/java/org/apache/http/localserver/SSLTestContexts.java
@@ -29,7 +29,7 @@ package org.apache.http.localserver;
import javax.net.ssl.SSLContext;
-import org.apache.http.ssl.SSLContexts;
+import org.apache.hc.core5.ssl.SSLContexts;
public class SSLTestContexts {
diff --git a/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java b/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
index 302302f57..eb87995b6 100644
--- a/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
+++ b/httpmime/src/examples/org/apache/http/examples/entity/mime/ClientMultipartFormPost.java
@@ -28,16 +28,16 @@ package org.apache.http.examples.entity.mime;
import java.io.File;
-import org.apache.http.HttpEntity;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
/**
* Example how to use multipart/form encoded POST request.
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/AbstractMultipartForm.java b/httpmime/src/main/java/org/apache/http/entity/mime/AbstractMultipartForm.java
index 32249f636..7aad2201b 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/AbstractMultipartForm.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/AbstractMultipartForm.java
@@ -33,11 +33,12 @@ import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.List;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.ByteArrayBuffer;
import org.apache.http.entity.mime.content.ContentBody;
-import org.apache.http.util.Args;
-import org.apache.http.util.ByteArrayBuffer;
/**
* HttpMultipart represents a collection of MIME multipart encoded content bodies. This class is
@@ -69,7 +70,7 @@ abstract class AbstractMultipartForm {
private static void writeBytes(
final String s, final OutputStream out) throws IOException {
- final ByteArrayBuffer b = encode(MIME.DEFAULT_CHARSET, s);
+ final ByteArrayBuffer b = encode(StandardCharsets.ISO_8859_1, s);
writeBytes(b, out);
}
@@ -89,9 +90,9 @@ abstract class AbstractMultipartForm {
writeBytes(CR_LF, out);
}
- private static final ByteArrayBuffer FIELD_SEP = encode(MIME.DEFAULT_CHARSET, ": ");
- private static final ByteArrayBuffer CR_LF = encode(MIME.DEFAULT_CHARSET, "\r\n");
- private static final ByteArrayBuffer TWO_DASHES = encode(MIME.DEFAULT_CHARSET, "--");
+ private static final ByteArrayBuffer FIELD_SEP = encode(StandardCharsets.ISO_8859_1, ": ");
+ private static final ByteArrayBuffer CR_LF = encode(StandardCharsets.ISO_8859_1, "\r\n");
+ private static final ByteArrayBuffer TWO_DASHES = encode(StandardCharsets.ISO_8859_1, "--");
final Charset charset;
final String boundary;
@@ -99,14 +100,14 @@ abstract class AbstractMultipartForm {
/**
* Creates an instance with the specified settings.
*
- * @param charset the character set to use. May be {@code null}, in which case {@link MIME#DEFAULT_CHARSET} - i.e. US-ASCII - is used.
+ * @param charset the character set to use. May be {@code null}, in which case {@link StandardCharsets#ISO_8859_1} is used.
* @param boundary to use - must not be {@code null}
* @throws IllegalArgumentException if charset is null or boundary is null
*/
public AbstractMultipartForm(final Charset charset, final String boundary) {
super();
Args.notNull(boundary, "Multipart boundary");
- this.charset = charset != null ? charset : MIME.DEFAULT_CHARSET;
+ this.charset = charset != null ? charset : StandardCharsets.ISO_8859_1;
this.boundary = boundary;
}
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java b/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
index a20018c90..4701c501a 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
@@ -27,8 +27,8 @@
package org.apache.http.entity.mime;
+import org.apache.hc.core5.util.Args;
import org.apache.http.entity.mime.content.ContentBody;
-import org.apache.http.util.Args;
/**
* FormBodyPart class represents a content body that can be used as a part of multipart encoded
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPartBuilder.java b/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPartBuilder.java
index 3fd282ad6..ec4bd6932 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPartBuilder.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPartBuilder.java
@@ -29,11 +29,11 @@ package org.apache.http.entity.mime;
import java.util.List;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.Asserts;
import org.apache.http.entity.mime.content.AbstractContentBody;
import org.apache.http.entity.mime.content.ContentBody;
-import org.apache.http.util.Args;
-import org.apache.http.util.Asserts;
/**
* Builder for individual {@link org.apache.http.entity.mime.FormBodyPart}s.
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/HttpRFC6532Multipart.java b/httpmime/src/main/java/org/apache/http/entity/mime/HttpRFC6532Multipart.java
index a48b42340..872904c8e 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/HttpRFC6532Multipart.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/HttpRFC6532Multipart.java
@@ -30,6 +30,7 @@ package org.apache.http.entity.mime;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.List;
/**
@@ -64,7 +65,7 @@ class HttpRFC6532Multipart extends AbstractMultipartForm {
// For RFC6532, we output all fields with UTF-8 encoding.
final Header header = part.getHeader();
for (final MinimalField field: header) {
- writeField(field, MIME.UTF8_CHARSET, out);
+ writeField(field, StandardCharsets.UTF_8, out);
}
}
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/MIME.java b/httpmime/src/main/java/org/apache/http/entity/mime/MIME.java
index 945bd1536..8ff4d6cfd 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/MIME.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/MIME.java
@@ -27,10 +27,6 @@
package org.apache.http.entity.mime;
-import org.apache.http.Consts;
-
-import java.nio.charset.Charset;
-
/**
*
* @since 4.0
@@ -44,10 +40,4 @@ public final class MIME {
public static final String ENC_8BIT = "8bit";
public static final String ENC_BINARY = "binary";
- /** The default character set to be used, i.e. "US-ASCII" */
- public static final Charset DEFAULT_CHARSET = Consts.ASCII;
-
- /** UTF-8 is used for RFC6532 */
- public static final Charset UTF8_CHARSET = Consts.UTF_8;
-
}
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java
index 7dfc5f86b..3b50c967f 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntityBuilder.java
@@ -35,16 +35,16 @@ import java.util.Collections;
import java.util.List;
import java.util.Random;
-import org.apache.http.HttpEntity;
-import org.apache.http.NameValuePair;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
+import org.apache.hc.core5.util.Args;
import org.apache.http.entity.mime.content.ByteArrayBody;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.apache.http.entity.mime.content.StringBody;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.util.Args;
/**
* Builder for multipart {@link HttpEntity}s.
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java
index 143fada41..28f6a1c9e 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartFormEntity.java
@@ -32,18 +32,17 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.Set;
-import org.apache.http.ContentTooLongException;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HTTP;
+import org.apache.hc.core5.http.ContentTooLongException;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.TrailerSupplier;
+import org.apache.hc.core5.http.entity.ContentType;
class MultipartFormEntity implements HttpEntity {
private final AbstractMultipartForm multipart;
- private final Header contentType;
+ private final ContentType contentType;
private final long contentLength;
MultipartFormEntity(
@@ -52,7 +51,7 @@ class MultipartFormEntity implements HttpEntity {
final long contentLength) {
super();
this.multipart = multipart;
- this.contentType = new BasicHeader(HTTP.CONTENT_TYPE, contentType.toString());
+ this.contentType = contentType;
this.contentLength = contentLength;
}
@@ -81,19 +80,15 @@ class MultipartFormEntity implements HttpEntity {
}
@Override
- public Header getContentType() {
- return this.contentType;
+ public String getContentType() {
+ return this.contentType != null ? this.contentType.toString() : null;
}
@Override
- public Header getContentEncoding() {
+ public String getContentEncoding() {
return null;
}
- @Override
- public void consumeContent() {
- }
-
@Override
public InputStream getContent() throws IOException {
if (this.contentLength < 0) {
@@ -112,4 +107,14 @@ class MultipartFormEntity implements HttpEntity {
this.multipart.writeTo(outstream);
}
+ @Override
+ public TrailerSupplier getTrailers() {
+ return null;
+ }
+
+ @Override
+ public Set getTrailerNames() {
+ return null;
+ }
+
}
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/AbstractContentBody.java b/httpmime/src/main/java/org/apache/http/entity/mime/content/AbstractContentBody.java
index cb0bf5d18..ddd92af3b 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/content/AbstractContentBody.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/AbstractContentBody.java
@@ -29,8 +29,8 @@ package org.apache.http.entity.mime.content;
import java.nio.charset.Charset;
-import org.apache.http.entity.ContentType;
-import org.apache.http.util.Args;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.util.Args;
/**
*
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java b/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
index 95692645a..99c08cad4 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
@@ -29,9 +29,9 @@ package org.apache.http.entity.mime.content;
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.util.Args;
import org.apache.http.entity.mime.MIME;
-import org.apache.http.util.Args;
/**
* Binary body part backed by a byte array.
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java b/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java
index 4fc5c9ce2..4907c0d3f 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java
@@ -33,9 +33,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.util.Args;
import org.apache.http.entity.mime.MIME;
-import org.apache.http.util.Args;
/**
* Binary body part backed by a file.
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java b/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java
index 91263749b..2d1bc5a95 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java
@@ -31,9 +31,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.util.Args;
import org.apache.http.entity.mime.MIME;
-import org.apache.http.util.Args;
/**
* Binary body part backed by an input stream.
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java b/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
index 098224284..57261fe95 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
@@ -34,11 +34,11 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.Consts;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.util.Args;
import org.apache.http.entity.mime.MIME;
-import org.apache.http.util.Args;
/**
* Text body part backed by a byte array.
@@ -58,14 +58,14 @@ public class StringBody extends AbstractContentBody {
super(contentType);
Args.notNull(text, "Text");
final Charset charset = contentType.getCharset();
- this.content = text.getBytes(charset != null ? charset : Consts.ASCII);
+ this.content = text.getBytes(charset != null ? charset : StandardCharsets.US_ASCII);
}
public Reader getReader() {
final Charset charset = getContentType().getCharset();
return new InputStreamReader(
new ByteArrayInputStream(this.content),
- charset != null ? charset : Consts.ASCII);
+ charset != null ? charset : StandardCharsets.US_ASCII);
}
@Override
diff --git a/httpmime/src/test/java/org/apache/http/entity/mime/FormBodyPartTest.java b/httpmime/src/test/java/org/apache/http/entity/mime/FormBodyPartTest.java
index 4d5dcedc0..96e673f57 100644
--- a/httpmime/src/test/java/org/apache/http/entity/mime/FormBodyPartTest.java
+++ b/httpmime/src/test/java/org/apache/http/entity/mime/FormBodyPartTest.java
@@ -27,13 +27,13 @@
package org.apache.http.entity.mime;
-import org.apache.http.entity.ContentType;
+import java.io.File;
+
+import org.apache.hc.core5.http.entity.ContentType;
import org.apache.http.entity.mime.content.FileBody;
import org.junit.Assert;
import org.junit.Test;
-import java.io.File;
-
public class FormBodyPartTest {
@Test
diff --git a/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java b/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java
index 49a6bd81e..f7d6b425d 100644
--- a/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java
+++ b/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java
@@ -31,7 +31,7 @@ import java.io.File;
import java.util.Arrays;
import java.util.List;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.ContentType;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.junit.Assert;
diff --git a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
index 6c5a6e210..53e79f04e 100644
--- a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
+++ b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
@@ -28,9 +28,9 @@
package org.apache.http.entity.mime;
import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.Consts;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.ContentType;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.apache.http.entity.mime.content.StringBody;
import org.junit.Assert;
@@ -53,9 +53,9 @@ public class TestMultipartContentBody {
Assert.assertEquals(MIME.ENC_8BIT, b1.getTransferEncoding());
final StringBody b2 = new StringBody("more text",
- ContentType.create("text/other", MIME.DEFAULT_CHARSET));
+ ContentType.create("text/other", StandardCharsets.ISO_8859_1));
Assert.assertEquals(9, b2.getContentLength());
- Assert.assertEquals(MIME.DEFAULT_CHARSET.name(), b2.getCharset());
+ Assert.assertEquals(StandardCharsets.ISO_8859_1.name(), b2.getCharset());
Assert.assertNull(b2.getFilename());
Assert.assertEquals("text/other", b2.getMimeType());
@@ -72,12 +72,12 @@ public class TestMultipartContentBody {
@Test(expected=IllegalArgumentException.class)
public void testStringBodyInvalidConstruction2() throws Exception {
- Assert.assertNotNull(new StringBody("stuff", (ContentType) null)); // avoid unused warning
+ Assert.assertNotNull(new StringBody("stuff", null)); // avoid unused warning
}
@Test
public void testInputStreamBody() throws Exception {
- final byte[] stuff = "Stuff".getBytes(Consts.ASCII);
+ final byte[] stuff = "Stuff".getBytes(StandardCharsets.US_ASCII);
final InputStreamBody b1 = new InputStreamBody(new ByteArrayInputStream(stuff), "stuff");
Assert.assertEquals(-1, b1.getContentLength());
diff --git a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java
index 68a1c172e..5de1da02d 100644
--- a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java
+++ b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java
@@ -29,12 +29,11 @@ package org.apache.http.entity.mime;
import java.io.ByteArrayInputStream;
import java.io.File;
+import java.nio.charset.StandardCharsets;
import java.util.List;
-import org.apache.http.Consts;
-import org.apache.http.Header;
-import org.apache.http.entity.ContentType;
-import org.apache.http.message.BasicNameValuePair;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
import org.junit.Assert;
import org.junit.Test;
@@ -52,13 +51,13 @@ public class TestMultipartEntityBuilder {
public void testMultipartOptions() throws Exception {
final MultipartFormEntity entity = MultipartEntityBuilder.create()
.setBoundary("blah-blah")
- .setCharset(Consts.UTF_8)
+ .setCharset(StandardCharsets.UTF_8)
.setLaxMode()
.buildEntity();
Assert.assertNotNull(entity);
Assert.assertTrue(entity.getMultipart() instanceof HttpBrowserCompatibleMultipart);
Assert.assertEquals("blah-blah", entity.getMultipart().boundary);
- Assert.assertEquals(Consts.UTF_8, entity.getMultipart().charset);
+ Assert.assertEquals(StandardCharsets.UTF_8, entity.getMultipart().charset);
}
@Test
@@ -80,13 +79,11 @@ public class TestMultipartEntityBuilder {
final MultipartFormEntity entity = MultipartEntityBuilder.create()
.setContentType(ContentType.APPLICATION_XML)
.setBoundary("blah-blah")
- .setCharset(Consts.UTF_8)
+ .setCharset(StandardCharsets.UTF_8)
.setLaxMode()
.buildEntity();
Assert.assertNotNull(entity);
- final Header contentType = entity.getContentType();
- Assert.assertNotNull(contentType);
- Assert.assertEquals("application/xml; boundary=blah-blah; charset=UTF-8", contentType.getValue());
+ Assert.assertEquals("application/xml; boundary=blah-blah; charset=UTF-8", entity.getContentType());
}
@Test
@@ -97,12 +94,9 @@ public class TestMultipartEntityBuilder {
new BasicNameValuePair("charset", "ascii")))
.buildEntity();
Assert.assertNotNull(entity);
- final Header contentType = entity.getContentType();
- Assert.assertNotNull(contentType);
- Assert.assertEquals("multipart/form-data; boundary=yada-yada; charset=US-ASCII",
- contentType.getValue());
+ Assert.assertEquals("multipart/form-data; boundary=yada-yada; charset=US-ASCII", entity.getContentType());
Assert.assertEquals("yada-yada", entity.getMultipart().boundary);
- Assert.assertEquals(Consts.ASCII, entity.getMultipart().charset);
+ Assert.assertEquals(StandardCharsets.US_ASCII, entity.getMultipart().charset);
}
@Test
@@ -113,14 +107,12 @@ public class TestMultipartEntityBuilder {
new BasicNameValuePair("charset", "ascii"),
new BasicNameValuePair("my", "stuff")))
.setBoundary("blah-blah")
- .setCharset(Consts.UTF_8)
+ .setCharset(StandardCharsets.UTF_8)
.setLaxMode()
.buildEntity();
Assert.assertNotNull(entity);
- final Header contentType = entity.getContentType();
- Assert.assertNotNull(contentType);
Assert.assertEquals("multipart/form-data; boundary=blah-blah; charset=UTF-8; my=stuff",
- contentType.getValue());
+ entity.getContentType());
}
}
diff --git a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
index c37e72c4c..f4d766a71 100644
--- a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
+++ b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
@@ -33,10 +33,10 @@ import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.Writer;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
-import org.apache.http.Consts;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.ContentType;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.apache.http.entity.mime.content.StringBody;
@@ -63,7 +63,7 @@ public class TestMultipartForm {
final FormBodyPart p2 = FormBodyPartBuilder.create(
"field2",
new StringBody("that stuff", ContentType.create(
- ContentType.TEXT_PLAIN.getMimeType(), Consts.UTF_8))).build();
+ ContentType.TEXT_PLAIN.getMimeType(), StandardCharsets.UTF_8))).build();
final FormBodyPart p3 = FormBodyPartBuilder.create(
"field3",
new StringBody("all kind of stuff", ContentType.DEFAULT_TEXT)).build();
@@ -317,7 +317,7 @@ public class TestMultipartForm {
"field2",
new InputStreamBody(new FileInputStream(tmpfile), s2 + ".tmp")).build();
final HttpBrowserCompatibleMultipart multipart = new HttpBrowserCompatibleMultipart(
- Consts.UTF_8, "foo",
+ StandardCharsets.UTF_8, "foo",
Arrays.asList(p1, p2));
final ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -368,17 +368,17 @@ public class TestMultipartForm {
"Content-Disposition: form-data; name=\"field1\"\r\n" +
"Content-Type: text/plain; charset=ISO-8859-1\r\n" +
"Content-Transfer-Encoding: 8bit\r\n" +
- "\r\n").getBytes(Consts.ASCII));
- out2.write(s1.getBytes(Consts.ISO_8859_1));
+ "\r\n").getBytes(StandardCharsets.US_ASCII));
+ out2.write(s1.getBytes(StandardCharsets.ISO_8859_1));
out2.write(("\r\n" +
"--foo\r\n" +
"Content-Disposition: form-data; name=\"field2\"\r\n" +
"Content-Type: text/plain; charset=KOI8-R\r\n" +
"Content-Transfer-Encoding: 8bit\r\n" +
- "\r\n").getBytes(Consts.ASCII));
+ "\r\n").getBytes(StandardCharsets.US_ASCII));
out2.write(s2.getBytes(Charset.forName("KOI8-R")));
out2.write(("\r\n" +
- "--foo--\r\n").getBytes(Consts.ASCII));
+ "--foo--\r\n").getBytes(StandardCharsets.US_ASCII));
out2.close();
final byte[] actual = out1.toByteArray();
diff --git a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartFormHttpEntity.java b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartFormHttpEntity.java
index fbbe57cbb..5a3eaec28 100644
--- a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartFormHttpEntity.java
+++ b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartFormHttpEntity.java
@@ -29,12 +29,14 @@ package org.apache.http.entity.mime;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntity;
-import org.apache.http.NameValuePair;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.message.BasicHeaderValueParser;
+import org.apache.hc.core5.http.message.ParserCursor;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.junit.Assert;
import org.junit.Test;
@@ -46,17 +48,13 @@ public class TestMultipartFormHttpEntity {
final HttpEntity entity = MultipartEntityBuilder.create()
.setLaxMode()
.setBoundary("whatever")
- .setCharset(MIME.UTF8_CHARSET)
+ .setCharset(StandardCharsets.UTF_8)
.build();
Assert.assertNull(entity.getContentEncoding());
- Assert.assertNotNull(entity.getContentType());
- final Header header = entity.getContentType();
- final HeaderElement[] elems = header.getElements();
- Assert.assertNotNull(elems);
- Assert.assertEquals(1, elems.length);
-
- final HeaderElement elem = elems[0];
+ final String contentType = entity.getContentType();
+ final HeaderElement elem = BasicHeaderValueParser.INSTANCE.parseHeaderElement(contentType,
+ new ParserCursor(0, contentType.length()));
Assert.assertEquals("multipart/form-data", elem.getName());
final NameValuePair p1 = elem.getParameterByName("boundary");
Assert.assertNotNull(p1);
@@ -70,13 +68,9 @@ public class TestMultipartFormHttpEntity {
public void testImplictContractorParams() throws Exception {
final HttpEntity entity = MultipartEntityBuilder.create().build();
Assert.assertNull(entity.getContentEncoding());
- Assert.assertNotNull(entity.getContentType());
- final Header header = entity.getContentType();
- final HeaderElement[] elems = header.getElements();
- Assert.assertNotNull(elems);
- Assert.assertEquals(1, elems.length);
-
- final HeaderElement elem = elems[0];
+ final String contentType = entity.getContentType();
+ final HeaderElement elem = BasicHeaderValueParser.INSTANCE.parseHeaderElement(contentType,
+ new ParserCursor(0, contentType.length()));
Assert.assertEquals("multipart/form-data", elem.getName());
final NameValuePair p1 = elem.getParameterByName("boundary");
Assert.assertNotNull(p1);
diff --git a/pom.xml b/pom.xml
index 3fd45d566..b815eb08b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,7 +66,7 @@
1.7
1.7
- 4.4.1
+ 5.0-alpha1
1.2
1.10
2.6.11
@@ -83,8 +83,8 @@
- org.apache.httpcomponents
- httpcore
+ org.apache.httpcomponents.core5
+ httpcore5
${httpcore.version}