tabs -> spaces; removed trailing whilespaces; updated stylecheck definitions
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1426529 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1c322eb843
commit
1db3da376e
|
@ -45,7 +45,7 @@ public class FluentAsync {
|
|||
// Use pool of two threads
|
||||
ExecutorService threadpool = Executors.newFixedThreadPool(2);
|
||||
Async async = Async.newInstance().use(threadpool);
|
||||
|
||||
|
||||
Request[] requests = new Request[] {
|
||||
Request.Get("http://www.google.com/"),
|
||||
Request.Get("http://www.yahoo.com/"),
|
||||
|
@ -53,23 +53,23 @@ public class FluentAsync {
|
|||
Request.Get("http://www.apple.com/")
|
||||
};
|
||||
|
||||
|
||||
|
||||
Queue<Future<Content>> queue = new LinkedList<Future<Content>>();
|
||||
// Execute requests asynchronously
|
||||
for (final Request request: requests) {
|
||||
Future<Content> future = async.execute(request, new FutureCallback<Content>() {
|
||||
|
||||
|
||||
public void failed(final Exception ex) {
|
||||
System.out.println(ex.getMessage() + ": " + request);
|
||||
}
|
||||
|
||||
|
||||
public void completed(final Content content) {
|
||||
System.out.println("Request completed: " + request);
|
||||
}
|
||||
|
||||
|
||||
public void cancelled() {
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
queue.add(future);
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ package org.apache.http.client.fluent;
|
|||
public class FluentQuickStart {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// The fluent API relieves the user from having to deal with manual
|
||||
// deallocation of system resources at the cost of having to buffer
|
||||
// The fluent API relieves the user from having to deal with manual
|
||||
// deallocation of system resources at the cost of having to buffer
|
||||
// response content in memory in some cases.
|
||||
|
||||
|
||||
Request.Get("http://targethost/homepage")
|
||||
.execute().returnContent();
|
||||
Request.Post("http://targethost/login")
|
||||
|
|
|
@ -49,23 +49,23 @@ public class Async {
|
|||
this.executor = executor;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Async use(final java.util.concurrent.Executor concurrentExec) {
|
||||
this.concurrentExec = concurrentExec;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
static class ExecRunnable<T> implements Runnable {
|
||||
|
||||
|
||||
private final BasicFuture<T> future;
|
||||
private final Request request;
|
||||
private final Executor executor;
|
||||
private final ResponseHandler<T> handler;
|
||||
|
||||
|
||||
ExecRunnable(
|
||||
final BasicFuture<T> future,
|
||||
final Request request,
|
||||
final Executor executor,
|
||||
final BasicFuture<T> future,
|
||||
final Request request,
|
||||
final Executor executor,
|
||||
final ResponseHandler<T> handler) {
|
||||
super();
|
||||
this.future = future;
|
||||
|
@ -83,9 +83,9 @@ public class Async {
|
|||
this.future.failed(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public <T> Future<T> execute(
|
||||
final Request request, final ResponseHandler<T> handler, final FutureCallback<T> callback) {
|
||||
BasicFuture<T> future = new BasicFuture<T>(callback);
|
||||
|
@ -103,7 +103,7 @@ public class Async {
|
|||
}
|
||||
return future;
|
||||
}
|
||||
|
||||
|
||||
public <T> Future<T> execute(final Request request, final ResponseHandler<T> handler) {
|
||||
return execute(request, handler, null);
|
||||
}
|
||||
|
@ -111,9 +111,9 @@ public class Async {
|
|||
public Future<Content> execute(final Request request, final FutureCallback<Content> callback) {
|
||||
return execute(request, new ContentResponseHandler(), callback);
|
||||
}
|
||||
|
||||
|
||||
public Future<Content> execute(final Request request) {
|
||||
return execute(request, new ContentResponseHandler(), null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ import org.apache.http.protocol.HTTP;
|
|||
|
||||
public class Content {
|
||||
|
||||
public static final Content NO_CONTENT = new Content(new byte[] {}, ContentType.DEFAULT_BINARY);
|
||||
|
||||
public static final Content NO_CONTENT = new Content(new byte[] {}, ContentType.DEFAULT_BINARY);
|
||||
|
||||
private final byte[] raw;
|
||||
private final ContentType type;
|
||||
|
||||
|
@ -75,5 +75,5 @@ public class Content {
|
|||
public String toString() {
|
||||
return asString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -198,10 +198,10 @@ public class Executor {
|
|||
}
|
||||
|
||||
/**
|
||||
* Executes the request. Please Note that response content must be processed
|
||||
* Executes the request. Please Note that response content must be processed
|
||||
* or discarded using {@link Response#discardContent()}, otherwise the
|
||||
* connection used for the request might not be released to the pool.
|
||||
*
|
||||
*
|
||||
* @see Response#handleResponse(org.apache.http.client.ResponseHandler)
|
||||
* @see Response#discardContent()
|
||||
*/
|
||||
|
|
|
@ -317,5 +317,5 @@ public class Request {
|
|||
public String toString() {
|
||||
return this.request.getRequestLine().toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@
|
|||
<module name="FileLength">
|
||||
<property name="max" value="10000" />
|
||||
</module>
|
||||
<!-- <module name="FileTabCharacter">
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="[ \t]+$"/>
|
||||
<property name="message" value="Trailing whitespace"/>
|
||||
</module> -->
|
||||
</module>
|
||||
</module>
|
||||
|
|
|
@ -67,7 +67,7 @@ class CacheEntity implements HttpEntity, Serializable {
|
|||
}
|
||||
|
||||
public long getContentLength() {
|
||||
return this.cacheEntry.getResource().length();
|
||||
return this.cacheEntry.getResource().length();
|
||||
}
|
||||
|
||||
public InputStream getContent() throws IOException {
|
||||
|
|
|
@ -201,7 +201,7 @@ class CacheInvalidator {
|
|||
|
||||
// do not invalidate if response is strictly older than entry
|
||||
// or if the etags match
|
||||
|
||||
|
||||
if (responseDateOlderThanEntryDate(response, entry)) return;
|
||||
if (!responseAndEntryEtagsDiffer(response, entry)) return;
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ class CachedResponseSuitabilityChecker {
|
|||
}
|
||||
|
||||
if (!isConditional(request) && entry.getStatusCode() == HttpStatus.SC_NOT_MODIFIED) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isConditional(request) && !allConditionalsMatch(request, entry, now)) {
|
||||
|
|
|
@ -281,8 +281,8 @@ public class CachingExec implements ClientExecChain {
|
|||
} else if (!mayCallBackend(request)) {
|
||||
log.debug("Cache entry not suitable but only-if-cached requested");
|
||||
out = Proxies.enhanceResponse(generateGatewayTimeout(context));
|
||||
} else if (validityPolicy.isRevalidatable(entry)
|
||||
&& !(entry.getStatusCode() == HttpStatus.SC_NOT_MODIFIED
|
||||
} else if (validityPolicy.isRevalidatable(entry)
|
||||
&& !(entry.getStatusCode() == HttpStatus.SC_NOT_MODIFIED
|
||||
&& !suitabilityChecker.isConditional(request))) {
|
||||
log.debug("Revalidating cache entry");
|
||||
return revalidateCacheEntry(route, request, context, execAware, entry, now);
|
||||
|
|
|
@ -470,13 +470,13 @@ public class CachingHttpClient implements HttpClient {
|
|||
return revalidateCacheEntry(target, request, context, entry, now);
|
||||
} else {
|
||||
log.debug("Cache entry not usable; calling backend");
|
||||
return callBackend(target, request, context);
|
||||
return callBackend(target, request, context);
|
||||
}
|
||||
if (context != null) {
|
||||
context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
|
||||
context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
|
||||
context.setAttribute(ExecutionContext.HTTP_RESPONSE, out);
|
||||
context.setAttribute(ExecutionContext.HTTP_REQ_SENT, Boolean.TRUE);
|
||||
context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
|
||||
context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
|
||||
context.setAttribute(ExecutionContext.HTTP_RESPONSE, out);
|
||||
context.setAttribute(ExecutionContext.HTTP_REQ_SENT, Boolean.TRUE);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -53,4 +53,4 @@ class Proxies {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,15 +58,15 @@ class ResponseCachingPolicy {
|
|||
private final boolean sharedCache;
|
||||
private final boolean neverCache1_0ResponsesWithQueryString;
|
||||
private final Log log = LogFactory.getLog(getClass());
|
||||
private static final Set<Integer> cacheableStatuses =
|
||||
new HashSet<Integer>(Arrays.asList(HttpStatus.SC_OK,
|
||||
HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION,
|
||||
HttpStatus.SC_MULTIPLE_CHOICES,
|
||||
HttpStatus.SC_MOVED_PERMANENTLY,
|
||||
HttpStatus.SC_GONE));
|
||||
private static final Set<Integer> cacheableStatuses =
|
||||
new HashSet<Integer>(Arrays.asList(HttpStatus.SC_OK,
|
||||
HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION,
|
||||
HttpStatus.SC_MULTIPLE_CHOICES,
|
||||
HttpStatus.SC_MOVED_PERMANENTLY,
|
||||
HttpStatus.SC_GONE));
|
||||
private static final Set<Integer> uncacheableStatuses =
|
||||
new HashSet<Integer>(Arrays.asList(HttpStatus.SC_PARTIAL_CONTENT,
|
||||
HttpStatus.SC_SEE_OTHER));
|
||||
new HashSet<Integer>(Arrays.asList(HttpStatus.SC_PARTIAL_CONTENT,
|
||||
HttpStatus.SC_SEE_OTHER));
|
||||
/**
|
||||
* Define a cache policy that limits the size of things that should be stored
|
||||
* in the cache to a maximum of {@link HttpResponse} bytes in size.
|
||||
|
@ -99,19 +99,19 @@ class ResponseCachingPolicy {
|
|||
log.debug("Response was not cacheable.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int status = response.getStatusLine().getStatusCode();
|
||||
if (cacheableStatuses.contains(status)) {
|
||||
// these response codes MAY be cached
|
||||
cacheable = true;
|
||||
// these response codes MAY be cached
|
||||
cacheable = true;
|
||||
} else if (uncacheableStatuses.contains(status)) {
|
||||
return false;
|
||||
return false;
|
||||
} else if (unknownStatusCode(status)) {
|
||||
// a response with an unknown status code MUST NOT be
|
||||
// cached
|
||||
return false;
|
||||
// a response with an unknown status code MUST NOT be
|
||||
// cached
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Header contentLength = response.getFirstHeader(HTTP.CONTENT_LEN);
|
||||
if (contentLength != null) {
|
||||
int contentLengthValue = Integer.parseInt(contentLength.getValue());
|
||||
|
@ -155,15 +155,15 @@ class ResponseCachingPolicy {
|
|||
}
|
||||
|
||||
private boolean unknownStatusCode(int status) {
|
||||
if (status >= 100 && status <= 101) return false;
|
||||
if (status >= 200 && status <= 206) return false;
|
||||
if (status >= 300 && status <= 307) return false;
|
||||
if (status >= 400 && status <= 417) return false;
|
||||
if (status >= 500 && status <= 505) return false;
|
||||
return true;
|
||||
}
|
||||
if (status >= 100 && status <= 101) return false;
|
||||
if (status >= 200 && status <= 206) return false;
|
||||
if (status >= 300 && status <= 307) return false;
|
||||
if (status >= 400 && status <= 417) return false;
|
||||
if (status >= 500 && status <= 505) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isExplicitlyNonCacheable(HttpResponse response) {
|
||||
protected boolean isExplicitlyNonCacheable(HttpResponse response) {
|
||||
Header[] cacheControlHeaders = response.getHeaders(HeaderConstants.CACHE_CONTROL);
|
||||
for (Header header : cacheControlHeaders) {
|
||||
for (HeaderElement elem : header.getElements()) {
|
||||
|
|
|
@ -72,4 +72,4 @@ public interface MemcachedCacheEntry {
|
|||
*/
|
||||
void set(byte[] bytes);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,14 +43,14 @@ public interface MemcachedCacheEntryFactory {
|
|||
* cache collisions. Therefore, we store the storage key along
|
||||
* with the <code>HttpCacheEntry</code> so it can be compared
|
||||
* on retrieval and thus detect collisions.
|
||||
* @param storageKey storage key under which the entry will
|
||||
* @param storageKey storage key under which the entry will
|
||||
* be logically stored
|
||||
* @param entry the cache entry to store
|
||||
* @return a {@link MemcachedCacheEntry} ready to provide
|
||||
* a serialized representation
|
||||
*/
|
||||
MemcachedCacheEntry getMemcachedCacheEntry(String storageKey, HttpCacheEntry entry);
|
||||
|
||||
|
||||
/**
|
||||
* Creates an "unset" {@link MemcachedCacheEntry} ready to accept
|
||||
* a serialized representation via {@link MemcachedCacheEntry#set(byte[])}
|
||||
|
@ -59,4 +59,4 @@ public interface MemcachedCacheEntryFactory {
|
|||
*/
|
||||
MemcachedCacheEntry getUnsetCacheEntry();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.apache.commons.logging.LogFactory;
|
|||
public class SHA256KeyHashingScheme implements KeyHashingScheme {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SHA256KeyHashingScheme.class);
|
||||
|
||||
|
||||
public String hash(String key) {
|
||||
MessageDigest md = getDigest();
|
||||
md.update(key.getBytes());
|
||||
|
|
|
@ -1574,152 +1574,152 @@ public class TestCachingExec {
|
|||
assertEquals(1, backend.getExecutions());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoEntityForIfNoneMatchRequestNotYetInCache() throws Exception {
|
||||
@Test
|
||||
public void testNoEntityForIfNoneMatchRequestNotYetInCache() throws Exception {
|
||||
|
||||
Date now = new Date();
|
||||
Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
|
||||
Date now = new Date();
|
||||
Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
|
||||
|
||||
impl = new CachingExec(mockBackend, new BasicHttpCache(),
|
||||
CacheConfig.DEFAULT);
|
||||
HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
|
||||
"http://foo.example.com/"));
|
||||
req1.addHeader("If-None-Match", "\"etag\"");
|
||||
impl = new CachingExec(mockBackend, new BasicHttpCache(),
|
||||
CacheConfig.DEFAULT);
|
||||
HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet(
|
||||
"http://foo.example.com/"));
|
||||
req1.addHeader("If-None-Match", "\"etag\"");
|
||||
|
||||
HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
|
||||
HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp1.setHeader("Content-Length", "128");
|
||||
resp1.setHeader("ETag", "\"etag\"");
|
||||
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
|
||||
resp1.setHeader("Cache-Control", "public, max-age=5");
|
||||
HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1,
|
||||
HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp1.setHeader("Content-Length", "128");
|
||||
resp1.setHeader("ETag", "\"etag\"");
|
||||
resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
|
||||
resp1.setHeader("Cache-Control", "public, max-age=5");
|
||||
|
||||
backendExpectsAnyRequestAndReturn(resp1);
|
||||
replayMocks();
|
||||
HttpResponse result = impl.execute(route, req1);
|
||||
verifyMocks();
|
||||
backendExpectsAnyRequestAndReturn(resp1);
|
||||
replayMocks();
|
||||
HttpResponse result = impl.execute(route, req1);
|
||||
verifyMocks();
|
||||
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result.getStatusLine()
|
||||
.getStatusCode());
|
||||
assertNull("The 304 response messages MUST NOT contain a message-body",
|
||||
result.getEntity());
|
||||
}
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result.getStatusLine()
|
||||
.getStatusCode());
|
||||
assertNull("The 304 response messages MUST NOT contain a message-body",
|
||||
result.getEntity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotModifiedResponseUpdatesCacheEntryWhenNoEntity() throws Exception {
|
||||
@Test
|
||||
public void testNotModifiedResponseUpdatesCacheEntryWhenNoEntity() throws Exception {
|
||||
|
||||
Date now = new Date();
|
||||
Date now = new Date();
|
||||
|
||||
impl = new CachingExec(mockBackend, new BasicHttpCache(),CacheConfig.DEFAULT);
|
||||
impl = new CachingExec(mockBackend, new BasicHttpCache(),CacheConfig.DEFAULT);
|
||||
|
||||
HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
req1.addHeader("If-None-Match", "etag");
|
||||
HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
req1.addHeader("If-None-Match", "etag");
|
||||
|
||||
HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
req2.addHeader("If-None-Match", "etag");
|
||||
HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
req2.addHeader("If-None-Match", "etag");
|
||||
|
||||
HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp1.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp1.setHeader("Cache-Control","max-age=0");
|
||||
resp1.setHeader("Etag", "etag");
|
||||
HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp1.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp1.setHeader("Cache-Control","max-age=0");
|
||||
resp1.setHeader("Etag", "etag");
|
||||
|
||||
HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp2.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp2.setHeader("Cache-Control","max-age=0");
|
||||
resp1.setHeader("Etag", "etag");
|
||||
HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp2.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp2.setHeader("Cache-Control","max-age=0");
|
||||
resp1.setHeader("Etag", "etag");
|
||||
|
||||
backendExpectsAnyRequestAndReturn(resp1);
|
||||
backendExpectsAnyRequestAndReturn(resp2);
|
||||
replayMocks();
|
||||
HttpResponse result1 = impl.execute(route, req1);
|
||||
HttpResponse result2 = impl.execute(route, req2);
|
||||
verifyMocks();
|
||||
backendExpectsAnyRequestAndReturn(resp1);
|
||||
backendExpectsAnyRequestAndReturn(resp2);
|
||||
replayMocks();
|
||||
HttpResponse result1 = impl.execute(route, req1);
|
||||
HttpResponse result2 = impl.execute(route, req2);
|
||||
verifyMocks();
|
||||
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result1.getStatusLine().getStatusCode());
|
||||
assertEquals("etag", result1.getFirstHeader("Etag").getValue());
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result2.getStatusLine().getStatusCode());
|
||||
assertEquals("etag", result2.getFirstHeader("Etag").getValue());
|
||||
}
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result1.getStatusLine().getStatusCode());
|
||||
assertEquals("etag", result1.getFirstHeader("Etag").getValue());
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result2.getStatusLine().getStatusCode());
|
||||
assertEquals("etag", result2.getFirstHeader("Etag").getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotModifiedResponseWithVaryUpdatesCacheEntryWhenNoEntity() throws Exception {
|
||||
@Test
|
||||
public void testNotModifiedResponseWithVaryUpdatesCacheEntryWhenNoEntity() throws Exception {
|
||||
|
||||
Date now = new Date();
|
||||
Date now = new Date();
|
||||
|
||||
impl = new CachingExec(mockBackend, new BasicHttpCache(),CacheConfig.DEFAULT);
|
||||
impl = new CachingExec(mockBackend, new BasicHttpCache(),CacheConfig.DEFAULT);
|
||||
|
||||
HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
req1.addHeader("If-None-Match", "etag");
|
||||
HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
req1.addHeader("If-None-Match", "etag");
|
||||
|
||||
HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
req2.addHeader("If-None-Match", "etag");
|
||||
HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
req2.addHeader("If-None-Match", "etag");
|
||||
|
||||
HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp1.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp1.setHeader("Cache-Control","max-age=0");
|
||||
resp1.setHeader("Etag", "etag");
|
||||
resp1.setHeader("Vary", "Accept-Encoding");
|
||||
HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp1.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp1.setHeader("Cache-Control","max-age=0");
|
||||
resp1.setHeader("Etag", "etag");
|
||||
resp1.setHeader("Vary", "Accept-Encoding");
|
||||
|
||||
HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp2.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp2.setHeader("Cache-Control","max-age=0");
|
||||
resp1.setHeader("Etag", "etag");
|
||||
resp1.setHeader("Vary", "Accept-Encoding");
|
||||
HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp2.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp2.setHeader("Cache-Control","max-age=0");
|
||||
resp1.setHeader("Etag", "etag");
|
||||
resp1.setHeader("Vary", "Accept-Encoding");
|
||||
|
||||
backendExpectsAnyRequestAndReturn(resp1);
|
||||
backendExpectsAnyRequestAndReturn(resp2);
|
||||
replayMocks();
|
||||
HttpResponse result1 = impl.execute(route, req1);
|
||||
HttpResponse result2 = impl.execute(route, req2);
|
||||
verifyMocks();
|
||||
backendExpectsAnyRequestAndReturn(resp1);
|
||||
backendExpectsAnyRequestAndReturn(resp2);
|
||||
replayMocks();
|
||||
HttpResponse result1 = impl.execute(route, req1);
|
||||
HttpResponse result2 = impl.execute(route, req2);
|
||||
verifyMocks();
|
||||
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result1.getStatusLine().getStatusCode());
|
||||
assertEquals("etag", result1.getFirstHeader("Etag").getValue());
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result2.getStatusLine().getStatusCode());
|
||||
assertEquals("etag", result2.getFirstHeader("Etag").getValue());
|
||||
}
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result1.getStatusLine().getStatusCode());
|
||||
assertEquals("etag", result1.getFirstHeader("Etag").getValue());
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result2.getStatusLine().getStatusCode());
|
||||
assertEquals("etag", result2.getFirstHeader("Etag").getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoesNotSend304ForNonConditionalRequest() throws Exception {
|
||||
@Test
|
||||
public void testDoesNotSend304ForNonConditionalRequest() throws Exception {
|
||||
|
||||
Date now = new Date();
|
||||
Date inOneMinute = new Date(System.currentTimeMillis()+60000);
|
||||
Date now = new Date();
|
||||
Date inOneMinute = new Date(System.currentTimeMillis()+60000);
|
||||
|
||||
impl = new CachingExec(mockBackend, new BasicHttpCache(),CacheConfig.DEFAULT);
|
||||
impl = new CachingExec(mockBackend, new BasicHttpCache(),CacheConfig.DEFAULT);
|
||||
|
||||
HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
req1.addHeader("If-None-Match", "etag");
|
||||
HttpRequestWrapper req1 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
req1.addHeader("If-None-Match", "etag");
|
||||
|
||||
HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
HttpRequestWrapper req2 = HttpRequestWrapper.wrap(new HttpGet("http://foo.example.com/"));
|
||||
|
||||
HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp1.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp1.setHeader("Cache-Control","public, max-age=60");
|
||||
resp1.setHeader("Expires",DateUtils.formatDate(inOneMinute));
|
||||
resp1.setHeader("Etag", "etag");
|
||||
resp1.setHeader("Vary", "Accept-Encoding");
|
||||
HttpResponse resp1 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not modified");
|
||||
resp1.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp1.setHeader("Cache-Control","public, max-age=60");
|
||||
resp1.setHeader("Expires",DateUtils.formatDate(inOneMinute));
|
||||
resp1.setHeader("Etag", "etag");
|
||||
resp1.setHeader("Vary", "Accept-Encoding");
|
||||
|
||||
HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "Ok");
|
||||
resp2.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp2.setHeader("Cache-Control","public, max-age=60");
|
||||
resp2.setHeader("Expires",DateUtils.formatDate(inOneMinute));
|
||||
resp2.setHeader("Etag", "etag");
|
||||
resp2.setHeader("Vary", "Accept-Encoding");
|
||||
resp2.setEntity(HttpTestUtils.makeBody(128));
|
||||
HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "Ok");
|
||||
resp2.setHeader("Date", DateUtils.formatDate(now));
|
||||
resp2.setHeader("Cache-Control","public, max-age=60");
|
||||
resp2.setHeader("Expires",DateUtils.formatDate(inOneMinute));
|
||||
resp2.setHeader("Etag", "etag");
|
||||
resp2.setHeader("Vary", "Accept-Encoding");
|
||||
resp2.setEntity(HttpTestUtils.makeBody(128));
|
||||
|
||||
backendExpectsAnyRequestAndReturn(resp1);
|
||||
backendExpectsAnyRequestAndReturn(resp2).anyTimes();
|
||||
replayMocks();
|
||||
HttpResponse result1 = impl.execute(route, req1);
|
||||
HttpResponse result2 = impl.execute(route, req2);
|
||||
verifyMocks();
|
||||
backendExpectsAnyRequestAndReturn(resp1);
|
||||
backendExpectsAnyRequestAndReturn(resp2).anyTimes();
|
||||
replayMocks();
|
||||
HttpResponse result1 = impl.execute(route, req1);
|
||||
HttpResponse result2 = impl.execute(route, req2);
|
||||
verifyMocks();
|
||||
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result1.getStatusLine().getStatusCode());
|
||||
assertNull(result1.getEntity());
|
||||
assertEquals(HttpStatus.SC_OK, result2.getStatusLine().getStatusCode());
|
||||
Assert.assertNotNull(result2.getEntity());
|
||||
}
|
||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result1.getStatusLine().getStatusCode());
|
||||
assertNull(result1.getEntity());
|
||||
assertEquals(HttpStatus.SC_OK, result2.getStatusLine().getStatusCode());
|
||||
Assert.assertNotNull(result2.getEntity());
|
||||
}
|
||||
|
||||
private IExpectationSetters<CloseableHttpResponse> backendExpectsAnyRequestAndReturn(
|
||||
private IExpectationSetters<CloseableHttpResponse> backendExpectsAnyRequestAndReturn(
|
||||
HttpResponse response) throws Exception {
|
||||
CloseableHttpResponse resp = mockBackend.execute(
|
||||
EasyMock.isA(HttpRoute.class),
|
||||
|
|
|
@ -73,12 +73,12 @@ public class TestHttpCacheJiraNumber1147 {
|
|||
}
|
||||
cacheDir.mkdir();
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void cleanUp() {
|
||||
removeCache();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIssue1147() throws Exception {
|
||||
CacheConfig cacheConfig = CacheConfig.custom()
|
||||
|
@ -97,30 +97,30 @@ public class TestHttpCacheJiraNumber1147 {
|
|||
|
||||
Date now = new Date();
|
||||
Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
|
||||
|
||||
|
||||
HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
|
||||
response.setEntity(HttpTestUtils.makeBody(128));
|
||||
response.setHeader("Content-Length", "128");
|
||||
response.setHeader("ETag", "\"etag\"");
|
||||
response.setHeader("Cache-Control", "public, max-age=3600");
|
||||
response.setHeader("Last-Modified", DateUtils.formatDate(tenSecondsAgo));
|
||||
|
||||
|
||||
EasyMock.expect(backend.execute(
|
||||
EasyMock.eq(route),
|
||||
EasyMock.isA(HttpRequestWrapper.class),
|
||||
EasyMock.same(context),
|
||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(Proxies.enhanceResponse(response));
|
||||
EasyMock.replay(backend);
|
||||
|
||||
|
||||
BasicHttpCache cache = new BasicHttpCache(resourceFactory, httpCacheStorage, cacheConfig);
|
||||
CachingExec t = new CachingExec(backend, cache, cacheConfig);
|
||||
|
||||
HttpResponse response1 = t.execute(route, get, context, null);
|
||||
Assert.assertEquals(200, response1.getStatusLine().getStatusCode());
|
||||
EntityUtils.consume(response1.getEntity());
|
||||
|
||||
|
||||
EasyMock.verify(backend);
|
||||
|
||||
|
||||
removeCache();
|
||||
|
||||
EasyMock.reset(backend);
|
||||
|
@ -130,7 +130,7 @@ public class TestHttpCacheJiraNumber1147 {
|
|||
EasyMock.same(context),
|
||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(Proxies.enhanceResponse(response));
|
||||
EasyMock.replay(backend);
|
||||
|
||||
|
||||
HttpResponse response2 = t.execute(route, get, context, null);
|
||||
Assert.assertEquals(200, response2.getStatusLine().getStatusCode());
|
||||
EntityUtils.consume(response2.getEntity());
|
||||
|
|
|
@ -516,13 +516,13 @@ public class TestResponseCachingPolicy {
|
|||
response.removeHeaders("Cache-Control");
|
||||
Assert.assertFalse(policy.isResponseCacheable(request, response));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void otherStatusCodesAreCacheableWithExplicitCachingHeaders() {
|
||||
response.setStatusCode(HttpStatus.SC_NOT_FOUND);
|
||||
response.setHeader("Date", formatDate(now));
|
||||
response.setHeader("Cache-Control","max-age=300");
|
||||
Assert.assertTrue(policy.isResponseCacheable(request, response));
|
||||
response.setStatusCode(HttpStatus.SC_NOT_FOUND);
|
||||
response.setHeader("Date", formatDate(now));
|
||||
response.setHeader("Cache-Control","max-age=300");
|
||||
Assert.assertTrue(policy.isResponseCacheable(request, response));
|
||||
}
|
||||
|
||||
private int getRandomStatus() {
|
||||
|
|
|
@ -51,31 +51,31 @@ public class TestMemcachedCacheEntryImpl {
|
|||
entry = HttpTestUtils.makeCacheEntry();
|
||||
impl = new MemcachedCacheEntryImpl("foo", entry);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void canBeCreatedEmpty() {
|
||||
impl = new MemcachedCacheEntryImpl();
|
||||
assertNull(impl.getStorageKey());
|
||||
assertNull(impl.getHttpCacheEntry());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void canBeSerialized() {
|
||||
byte[] bytes = impl.toByteArray();
|
||||
assertNotNull(bytes);
|
||||
assertTrue(bytes.length > 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void knowsItsCacheKey() {
|
||||
assertEquals("foo", impl.getStorageKey());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void knowsItsCacheEntry() {
|
||||
assertEquals(entry, impl.getHttpCacheEntry());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void canBeReconstitutedFromByteArray() throws Exception {
|
||||
String key = impl.getStorageKey();
|
||||
|
@ -83,11 +83,11 @@ public class TestMemcachedCacheEntryImpl {
|
|||
byte[] bytes = impl.toByteArray();
|
||||
impl = new MemcachedCacheEntryImpl();
|
||||
impl.set(bytes);
|
||||
|
||||
|
||||
assertEquals(key, impl.getStorageKey());
|
||||
assertEquivalent(entry, impl.getHttpCacheEntry());
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=MemcachedSerializationException.class)
|
||||
public void cannotReconstituteFromGarbage() {
|
||||
impl = new MemcachedCacheEntryImpl();
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TestPrefixKeyHashingScheme {
|
|||
};
|
||||
impl = new PrefixKeyHashingScheme(PREFIX, scheme);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void addsPrefixToBackingScheme() {
|
||||
assertEquals("prefixhash", impl.hash(KEY));
|
||||
|
|
|
@ -39,5 +39,5 @@ public class TestSHA256HashingScheme {
|
|||
String result = impl.hash("hello, hashing world");
|
||||
assertTrue(result != null && result.length() > 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -79,4 +79,4 @@ public class ClientExecuteProxy {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,4 +130,4 @@ public class ClientExecuteSOCKS {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public class AuthState {
|
|||
*
|
||||
* @deprecated (4.2) use {@link #reset()}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public void invalidate() {
|
||||
reset();
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public class AuthState {
|
|||
*
|
||||
* @deprecated (4.2) use {@link #update(AuthScheme, Credentials)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public void setAuthScheme(final AuthScheme authScheme) {
|
||||
if (authScheme == null) {
|
||||
reset();
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.apache.http.conn.ManagedClientConnection;
|
|||
* down the underlying HTTP connection.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) use {@link HttpExecutionAware}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.http.HttpResponse;
|
|||
|
||||
/**
|
||||
* Extended version of the {@link HttpResponse} interface that also extends {@link Closeable}.
|
||||
*
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public interface CloseableHttpResponse extends HttpResponse, Closeable {
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ClientParamBean extends HttpAbstractParamBean {
|
|||
/**
|
||||
* @deprecated (4.2) do not use.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public void setConnectionManagerFactoryClassName (final String factory) {
|
||||
params.setParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME, factory);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class RequestAcceptEncoding implements HttpRequestInterceptor {
|
|||
/* Signal support for Accept-Encoding transfer encodings. */
|
||||
if (!request.containsHeader("Accept-Encoding")) {
|
||||
request.addHeader("Accept-Encoding", "gzip,deflate");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ import org.apache.http.util.Args;
|
|||
* @deprecated (4.2) use {@link AuthenticationStrategy}
|
||||
*/
|
||||
@Immutable
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class ResponseAuthCache implements HttpResponseInterceptor {
|
||||
|
||||
private final Log log = LogFactory.getLog(getClass());
|
||||
|
|
|
@ -52,8 +52,8 @@ import org.apache.http.protocol.HttpContext;
|
|||
@Immutable
|
||||
public class ResponseContentEncoding implements HttpResponseInterceptor {
|
||||
|
||||
public static final String UNCOMPRESSED = "http.client.response.uncompressed";
|
||||
|
||||
public static final String UNCOMPRESSED = "http.client.response.uncompressed";
|
||||
|
||||
/**
|
||||
* Handles the following {@code Content-Encoding}s by
|
||||
* using the appropriate decompressor to wrap the response Entity:
|
||||
|
|
|
@ -72,7 +72,7 @@ public class URIBuilder {
|
|||
|
||||
/**
|
||||
* Construct an instance from the string which must be a valid URI.
|
||||
*
|
||||
*
|
||||
* @param string a valid URI in string form
|
||||
* @throws URISyntaxException if the input is not a valid URI
|
||||
*/
|
||||
|
@ -103,7 +103,7 @@ public class URIBuilder {
|
|||
public URI build() throws URISyntaxException {
|
||||
return new URI(buildString());
|
||||
}
|
||||
|
||||
|
||||
private String buildString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (this.scheme != null) {
|
||||
|
@ -256,9 +256,9 @@ public class URIBuilder {
|
|||
* Sets URI query.
|
||||
* <p>
|
||||
* The value is expected to be encoded form data.
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) use {@link #setParameters(List)} or {@link #setParameters(NameValuePair...)}
|
||||
*
|
||||
*
|
||||
* @see URLEncodedUtils#parse
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -269,14 +269,14 @@ public class URIBuilder {
|
|||
this.encodedSchemeSpecificPart = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets URI query parameters. The parameter name / values are expected to be unescaped
|
||||
* and may contain non ASCII characters.
|
||||
* <p/>
|
||||
* Please note query parameters and custom query component are mutually exclusive. This method
|
||||
* will remove custom query if present.
|
||||
*
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public URIBuilder setParameters(final List <NameValuePair> nvps) {
|
||||
|
@ -291,14 +291,14 @@ public class URIBuilder {
|
|||
this.query = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds URI query parameters. The parameter name / values are expected to be unescaped
|
||||
* and may contain non ASCII characters.
|
||||
* <p/>
|
||||
* Please note query parameters and custom query component are mutually exclusive. This method
|
||||
* will remove custom query if present.
|
||||
*
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public URIBuilder addParameters(final List <NameValuePair> nvps) {
|
||||
|
@ -311,14 +311,14 @@ public class URIBuilder {
|
|||
this.query = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets URI query parameters. The parameter name / values are expected to be unescaped
|
||||
* and may contain non ASCII characters.
|
||||
* <p/>
|
||||
* Please note query parameters and custom query component are mutually exclusive. This method
|
||||
* will remove custom query if present.
|
||||
*
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public URIBuilder setParameters(final NameValuePair... nvps) {
|
||||
|
@ -335,7 +335,7 @@ public class URIBuilder {
|
|||
this.query = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds parameter to URI query. The parameter name and value are expected to be unescaped
|
||||
* and may contain non ASCII characters.
|
||||
|
@ -382,7 +382,7 @@ public class URIBuilder {
|
|||
|
||||
/**
|
||||
* Clears URI query parameters.
|
||||
*
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public URIBuilder clearParameters() {
|
||||
|
@ -391,14 +391,14 @@ public class URIBuilder {
|
|||
this.encodedSchemeSpecificPart = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets custom URI query. The value is expected to be unescaped and may contain non ASCII
|
||||
* characters.
|
||||
* characters.
|
||||
* <p/>
|
||||
* Please note query parameters and custom query component are mutually exclusive. This method
|
||||
* will remove query parameters if present.
|
||||
*
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public URIBuilder setCustomQuery(final String query) {
|
||||
|
@ -408,7 +408,7 @@ public class URIBuilder {
|
|||
this.queryParams = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets URI fragment. The value is expected to be unescaped and may contain non ASCII
|
||||
* characters.
|
||||
|
|
|
@ -257,7 +257,7 @@ public class URLEncodedUtils {
|
|||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Unreserved characters, i.e. alphanumeric, plus: {@code _ - ! . ~ ' ( ) *}
|
||||
* <p>
|
||||
* This list is the same as the {@code unreserved} list in
|
||||
|
@ -270,28 +270,28 @@ public class URLEncodedUtils {
|
|||
* These are the additional characters allowed by userinfo.
|
||||
*/
|
||||
private static final BitSet PUNCT = new BitSet(256);
|
||||
/** Characters which are safe to use in userinfo,
|
||||
/** Characters which are safe to use in userinfo,
|
||||
* i.e. {@link #UNRESERVED} plus {@link #PUNCT}uation */
|
||||
private static final BitSet USERINFO = new BitSet(256);
|
||||
/** Characters which are safe to use in a path,
|
||||
/** Characters which are safe to use in a path,
|
||||
* i.e. {@link #UNRESERVED} plus {@link #PUNCT}uation plus / @ */
|
||||
private static final BitSet PATHSAFE = new BitSet(256);
|
||||
/** Characters which are safe to use in a query or a fragment,
|
||||
/** Characters which are safe to use in a query or a fragment,
|
||||
* i.e. {@link #RESERVED} plus {@link #UNRESERVED} */
|
||||
private static final BitSet URIC = new BitSet(256);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Reserved characters, i.e. {@code ;/?:@&=+$,[]}
|
||||
* <p>
|
||||
* This list is the same as the {@code reserved} list in
|
||||
* This list is the same as the {@code reserved} list in
|
||||
* <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>
|
||||
* as augmented by
|
||||
* <a href="http://www.ietf.org/rfc/rfc2732.txt">RFC 2732</a>
|
||||
*/
|
||||
private static final BitSet RESERVED = new BitSet(256);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Safe characters for x-www-form-urlencoded data, as per java.net.URLEncoder and browser behaviour,
|
||||
* i.e. alphanumeric plus {@code "-", "_", ".", "*"}
|
||||
*/
|
||||
|
@ -343,7 +343,7 @@ public class URLEncodedUtils {
|
|||
PATHSAFE.set('+');
|
||||
PATHSAFE.set('$');
|
||||
PATHSAFE.set(',');
|
||||
|
||||
|
||||
RESERVED.set(';');
|
||||
RESERVED.set('/');
|
||||
RESERVED.set('?');
|
||||
|
@ -356,7 +356,7 @@ public class URLEncodedUtils {
|
|||
RESERVED.set(',');
|
||||
RESERVED.set('['); // added by RFC 2732
|
||||
RESERVED.set(']'); // added by RFC 2732
|
||||
|
||||
|
||||
URIC.or(RESERVED);
|
||||
URIC.or(UNRESERVED);
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ public class URLEncodedUtils {
|
|||
|
||||
/**
|
||||
* Emcode/escape a portion of a URL, to use with the query part ensure {@code plusAsBlank} is true.
|
||||
*
|
||||
*
|
||||
* @param content the portion to decode
|
||||
* @param charset the charset to use
|
||||
* @param blankAsPlus if {@code true}, then convert space to '+' (e.g. for www-url-form-encoded content), otherwise leave as is.
|
||||
|
@ -400,7 +400,7 @@ public class URLEncodedUtils {
|
|||
|
||||
/**
|
||||
* Decode/unescape a portion of a URL, to use with the query part ensure {@code plusAsBlank} is true.
|
||||
*
|
||||
*
|
||||
* @param content the portion to decode
|
||||
* @param charset the charset to use
|
||||
* @param plusAsBlank if {@code true}, then convert '+' to space (e.g. for www-url-form-encoded content), otherwise leave as is.
|
||||
|
@ -441,7 +441,7 @@ public class URLEncodedUtils {
|
|||
|
||||
/**
|
||||
* Decode/unescape www-url-form-encoded content.
|
||||
*
|
||||
*
|
||||
* @param content the content to decode, will decode '+' as space
|
||||
* @param charset the charset to use
|
||||
* @return
|
||||
|
@ -455,7 +455,7 @@ public class URLEncodedUtils {
|
|||
|
||||
/**
|
||||
* Decode/unescape www-url-form-encoded content.
|
||||
*
|
||||
*
|
||||
* @param content the content to decode, will decode '+' as space
|
||||
* @param charset the charset to use
|
||||
* @return
|
||||
|
@ -473,7 +473,7 @@ public class URLEncodedUtils {
|
|||
* Uses the {@link #URLENCODER} set of characters, rather than
|
||||
* the {@link #UNRSERVED} set; this is for compatibilty with previous
|
||||
* releases, URLEncoder.encode() and most browsers.
|
||||
*
|
||||
*
|
||||
* @param content the content to encode, will convert space to '+'
|
||||
* @param charset the charset to use
|
||||
* @return
|
||||
|
@ -492,7 +492,7 @@ public class URLEncodedUtils {
|
|||
* Uses the {@link #URLENCODER} set of characters, rather than
|
||||
* the {@link #UNRSERVED} set; this is for compatibilty with previous
|
||||
* releases, URLEncoder.encode() and most browsers.
|
||||
*
|
||||
*
|
||||
* @param content the content to encode, will convert space to '+'
|
||||
* @param charset the charset to use
|
||||
* @return
|
||||
|
@ -508,7 +508,7 @@ public class URLEncodedUtils {
|
|||
* Encode a String using the {@link #USERINFO} set of characters.
|
||||
* <p>
|
||||
* Used by URIBuilder to encode the userinfo segment.
|
||||
*
|
||||
*
|
||||
* @param content the string to encode, does not convert space to '+'
|
||||
* @param charset the charset to use
|
||||
* @return the encoded string
|
||||
|
@ -521,7 +521,7 @@ public class URLEncodedUtils {
|
|||
* Encode a String using the {@link #URIC} set of characters.
|
||||
* <p>
|
||||
* Used by URIBuilder to encode the query and fragment segments.
|
||||
*
|
||||
*
|
||||
* @param content the string to encode, does not convert space to '+'
|
||||
* @param charset the charset to use
|
||||
* @return the encoded string
|
||||
|
@ -534,7 +534,7 @@ public class URLEncodedUtils {
|
|||
* Encode a String using the {@link #PATHSAFE} set of characters.
|
||||
* <p>
|
||||
* Used by URIBuilder to encode path segments.
|
||||
*
|
||||
*
|
||||
* @param content the string to encode, does not convert space to '+'
|
||||
* @param charset the charset to use
|
||||
* @return the encoded string
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.http.util.Args;
|
|||
* is released on close or EOF.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) do not use.
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.http.util.EntityUtils;
|
|||
* the unmanaged entity in the response with a managed one.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) do not use.
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -106,7 +106,7 @@ public class BasicManagedEntity extends HttpEntityWrapper
|
|||
* @deprecated (4.1) Use {@link EntityUtils#consume(HttpEntity)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
@Override
|
||||
public void consumeContent() throws IOException {
|
||||
ensureConsumed();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.http.impl.conn.DefaultHttpResponseParser;
|
|||
* Parameter names for HTTP client connections.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.1) use custom {@link DefaultHttpResponseParser} implementation.
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -58,7 +58,7 @@ public interface ConnConnectionPNames {
|
|||
* @deprecated (4.1) Use custom {@link DefaultHttpResponseParser} implementation
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String MAX_STATUS_LINE_GARBAGE = "http.connection.max-status-line-garbage";
|
||||
public static final String MAX_STATUS_LINE_GARBAGE = "http.connection.max-status-line-garbage";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@ import org.apache.http.params.HttpParams;
|
|||
* using Java Beans conventions.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class ConnConnectionParamBean extends HttpAbstractParamBean {
|
||||
|
||||
public ConnConnectionParamBean (final HttpParams params) {
|
||||
|
@ -51,7 +51,7 @@ public class ConnConnectionParamBean extends HttpAbstractParamBean {
|
|||
* @deprecated (4.2) Use custom {@link DefaultHttpResponseParser} implementation
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMaxStatusLineGarbage (final int maxStatusLineGarbage) {
|
||||
public void setMaxStatusLineGarbage (final int maxStatusLineGarbage) {
|
||||
params.setIntParameter(ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE, maxStatusLineGarbage);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@ package org.apache.http.conn.params;
|
|||
* Parameter names for connection managers in HttpConn.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.1) use configuration methods of the specific connection manager implementation.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public interface ConnManagerPNames {
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,11 +37,11 @@ import org.apache.http.params.HttpParams;
|
|||
* using Java Beans conventions.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.1) use configuration methods of the specific connection manager implementation.
|
||||
*/
|
||||
@NotThreadSafe
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class ConnManagerParamBean extends HttpAbstractParamBean {
|
||||
|
||||
public ConnManagerParamBean (final HttpParams params) {
|
||||
|
|
|
@ -39,10 +39,10 @@ import org.apache.http.util.Args;
|
|||
* @since 4.0
|
||||
*
|
||||
* @see ConnManagerPNames
|
||||
*
|
||||
*
|
||||
* @deprecated (4.1) use configuration methods of the specific connection manager implementation.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
@Immutable
|
||||
public final class ConnManagerParams implements ConnManagerPNames {
|
||||
|
||||
|
@ -59,7 +59,7 @@ public final class ConnManagerParams implements ConnManagerPNames {
|
|||
* @deprecated (4.1) use {@link HttpConnectionParams#getConnectionTimeout(HttpParams)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static long getTimeout(final HttpParams params) {
|
||||
public static long getTimeout(final HttpParams params) {
|
||||
Args.notNull(params, "HTTP parameters");
|
||||
return params.getLongParameter(TIMEOUT, 0);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public final class ConnManagerParams implements ConnManagerPNames {
|
|||
* @deprecated (4.1) use {@link HttpConnectionParams#setConnectionTimeout(HttpParams, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setTimeout(final HttpParams params, long timeout) {
|
||||
public static void setTimeout(final HttpParams params, long timeout) {
|
||||
Args.notNull(params, "HTTP parameters");
|
||||
params.setLongParameter(TIMEOUT, timeout);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.http.util.Args;
|
|||
*
|
||||
* @deprecated (4.2) use {@link ConnPoolControl}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
@ThreadSafe
|
||||
public final class ConnPerRouteBean implements ConnPerRoute {
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import java.net.InetAddress;
|
|||
*
|
||||
* @deprecated (4.1) Do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public interface HostNameResolver {
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.net.UnknownHostException;
|
|||
* Extended {@link SchemeSocketFactory} interface for layered sockets such as SSL/TLS.
|
||||
*
|
||||
* @since 4.1
|
||||
*
|
||||
*
|
||||
* @deprecated (4.2) use {@link SchemeLayeredSocketFactory}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -39,7 +39,7 @@ import java.net.UnknownHostException;
|
|||
*
|
||||
* @deprecated (4.1) use {@link SchemeSocketFactory}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public interface LayeredSocketFactory extends SocketFactory {
|
||||
|
||||
/**
|
||||
|
|
|
@ -119,7 +119,7 @@ public final class Scheme {
|
|||
*
|
||||
* @deprecated (4.1) Use {@link #Scheme(String, int, SchemeSocketFactory)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public Scheme(final String name,
|
||||
final SocketFactory factory,
|
||||
final int port) {
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.http.params.HttpParams;
|
|||
/**
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
class SchemeLayeredSocketFactoryAdaptor2 implements SchemeLayeredSocketFactory {
|
||||
|
||||
private final LayeredSchemeSocketFactory factory;
|
||||
|
@ -53,9 +53,9 @@ class SchemeLayeredSocketFactoryAdaptor2 implements SchemeLayeredSocketFactory {
|
|||
}
|
||||
|
||||
public Socket connectSocket(
|
||||
final Socket sock,
|
||||
final Socket sock,
|
||||
final InetSocketAddress remoteAddress,
|
||||
final InetSocketAddress localAddress,
|
||||
final InetSocketAddress localAddress,
|
||||
final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
|
||||
return this.factory.connectSocket(sock, remoteAddress, localAddress, params);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,6 @@ public class SSLInitializationException extends IllegalStateException {
|
|||
|
||||
public SSLInitializationException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.http.cookie.CookieSpecProvider;
|
|||
* Parameter names for HTTP cookie management classes.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) use constructor parameters of {@link CookieSpecProvider}s.
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.apache.http.params.HttpParams;
|
|||
* conventions.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) use constructor parameters of {@link CookieSpecProvider}s.
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -113,7 +113,7 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
|
|||
/**
|
||||
* @deprecated (4.2) Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public Header authenticate(
|
||||
final Credentials credentials,
|
||||
final HttpRequest request) throws AuthenticationException {
|
||||
|
|
|
@ -1234,7 +1234,7 @@ final class NTLMEngineImpl implements NTLMEngine {
|
|||
|
||||
// Start the response. Length includes signature and type
|
||||
prepareResponse(finalLength, 3);
|
||||
|
||||
|
||||
// LM Resp Length (twice)
|
||||
addUShort(lmRespLen);
|
||||
addUShort(lmRespLen);
|
||||
|
|
|
@ -84,7 +84,7 @@ public class NegotiateScheme extends GGSSchemeBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Header authenticate(
|
||||
public Header authenticate(
|
||||
final Credentials credentials,
|
||||
final HttpRequest request) throws AuthenticationException {
|
||||
return authenticate(credentials, request, null);
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.http.params.HttpParams;
|
|||
*
|
||||
* @deprecated (4.2) use {@link SPNegoSchemeFactory} or {@link KerberosSchemeFactory}.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class NegotiateSchemeFactory implements AuthSchemeFactory {
|
||||
|
||||
private final SpnegoTokenGenerator spengoGenerator;
|
||||
|
|
|
@ -61,7 +61,7 @@ import org.apache.http.util.CharArrayBuffer;
|
|||
*
|
||||
* @deprecated (4.2) use {@link AuthenticationStrategy}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
@Immutable
|
||||
public abstract class AbstractAuthenticationHandler implements AuthenticationHandler {
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ import org.apache.http.util.Args;
|
|||
* shut down by calling {@link ClientConnectionManager#shutdown()}!
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) use {@link HttpClientBuilder}.
|
||||
*/
|
||||
@ThreadSafe
|
||||
|
@ -395,7 +395,7 @@ public abstract class AbstractHttpClient extends CloseableHttpClient {
|
|||
/**
|
||||
* @deprecated (4.1) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
protected RedirectHandler createRedirectHandler() {
|
||||
return new DefaultRedirectHandler();
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ public abstract class AbstractHttpClient extends CloseableHttpClient {
|
|||
/**
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
protected AuthenticationHandler createTargetAuthenticationHandler() {
|
||||
return new DefaultTargetAuthenticationHandler();
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ public abstract class AbstractHttpClient extends CloseableHttpClient {
|
|||
/**
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
protected AuthenticationHandler createProxyAuthenticationHandler() {
|
||||
return new DefaultProxyAuthenticationHandler();
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ public abstract class AbstractHttpClient extends CloseableHttpClient {
|
|||
/**
|
||||
* @deprecated (4.1) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public synchronized final RedirectHandler getRedirectHandler() {
|
||||
return createRedirectHandler();
|
||||
}
|
||||
|
@ -561,7 +561,7 @@ public abstract class AbstractHttpClient extends CloseableHttpClient {
|
|||
/**
|
||||
* @deprecated (4.1) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public synchronized void setRedirectHandler(final RedirectHandler handler) {
|
||||
this.redirectStrategy = new DefaultRedirectStrategyAdaptor(handler);
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ public abstract class AbstractHttpClient extends CloseableHttpClient {
|
|||
/**
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public synchronized final AuthenticationHandler getTargetAuthenticationHandler() {
|
||||
return createTargetAuthenticationHandler();
|
||||
}
|
||||
|
@ -594,7 +594,7 @@ public abstract class AbstractHttpClient extends CloseableHttpClient {
|
|||
/**
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public synchronized void setTargetAuthenticationHandler(final AuthenticationHandler handler) {
|
||||
this.targetAuthStrategy = new AuthenticationStrategyAdaptor(handler);
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ public abstract class AbstractHttpClient extends CloseableHttpClient {
|
|||
/**
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public synchronized final AuthenticationHandler getProxyAuthenticationHandler() {
|
||||
return createProxyAuthenticationHandler();
|
||||
}
|
||||
|
@ -627,7 +627,7 @@ public abstract class AbstractHttpClient extends CloseableHttpClient {
|
|||
/**
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public synchronized void setProxyAuthenticationHandler(final AuthenticationHandler handler) {
|
||||
this.proxyAuthStrategy = new AuthenticationStrategyAdaptor(handler);
|
||||
}
|
||||
|
@ -777,7 +777,7 @@ public abstract class AbstractHttpClient extends CloseableHttpClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected final CloseableHttpResponse doExecute(HttpHost target, HttpRequest request,
|
||||
protected final CloseableHttpResponse doExecute(HttpHost target, HttpRequest request,
|
||||
HttpContext context)
|
||||
throws IOException, ClientProtocolException {
|
||||
|
||||
|
@ -894,7 +894,7 @@ public abstract class AbstractHttpClient extends CloseableHttpClient {
|
|||
/**
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
protected RequestDirector createClientRequestDirector(
|
||||
final HttpRequestExecutor requestExec,
|
||||
final ClientConnectionManager conman,
|
||||
|
|
|
@ -52,7 +52,7 @@ import org.apache.http.util.EntityUtils;
|
|||
* a non-2xx response using the {@link ServiceUnavailableRetryStrategy} interface.
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) use {@link HttpClientBuilder}.
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -66,7 +66,7 @@ import org.apache.http.util.Args;
|
|||
* when looking up parameters.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) use {@link DefaultedHttpParams}
|
||||
*/
|
||||
@NotThreadSafe
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.apache.http.protocol.BasicHttpProcessor;
|
|||
/**
|
||||
* {@link DefaultHttpClient} sub-class which includes a {@link RequestAcceptEncoding}
|
||||
* for the request and response.
|
||||
*
|
||||
*
|
||||
* <b>Deprecation note:</b> due to the way this class modifies a response body
|
||||
* without changing the response headers to reflect the entity changes, it cannot
|
||||
* be used as the "backend" for a caching {@link HttpClient} and still
|
||||
|
@ -47,7 +47,7 @@ import org.apache.http.protocol.BasicHttpProcessor;
|
|||
* responses in compressed or uncompressed form.
|
||||
*
|
||||
* @since 4.1
|
||||
*
|
||||
*
|
||||
* @deprecated (4.2) use {@link HttpClientBuilder}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -58,20 +58,20 @@ import org.apache.http.util.EntityUtils;
|
|||
* header on the response to uncompress any compressed response bodies.
|
||||
* The {@link java.io.InputStream} of the entity will contain the uncompressed
|
||||
* content.</p>
|
||||
*
|
||||
*
|
||||
* <p><b>N.B.</b> Any upstream clients of this class need to be aware that
|
||||
* this effectively obscures visibility into the length of a server
|
||||
* response body, since the <code>Content-Length</code> header will
|
||||
* correspond to the compressed entity length received from the server,
|
||||
* but the content length experienced by reading the response body may
|
||||
* be different (hopefully higher!).</p>
|
||||
*
|
||||
* <p>That said, this decorator is compatible with the
|
||||
* <code>CachingHttpClient</code> in that the two decorators can be added
|
||||
* in either order and still have cacheable responses be cached.</p>
|
||||
*
|
||||
*
|
||||
* <p>That said, this decorator is compatible with the
|
||||
* <code>CachingHttpClient</code> in that the two decorators can be added
|
||||
* in either order and still have cacheable responses be cached.</p>
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) use {@link HttpClientBuilder}
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -80,7 +80,7 @@ public class DecompressingHttpClient implements HttpClient {
|
|||
private final HttpClient backend;
|
||||
private final HttpRequestInterceptor acceptEncodingInterceptor;
|
||||
private final HttpResponseInterceptor contentEncodingInterceptor;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a decorator to ask for and handle compressed
|
||||
* entities on the fly.
|
||||
|
@ -98,9 +98,9 @@ public class DecompressingHttpClient implements HttpClient {
|
|||
public DecompressingHttpClient(HttpClient backend) {
|
||||
this(backend, new RequestAcceptEncoding(), new ResponseContentEncoding());
|
||||
}
|
||||
|
||||
DecompressingHttpClient(HttpClient backend,
|
||||
HttpRequestInterceptor requestInterceptor,
|
||||
|
||||
DecompressingHttpClient(HttpClient backend,
|
||||
HttpRequestInterceptor requestInterceptor,
|
||||
HttpResponseInterceptor responseInterceptor) {
|
||||
this.backend = backend;
|
||||
this.acceptEncodingInterceptor = requestInterceptor;
|
||||
|
@ -122,7 +122,7 @@ public class DecompressingHttpClient implements HttpClient {
|
|||
|
||||
/**
|
||||
* Gets the HttpClient to issue request.
|
||||
*
|
||||
*
|
||||
* @return the HttpClient to issue request
|
||||
*/
|
||||
public HttpClient getHttpClient() {
|
||||
|
|
|
@ -111,7 +111,7 @@ import org.apache.http.util.VersionInfo;
|
|||
* </ul>
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) use {@link HttpClientBuilder}.
|
||||
*/
|
||||
@ThreadSafe
|
||||
|
|
|
@ -154,11 +154,11 @@ public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler {
|
|||
|
||||
/**
|
||||
* @since 4.2
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3)
|
||||
*/
|
||||
@Deprecated
|
||||
protected boolean requestIsAborted(final HttpRequest request) {
|
||||
protected boolean requestIsAborted(final HttpRequest request) {
|
||||
HttpRequest req = request;
|
||||
if (request instanceof RequestWrapper) { // does not forward request to original
|
||||
req = ((RequestWrapper) request).getOriginal();
|
||||
|
|
|
@ -49,7 +49,7 @@ import org.apache.http.util.Args;
|
|||
*
|
||||
* @deprecated (4.2) use {@link ProxyAuthenticationStrategy}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
@Immutable
|
||||
public class DefaultProxyAuthenticationHandler extends AbstractAuthenticationHandler {
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.http.protocol.HttpContext;
|
|||
* @deprecated (4.1) do not use
|
||||
*/
|
||||
@Immutable
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
class DefaultRedirectStrategyAdaptor implements RedirectStrategy {
|
||||
|
||||
private final RedirectHandler handler;
|
||||
|
|
|
@ -128,7 +128,7 @@ import org.apache.http.util.EntityUtils;
|
|||
* </ul>
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3)
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -1050,7 +1050,7 @@ public class DefaultRequestDirector implements RequestDirector {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (HttpClientParams.isRedirecting(params) &&
|
||||
this.redirectStrategy.isRedirected(request, response, context)) {
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ import org.apache.http.protocol.HTTP;
|
|||
* the state of the original request.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) do not use.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
@NotThreadSafe // e.g. [gs]etEntity()
|
||||
public class EntityEnclosingRequestWrapper extends RequestWrapper
|
||||
implements HttpEntityEnclosingRequest {
|
||||
|
|
|
@ -330,7 +330,7 @@ public class HttpClientBuilder {
|
|||
this.backoffManager = backoffManager;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public final HttpClientBuilder setServiceUnavailableRetryStrategy(
|
||||
final ServiceUnavailableRetryStrategy serviceUnavailStrategy) {
|
||||
this.serviceUnavailStrategy = serviceUnavailStrategy;
|
||||
|
|
|
@ -152,7 +152,7 @@ class InternalHttpClient extends CloseableHttpClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected CloseableHttpResponse doExecute(
|
||||
protected CloseableHttpResponse doExecute(
|
||||
final HttpHost target,
|
||||
final HttpRequest request,
|
||||
final HttpContext context) throws IOException, ClientProtocolException {
|
||||
|
|
|
@ -86,7 +86,7 @@ class MinimalHttpClient extends CloseableHttpClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected CloseableHttpResponse doExecute(
|
||||
protected CloseableHttpResponse doExecute(
|
||||
final HttpHost target,
|
||||
final HttpRequest request,
|
||||
final HttpContext context) throws IOException, ClientProtocolException {
|
||||
|
@ -109,7 +109,7 @@ class MinimalHttpClient extends CloseableHttpClient {
|
|||
}
|
||||
if (config.getDefaultProxy() != null) {
|
||||
throw new ClientProtocolException("Minimal HttpClient does not support" +
|
||||
" request execution via proxy");
|
||||
" request execution via proxy");
|
||||
}
|
||||
localcontext.setRequestConfig(config);
|
||||
return this.requestExecutor.execute(route, wrapper, localcontext, execAware);
|
||||
|
|
|
@ -50,11 +50,11 @@ import org.apache.http.util.Args;
|
|||
* the state of the original request.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) do not use.
|
||||
*/
|
||||
@NotThreadSafe
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class RequestWrapper extends AbstractHttpMessage implements HttpUriRequest {
|
||||
|
||||
private final HttpRequest original;
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.http.conn.routing.HttpRoute;
|
|||
* A request with the route along which it should be sent.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) do not use.
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -101,7 +101,7 @@ import org.apache.http.params.HttpParams;
|
|||
* </p>
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
*
|
||||
* @deprecated (4.3) use {@link HttpClientBuilder}
|
||||
*/
|
||||
@ThreadSafe
|
||||
|
|
|
@ -90,4 +90,4 @@ class Proxies {
|
|||
new ResponseProxyHandler(original, connReleaseTrigger));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,4 +85,4 @@ class RequestEntityExecHandler implements InvocationHandler {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ServiceUnavailableRetryExec implements ClientExecChain {
|
|||
private final ServiceUnavailableRetryStrategy retryStrategy;
|
||||
|
||||
public ServiceUnavailableRetryExec(
|
||||
final ClientExecChain requestExecutor,
|
||||
final ClientExecChain requestExecutor,
|
||||
final ServiceUnavailableRetryStrategy retryStrategy) {
|
||||
super();
|
||||
Args.notNull(requestExecutor, "HTTP request executor");
|
||||
|
@ -67,7 +67,7 @@ public class ServiceUnavailableRetryExec implements ClientExecChain {
|
|||
}
|
||||
|
||||
public CloseableHttpResponse execute(
|
||||
final HttpRoute route,
|
||||
final HttpRoute route,
|
||||
final HttpRequestWrapper request,
|
||||
final HttpClientContext context,
|
||||
final HttpExecutionAware execAware) throws IOException, HttpException {
|
||||
|
|
|
@ -129,7 +129,7 @@ public abstract class AbstractClientConnAdapter implements ManagedClientConnecti
|
|||
* @deprecated (4.1) use {@link #assertValid(OperatedClientConnection)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected final void assertNotAborted() throws InterruptedIOException {
|
||||
protected final void assertNotAborted() throws InterruptedIOException {
|
||||
if (isReleased()) {
|
||||
throw new InterruptedIOException("Connection has been shut down");
|
||||
}
|
||||
|
|
|
@ -71,11 +71,11 @@ public abstract class AbstractPooledConnAdapter extends AbstractClientConnAdapte
|
|||
* Obtains the pool entry.
|
||||
*
|
||||
* @return the pool entry, or <code>null</code> if detached
|
||||
*
|
||||
* @deprecated (4.0.1)
|
||||
*
|
||||
* @deprecated (4.0.1)
|
||||
*/
|
||||
@Deprecated
|
||||
protected AbstractPoolEntry getPoolEntry() {
|
||||
protected AbstractPoolEntry getPoolEntry() {
|
||||
return this.poolEntry;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ public abstract class AbstractPooledConnAdapter extends AbstractClientConnAdapte
|
|||
* @deprecated (4.1) use {@link #assertValid(AbstractPoolEntry)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected final void assertAttached() {
|
||||
protected final void assertAttached() {
|
||||
if (poolEntry == null) {
|
||||
throw new ConnectionShutdownException();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ import org.apache.http.util.Asserts;
|
|||
|
||||
/**
|
||||
* A connection manager for a single connection. This connection manager maintains only one active
|
||||
* connection. Even though this class is fully thread-safe it ought to be used by one execution
|
||||
* connection. Even though this class is fully thread-safe it ought to be used by one execution
|
||||
* thread only, as only one thread a time can lease the connection at a time.
|
||||
* <p/>
|
||||
* This connection manager will make an effort to reuse the connection for subsequent requests
|
||||
|
@ -186,7 +186,7 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void releaseConnection(final ManagedClientConnection conn, long keepalive, TimeUnit tunit) {
|
||||
Args.check(conn instanceof ManagedClientConnectionImpl, "Connection class mismatch, " +
|
||||
"connection not obtained from this manager");
|
||||
|
|
|
@ -65,7 +65,7 @@ public class DefaultClientConnectionFactory implements HttpConnectionFactory<Soc
|
|||
return new SocketClientConnectionImpl(8 * 1024,
|
||||
chardecoder, charencoder,
|
||||
cconfig.getMessageConstraints(),
|
||||
null, null, null,
|
||||
null, null, null,
|
||||
DefaultHttpResponseParserFactory.INSTANCE);
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ public class DefaultClientConnectionOperator implements ClientConnectionOperator
|
|||
}
|
||||
return reg;
|
||||
}
|
||||
|
||||
|
||||
public void openConnection(
|
||||
final OperatedClientConnection conn,
|
||||
final HttpHost target,
|
||||
|
|
|
@ -50,7 +50,7 @@ import org.apache.http.util.Args;
|
|||
import org.apache.http.util.CharArrayBuffer;
|
||||
|
||||
/**
|
||||
* Lenient HTTP response parser implementation that can skip malformed data until
|
||||
* Lenient HTTP response parser implementation that can skip malformed data until
|
||||
* a valid HTTP response message head is encountered.
|
||||
*
|
||||
* @since 4.2
|
||||
|
@ -79,18 +79,18 @@ public class DefaultHttpResponseParser extends AbstractMessageParser<HttpRespons
|
|||
this.responseFactory = responseFactory;
|
||||
this.lineBuf = new CharArrayBuffer(128);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates new instance of DefaultHttpResponseParser.
|
||||
*
|
||||
* @param buffer the session input buffer.
|
||||
* @param lineParser the line parser. If <code>null</code> {@link BasicLineParser#INSTANCE}
|
||||
* will be used.
|
||||
* @param responseFactory HTTP response factory. If <code>null</code>
|
||||
* @param responseFactory HTTP response factory. If <code>null</code>
|
||||
* {@link DefaultHttpResponseFactory#INSTANCE} will be used.
|
||||
* @param constraints the message constraints. If <code>null</code>
|
||||
* {@link MessageConstraints#DEFAULT} will be used.
|
||||
*
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public DefaultHttpResponseParser(
|
||||
|
@ -108,7 +108,7 @@ public class DefaultHttpResponseParser extends AbstractMessageParser<HttpRespons
|
|||
* Creates new instance of DefaultHttpResponseParser.
|
||||
*
|
||||
* @param buffer the session input buffer.
|
||||
*
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public DefaultHttpResponseParser(final SessionInputBuffer buffer) {
|
||||
|
@ -151,5 +151,5 @@ public class DefaultHttpResponseParser extends AbstractMessageParser<HttpRespons
|
|||
protected boolean reject(CharArrayBuffer line, int count) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ import org.apache.http.util.CharArrayBuffer;
|
|||
* </ul>
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*
|
||||
* @deprecated (4.2) use {@link DefaultHttpResponseParser}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
@ -485,4 +485,4 @@ public class PoolingHttpClientConnectionManager implements HttpClientConnectionM
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ import org.apache.http.util.Asserts;
|
|||
* @deprecated (4.2) use {@link BasicClientConnectionManager}
|
||||
*/
|
||||
@ThreadSafe
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class SingleClientConnManager implements ClientConnectionManager {
|
||||
|
||||
private final Log log = LogFactory.getLog(getClass());
|
||||
|
@ -109,7 +109,7 @@ public class SingleClientConnManager implements ClientConnectionManager {
|
|||
* @deprecated (4.1) use {@link SingleClientConnManager#SingleClientConnManager(SchemeRegistry)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SingleClientConnManager(HttpParams params,
|
||||
public SingleClientConnManager(HttpParams params,
|
||||
SchemeRegistry schreg) {
|
||||
this(schreg);
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public class Wire {
|
|||
/**
|
||||
* @deprecated (4.1) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public void output(final String s)
|
||||
throws IOException {
|
||||
Args.notNull(s, "Output");
|
||||
|
@ -151,7 +151,7 @@ public class Wire {
|
|||
/**
|
||||
* @deprecated (4.1) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public void input(final String s)
|
||||
throws IOException {
|
||||
Args.notNull(s, "Input");
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.apache.http.util.Args;
|
|||
*
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class BasicPoolEntryRef extends WeakReference<BasicPoolEntry> {
|
||||
|
||||
/** The planned route of the entry. */
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.apache.http.impl.conn.AbstractPooledConnAdapter;
|
|||
*
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class BasicPooledConnAdapter extends AbstractPooledConnAdapter {
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,7 +67,7 @@ import org.apache.http.util.Asserts;
|
|||
*
|
||||
* @deprecated (4.2) use {@link org.apache.http.pool.AbstractConnPool}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class ConnPoolByRoute extends AbstractConnPool {
|
||||
|
||||
private final Log log = LogFactory.getLog(getClass());
|
||||
|
@ -148,7 +148,7 @@ public class ConnPoolByRoute extends AbstractConnPool {
|
|||
* @deprecated (4.1) use {@link ConnPoolByRoute#ConnPoolByRoute(ClientConnectionOperator, ConnPerRoute, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params) {
|
||||
public ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params) {
|
||||
this(operator,
|
||||
ConnManagerParams.getMaxConnectionsPerRoute(params),
|
||||
ConnManagerParams.getMaxTotalConnections(params));
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.http.conn.ConnectionPoolTimeoutException;
|
|||
*
|
||||
* @deprecated (4.2) use {@link Future}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public interface PoolEntryRequest {
|
||||
|
||||
/**
|
||||
|
|
|
@ -80,7 +80,7 @@ public class RouteSpecificPool {
|
|||
* @deprecated (4.1) use {@link RouteSpecificPool#RouteSpecificPool(HttpRoute, ConnPerRoute)}
|
||||
*/
|
||||
@Deprecated
|
||||
public RouteSpecificPool(HttpRoute route, int maxEntries) {
|
||||
public RouteSpecificPool(HttpRoute route, int maxEntries) {
|
||||
this.route = route;
|
||||
this.maxEntries = maxEntries;
|
||||
this.connPerRoute = new ConnPerRoute() {
|
||||
|
|
|
@ -69,7 +69,7 @@ import org.apache.http.util.Asserts;
|
|||
* @deprecated (4.2) use {@link PoolingClientConnectionManager}
|
||||
*/
|
||||
@ThreadSafe
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class ThreadSafeClientConnManager implements ClientConnectionManager {
|
||||
|
||||
private final Log log;
|
||||
|
@ -150,7 +150,7 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
|
|||
* @deprecated (4.1) use {@link ThreadSafeClientConnManager#ThreadSafeClientConnManager(SchemeRegistry)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ThreadSafeClientConnManager(HttpParams params,
|
||||
public ThreadSafeClientConnManager(HttpParams params,
|
||||
SchemeRegistry schreg) {
|
||||
Args.notNull(schreg, "Scheme registry");
|
||||
this.log = LogFactory.getLog(getClass());
|
||||
|
@ -178,7 +178,7 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
|
|||
* @deprecated (4.1) use #createConnectionPool(long, TimeUnit))
|
||||
*/
|
||||
@Deprecated
|
||||
protected AbstractConnPool createConnectionPool(final HttpParams params) {
|
||||
protected AbstractConnPool createConnectionPool(final HttpParams params) {
|
||||
return new ConnPoolByRoute(connOperator, params);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.apache.http.util.Args;
|
|||
*
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class WaitingThread {
|
||||
|
||||
/** The condition on which the thread is waiting. */
|
||||
|
|
|
@ -35,7 +35,7 @@ package org.apache.http.impl.conn.tsccm;
|
|||
*
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class WaitingThreadAborter {
|
||||
|
||||
private WaitingThread waitingThread;
|
||||
|
|
|
@ -39,28 +39,28 @@ import org.apache.http.util.Args;
|
|||
*/
|
||||
@Immutable
|
||||
public class BrowserCompatVersionAttributeHandler extends
|
||||
AbstractCookieAttributeHandler {
|
||||
AbstractCookieAttributeHandler {
|
||||
|
||||
public BrowserCompatVersionAttributeHandler() {
|
||||
super();
|
||||
}
|
||||
public BrowserCompatVersionAttributeHandler() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse cookie version attribute.
|
||||
*/
|
||||
public void parse(final SetCookie cookie, final String value)
|
||||
throws MalformedCookieException {
|
||||
Args.notNull(cookie, "Cookie");
|
||||
if (value == null) {
|
||||
throw new MalformedCookieException("Missing value for version attribute");
|
||||
}
|
||||
int version = 0;
|
||||
try {
|
||||
version = Integer.parseInt(value);
|
||||
} catch (NumberFormatException e) {
|
||||
// Just ignore invalid versions
|
||||
}
|
||||
cookie.setVersion(version);
|
||||
}
|
||||
/**
|
||||
* Parse cookie version attribute.
|
||||
*/
|
||||
public void parse(final SetCookie cookie, final String value)
|
||||
throws MalformedCookieException {
|
||||
Args.notNull(cookie, "Cookie");
|
||||
if (value == null) {
|
||||
throw new MalformedCookieException("Missing value for version attribute");
|
||||
}
|
||||
int version = 0;
|
||||
try {
|
||||
version = Integer.parseInt(value);
|
||||
} catch (NumberFormatException e) {
|
||||
// Just ignore invalid versions
|
||||
}
|
||||
cookie.setVersion(version);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ import org.apache.http.protocol.HttpContext;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@Deprecated
|
||||
@Deprecated
|
||||
public class TestResponseAuthCache {
|
||||
|
||||
private HttpHost target;
|
||||
|
|
|
@ -192,9 +192,9 @@ public class TestURIBuilder {
|
|||
.build();
|
||||
|
||||
Assert.assertEquals(uri.getHost(), bld.getHost());
|
||||
|
||||
|
||||
Assert.assertEquals(uri.getUserInfo(), bld.getUserInfo());
|
||||
|
||||
|
||||
Assert.assertEquals(uri.getPath(), bld.getPath());
|
||||
|
||||
Assert.assertEquals(uri.getQuery(), bld.getQuery());
|
||||
|
@ -221,9 +221,9 @@ public class TestURIBuilder {
|
|||
.build();
|
||||
|
||||
Assert.assertEquals(uri.getHost(), bld.getHost());
|
||||
|
||||
|
||||
Assert.assertEquals(uri.getRawUserInfo(), bld.getRawUserInfo());
|
||||
|
||||
|
||||
Assert.assertEquals(uri.getRawPath(), bld.getRawPath());
|
||||
|
||||
Assert.assertEquals(uri.getRawQuery(), bld.getRawQuery());
|
||||
|
|
|
@ -200,7 +200,7 @@ public class TestNTLMEngineImpl {
|
|||
public void testType1Message() throws Exception {
|
||||
new NTLMEngineImpl().getType1Message("myhost", "mydomain");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testType3Message() throws Exception {
|
||||
new NTLMEngineImpl().getType3Message("me", "mypassword", "myhost", "mydomain",
|
||||
|
@ -213,7 +213,7 @@ public class TestNTLMEngineImpl {
|
|||
"mytarget",
|
||||
toBytes("02000c0044004f004d00410049004e0001000c005300450052005600450052000400140064006f006d00610069006e002e0063006f006d00030022007300650072007600650072002e0064006f006d00610069006e002e0063006f006d0000000000"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRC4() throws Exception {
|
||||
checkArraysMatch(toBytes("e37f97f2544f4d7e"),
|
||||
|
|
|
@ -51,11 +51,11 @@ public class DummyHttpClient implements HttpClient {
|
|||
private ClientConnectionManager connManager = new SingleClientConnManager();
|
||||
private HttpRequest request;
|
||||
private HttpResponse response = new BasicHttpResponse(new ProtocolVersion("HTTP",1,1), HttpStatus.SC_OK, "OK");
|
||||
|
||||
|
||||
public void setParams(HttpParams params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
|
||||
public HttpParams getParams() {
|
||||
return params;
|
||||
}
|
||||
|
@ -63,15 +63,15 @@ public class DummyHttpClient implements HttpClient {
|
|||
public ClientConnectionManager getConnectionManager() {
|
||||
return connManager;
|
||||
}
|
||||
|
||||
|
||||
public void setConnectionManager(ClientConnectionManager ccm) {
|
||||
connManager = ccm;
|
||||
}
|
||||
|
||||
|
||||
public void setResponse(HttpResponse resp) {
|
||||
response = resp;
|
||||
}
|
||||
|
||||
|
||||
public HttpRequest getCapturedRequest() {
|
||||
return request;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ import org.mockito.runners.MockitoJUnitRunner;
|
|||
@Deprecated
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TestDecompressingHttpClient {
|
||||
|
||||
|
||||
private DummyHttpClient backend;
|
||||
@Mock private ClientConnectionManager mockConnManager;
|
||||
@Mock private ResponseHandler<Object> mockHandler;
|
||||
|
@ -84,7 +84,7 @@ public class TestDecompressingHttpClient {
|
|||
@Mock private HttpResponse mockResponse;
|
||||
@Mock private HttpEntity mockEntity;
|
||||
private Object handled;
|
||||
|
||||
|
||||
@Before
|
||||
public void canCreate() {
|
||||
handled = new Object();
|
||||
|
@ -95,61 +95,61 @@ public class TestDecompressingHttpClient {
|
|||
ctx = new BasicHttpContext();
|
||||
host = new HttpHost("www.example.com");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void isAnHttpClient() {
|
||||
assertTrue(impl instanceof HttpClient);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void usesParamsFromBackend() {
|
||||
HttpParams params = new BasicHttpParams();
|
||||
backend.setParams(params);
|
||||
assertSame(params, impl.getParams());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void extractsHostNameFromUriRequest() {
|
||||
assertEquals(new HttpHost("www.example.com"),
|
||||
assertEquals(new HttpHost("www.example.com"),
|
||||
impl.getHttpHost(new HttpGet("http://www.example.com/")));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void extractsHostNameAndPortFromUriRequest() {
|
||||
assertEquals(new HttpHost("www.example.com", 8080),
|
||||
assertEquals(new HttpHost("www.example.com", 8080),
|
||||
impl.getHttpHost(new HttpGet("http://www.example.com:8080/")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractsIPAddressFromUriRequest() {
|
||||
assertEquals(new HttpHost("10.0.0.1"),
|
||||
assertEquals(new HttpHost("10.0.0.1"),
|
||||
impl.getHttpHost(new HttpGet("http://10.0.0.1/")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractsIPAddressAndPortFromUriRequest() {
|
||||
assertEquals(new HttpHost("10.0.0.1", 8080),
|
||||
assertEquals(new HttpHost("10.0.0.1", 8080),
|
||||
impl.getHttpHost(new HttpGet("http://10.0.0.1:8080/")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractsLocalhostFromUriRequest() {
|
||||
assertEquals(new HttpHost("localhost"),
|
||||
assertEquals(new HttpHost("localhost"),
|
||||
impl.getHttpHost(new HttpGet("http://localhost/")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractsLocalhostAndPortFromUriRequest() {
|
||||
assertEquals(new HttpHost("localhost", 8080),
|
||||
assertEquals(new HttpHost("localhost", 8080),
|
||||
impl.getHttpHost(new HttpGet("http://localhost:8080/")));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void usesConnectionManagerFromBackend() {
|
||||
backend.setConnectionManager(mockConnManager);
|
||||
assertSame(mockConnManager, impl.getConnectionManager());
|
||||
}
|
||||
|
||||
|
||||
private void assertAcceptEncodingGzipAndDeflateWereAddedToRequest(HttpRequest captured) {
|
||||
boolean foundGzip = false;
|
||||
boolean foundDeflate = false;
|
||||
|
@ -162,7 +162,7 @@ public class TestDecompressingHttpClient {
|
|||
assertTrue(foundGzip);
|
||||
assertTrue(foundDeflate);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void addsAcceptEncodingHeaderToHttpUriRequest() throws Exception {
|
||||
impl.execute(request);
|
||||
|
@ -174,19 +174,19 @@ public class TestDecompressingHttpClient {
|
|||
impl.execute(request, ctx);
|
||||
assertAcceptEncodingGzipAndDeflateWereAddedToRequest(backend.getCapturedRequest());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void addsAcceptEncodingHeaderToHostAndHttpRequest() throws Exception {
|
||||
impl.execute(host, request);
|
||||
assertAcceptEncodingGzipAndDeflateWereAddedToRequest(backend.getCapturedRequest());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void addsAcceptEncodingHeaderToHostAndHttpRequestWithContext() throws Exception {
|
||||
impl.execute(host, request, ctx);
|
||||
assertAcceptEncodingGzipAndDeflateWereAddedToRequest(backend.getCapturedRequest());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void addsAcceptEncodingHeaderToUriRequestWithHandler() throws Exception {
|
||||
when(mockHandler.handleResponse(isA(HttpResponse.class))).thenReturn(new Object());
|
||||
|
@ -223,35 +223,35 @@ public class TestDecompressingHttpClient {
|
|||
when(mockResponse.getLastHeader("Content-Encoding")).thenReturn(null);
|
||||
when(mockResponse.getEntity()).thenReturn(mockEntity);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void doesNotModifyResponseBodyIfNoContentEncoding() throws Exception {
|
||||
mockResponseHasNoContentEncodingHeaders();
|
||||
assertSame(mockResponse, impl.execute(request));
|
||||
verify(mockResponse, never()).setEntity(any(HttpEntity.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void doesNotModifyResponseBodyIfNoContentEncodingWithContext() throws Exception {
|
||||
mockResponseHasNoContentEncodingHeaders();
|
||||
assertSame(mockResponse, impl.execute(request, ctx));
|
||||
verify(mockResponse, never()).setEntity(any(HttpEntity.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void doesNotModifyResponseBodyIfNoContentEncodingForHostRequest() throws Exception {
|
||||
mockResponseHasNoContentEncodingHeaders();
|
||||
assertSame(mockResponse, impl.execute(host, request));
|
||||
verify(mockResponse, never()).setEntity(any(HttpEntity.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void doesNotModifyResponseBodyIfNoContentEncodingForHostRequestWithContext() throws Exception {
|
||||
mockResponseHasNoContentEncodingHeaders();
|
||||
assertSame(mockResponse, impl.execute(host, request, ctx));
|
||||
verify(mockResponse, never()).setEntity(any(HttpEntity.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void doesNotModifyResponseBodyWithHandlerIfNoContentEncoding() throws Exception {
|
||||
mockResponseHasNoContentEncodingHeaders();
|
||||
|
@ -259,7 +259,7 @@ public class TestDecompressingHttpClient {
|
|||
assertSame(handled, impl.execute(request, mockHandler));
|
||||
verify(mockResponse, never()).setEntity(any(HttpEntity.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void doesNotModifyResponseBodyWithHandlerAndContextIfNoContentEncoding() throws Exception {
|
||||
mockResponseHasNoContentEncodingHeaders();
|
||||
|
@ -267,7 +267,7 @@ public class TestDecompressingHttpClient {
|
|||
assertSame(handled, impl.execute(request, mockHandler, ctx));
|
||||
verify(mockResponse, never()).setEntity(any(HttpEntity.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void doesNotModifyResponseBodyWithHostAndHandlerIfNoContentEncoding() throws Exception {
|
||||
mockResponseHasNoContentEncodingHeaders();
|
||||
|
@ -275,7 +275,7 @@ public class TestDecompressingHttpClient {
|
|||
assertSame(handled, impl.execute(host, request, mockHandler));
|
||||
verify(mockResponse, never()).setEntity(any(HttpEntity.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void doesNotModifyResponseBodyWithHostAndHandlerAndContextIfNoContentEncoding() throws Exception {
|
||||
mockResponseHasNoContentEncodingHeaders();
|
||||
|
@ -283,13 +283,13 @@ public class TestDecompressingHttpClient {
|
|||
assertSame(handled, impl.execute(host, request, mockHandler, ctx));
|
||||
verify(mockResponse, never()).setEntity(any(HttpEntity.class));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void successfullyUncompressesContent() throws Exception {
|
||||
final String plainText = "hello\n";
|
||||
HttpResponse response = getGzippedResponse(plainText);
|
||||
backend.setResponse(response);
|
||||
|
||||
|
||||
HttpResponse result = impl.execute(request);
|
||||
ByteArrayOutputStream resultBuf = new ByteArrayOutputStream();
|
||||
InputStream is = result.getEntity().getContent();
|
||||
|
@ -300,13 +300,13 @@ public class TestDecompressingHttpClient {
|
|||
is.close();
|
||||
assertEquals(plainText, new String(resultBuf.toByteArray()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void uncompressedResponseHasUnknownLength() throws Exception {
|
||||
final String plainText = "hello\n";
|
||||
HttpResponse response = getGzippedResponse(plainText);
|
||||
backend.setResponse(response);
|
||||
|
||||
|
||||
HttpResponse result = impl.execute(request);
|
||||
HttpEntity entity = result.getEntity();
|
||||
assertEquals(-1, entity.getContentLength());
|
||||
|
@ -319,22 +319,22 @@ public class TestDecompressingHttpClient {
|
|||
final String plainText = "hello\n";
|
||||
HttpResponse response = getGzippedResponse(plainText);
|
||||
backend.setResponse(response);
|
||||
|
||||
|
||||
HttpResponse result = impl.execute(request);
|
||||
assertNull(result.getFirstHeader("Content-Encoding"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void uncompressedResponseHasContentMD5Removed() throws Exception {
|
||||
final String plainText = "hello\n";
|
||||
HttpResponse response = getGzippedResponse(plainText);
|
||||
response.setHeader("Content-MD5","a checksum");
|
||||
backend.setResponse(response);
|
||||
|
||||
|
||||
HttpResponse result = impl.execute(request);
|
||||
assertNull(result.getFirstHeader("Content-MD5"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void unencodedResponseRetainsContentMD5() throws Exception {
|
||||
final String plainText = "hello\n";
|
||||
|
@ -342,20 +342,20 @@ public class TestDecompressingHttpClient {
|
|||
response.setHeader("Content-MD5","a checksum");
|
||||
response.setEntity(new ByteArrayEntity(plainText.getBytes()));
|
||||
backend.setResponse(response);
|
||||
|
||||
|
||||
HttpResponse result = impl.execute(request);
|
||||
assertNotNull(result.getFirstHeader("Content-MD5"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void passesThroughTheBodyOfAPOST() throws Exception {
|
||||
when(mockHandler.handleResponse(isA(HttpResponse.class))).thenReturn(new Object());
|
||||
HttpPost post = new HttpPost("http://localhost:8080/");
|
||||
post.setEntity(new ByteArrayEntity("hello".getBytes()));
|
||||
impl.execute(host, post, mockHandler, ctx);
|
||||
assertNotNull(((HttpEntityEnclosingRequest)backend.getCapturedRequest()).getEntity());
|
||||
when(mockHandler.handleResponse(isA(HttpResponse.class))).thenReturn(new Object());
|
||||
HttpPost post = new HttpPost("http://localhost:8080/");
|
||||
post.setEntity(new ByteArrayEntity("hello".getBytes()));
|
||||
impl.execute(host, post, mockHandler, ctx);
|
||||
assertNotNull(((HttpEntityEnclosingRequest)backend.getCapturedRequest()).getEntity());
|
||||
}
|
||||
|
||||
|
||||
private HttpResponse getGzippedResponse(final String plainText)
|
||||
throws IOException {
|
||||
HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
|
||||
|
|
|
@ -156,7 +156,7 @@ public class TestSPNegoScheme extends IntegrationTestBase {
|
|||
HttpHost target = new HttpHost("localhost", port);
|
||||
|
||||
AuthSchemeProvider nsf = new NegotiateSchemeProviderWithMockGssManager();
|
||||
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
||||
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
||||
Credentials use_jaas_creds = new UseJaasCredentials();
|
||||
credentialsProvider.setCredentials(new AuthScope(null, -1, null), use_jaas_creds);
|
||||
|
||||
|
@ -164,7 +164,7 @@ public class TestSPNegoScheme extends IntegrationTestBase {
|
|||
.registerAuthScheme(AuthSchemes.SPNEGO, nsf)
|
||||
.setCredentialsProvider(credentialsProvider)
|
||||
.build();
|
||||
|
||||
|
||||
String s = "/path";
|
||||
HttpGet httpget = new HttpGet(s);
|
||||
HttpResponse response = this.httpclient.execute(target, httpget);
|
||||
|
@ -186,15 +186,15 @@ public class TestSPNegoScheme extends IntegrationTestBase {
|
|||
|
||||
AuthSchemeProvider nsf = new NegotiateSchemeProviderWithMockGssManager();
|
||||
|
||||
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
||||
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
||||
Credentials use_jaas_creds = new UseJaasCredentials();
|
||||
credentialsProvider.setCredentials(new AuthScope(null, -1, null), use_jaas_creds);
|
||||
|
||||
|
||||
this.httpclient = HttpClients.custom()
|
||||
.registerAuthScheme(AuthSchemes.SPNEGO, nsf)
|
||||
.setCredentialsProvider(credentialsProvider)
|
||||
.build();
|
||||
|
||||
|
||||
String s = "/path";
|
||||
HttpGet httpget = new HttpGet(s);
|
||||
HttpResponse response = this.httpclient.execute(target, httpget);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue