HTTPCLIENT-1005: reduced public API
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1023261 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6892f58f2c
commit
65528c02ec
|
@ -13,7 +13,6 @@ import org.apache.http.HttpRequest;
|
|||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.HttpVersion;
|
||||
import org.apache.http.client.cache.HttpCache;
|
||||
import org.apache.http.client.cache.HttpCacheEntry;
|
||||
import org.apache.http.client.cache.HttpCacheStorage;
|
||||
import org.apache.http.client.cache.HttpCacheUpdateCallback;
|
||||
|
@ -23,7 +22,7 @@ import org.apache.http.client.cache.ResourceFactory;
|
|||
import org.apache.http.entity.ByteArrayEntity;
|
||||
import org.apache.http.message.BasicHttpResponse;
|
||||
|
||||
public class BasicHttpCache implements HttpCache {
|
||||
class BasicHttpCache implements HttpCache {
|
||||
|
||||
private final URIExtractor uriExtractor;
|
||||
private final ResourceFactory resourceFactory;
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.apache.http.HttpHost;
|
|||
import org.apache.http.HttpRequest;
|
||||
import org.apache.http.annotation.ThreadSafe;
|
||||
import org.apache.http.client.cache.HeaderConstants;
|
||||
import org.apache.http.client.cache.HttpCache;
|
||||
import org.apache.http.client.cache.HttpCacheEntry;
|
||||
import org.apache.http.client.cache.HttpCacheStorage;
|
||||
|
||||
|
|
|
@ -52,8 +52,9 @@ import org.apache.http.client.HttpClient;
|
|||
import org.apache.http.client.ResponseHandler;
|
||||
import org.apache.http.client.cache.CacheResponseStatus;
|
||||
import org.apache.http.client.cache.HeaderConstants;
|
||||
import org.apache.http.client.cache.HttpCache;
|
||||
import org.apache.http.client.cache.HttpCacheEntry;
|
||||
import org.apache.http.client.cache.HttpCacheStorage;
|
||||
import org.apache.http.client.cache.ResourceFactory;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.conn.ClientConnectionManager;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
|
@ -96,7 +97,7 @@ public class CachingHttpClient implements HttpClient {
|
|||
|
||||
private final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
public CachingHttpClient(
|
||||
CachingHttpClient(
|
||||
HttpClient client,
|
||||
HttpCache cache,
|
||||
CacheConfig config) {
|
||||
|
@ -150,26 +151,22 @@ public class CachingHttpClient implements HttpClient {
|
|||
}
|
||||
|
||||
public CachingHttpClient(
|
||||
HttpCache cache) {
|
||||
this(new DefaultHttpClient(),
|
||||
cache,
|
||||
new CacheConfig());
|
||||
}
|
||||
|
||||
public CachingHttpClient(
|
||||
HttpCache cache,
|
||||
HttpClient client,
|
||||
ResourceFactory resourceFactory,
|
||||
HttpCacheStorage storage,
|
||||
CacheConfig config) {
|
||||
this(new DefaultHttpClient(),
|
||||
cache,
|
||||
this(client,
|
||||
new BasicHttpCache(resourceFactory, storage, config),
|
||||
config);
|
||||
}
|
||||
|
||||
public CachingHttpClient(
|
||||
HttpClient client,
|
||||
HttpCache cache) {
|
||||
HttpCacheStorage storage,
|
||||
CacheConfig config) {
|
||||
this(client,
|
||||
cache,
|
||||
new CacheConfig());
|
||||
new BasicHttpCache(new HeapResourceFactory(), storage, config),
|
||||
config);
|
||||
}
|
||||
|
||||
CachingHttpClient(
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package org.apache.http.client.cache;
|
||||
package org.apache.http.impl.client.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
@ -33,11 +33,12 @@ import java.util.Set;
|
|||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpRequest;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.cache.HttpCacheEntry;
|
||||
|
||||
/**
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface HttpCache {
|
||||
interface HttpCache {
|
||||
|
||||
/**
|
||||
* Clear all matching {@link HttpCacheEntry}s.
|
|
@ -29,7 +29,7 @@ package org.apache.http.impl.client.cache;
|
|||
/**
|
||||
* @since 4.1
|
||||
*/
|
||||
public enum RequestProtocolError {
|
||||
enum RequestProtocolError {
|
||||
|
||||
UNKNOWN,
|
||||
BODY_BUT_NO_LENGTH_ERROR,
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.apache.http.HttpRequest;
|
|||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpVersion;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.cache.HttpCache;
|
||||
import org.apache.http.client.cache.HttpCacheEntry;
|
||||
import org.apache.http.message.BasicHttpRequest;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.apache.http.NameValuePair;
|
|||
import org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.cache.HttpCache;
|
||||
import org.apache.http.entity.ByteArrayEntity;
|
||||
import org.apache.http.impl.cookie.DateUtils;
|
||||
import org.apache.http.message.BasicHttpRequest;
|
||||
|
|
|
@ -47,7 +47,6 @@ import org.apache.http.client.HttpClient;
|
|||
import org.apache.http.client.ResponseHandler;
|
||||
import org.apache.http.client.cache.CacheResponseStatus;
|
||||
import org.apache.http.client.cache.HeaderConstants;
|
||||
import org.apache.http.client.cache.HttpCache;
|
||||
import org.apache.http.client.cache.HttpCacheEntry;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
|
@ -1907,7 +1906,7 @@ public class TestCachingHttpClient {
|
|||
public void testTreatsCacheIOExceptionsAsCacheMiss()
|
||||
throws Exception {
|
||||
|
||||
impl = new CachingHttpClient(mockBackend, mockCache);
|
||||
impl = new CachingHttpClient(mockBackend, mockCache, new CacheConfig());
|
||||
HttpResponse resp = HttpTestUtils.make200Response();
|
||||
|
||||
mockCache.flushInvalidatedCacheEntriesFor(host, request);
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.apache.http.HttpStatus;
|
|||
import org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.cache.HttpCache;
|
||||
import org.apache.http.entity.ByteArrayEntity;
|
||||
import org.apache.http.impl.cookie.DateUtils;
|
||||
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
|
||||
|
|
|
@ -31,18 +31,12 @@ import net.sf.ehcache.config.CacheConfiguration;
|
|||
import net.sf.ehcache.config.Configuration;
|
||||
import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpVersion;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.cache.HttpCache;
|
||||
import org.apache.http.client.cache.HttpCacheStorage;
|
||||
import org.apache.http.impl.client.cache.BasicHttpCache;
|
||||
import org.apache.http.impl.client.cache.CacheConfig;
|
||||
import org.apache.http.impl.client.cache.CachingHttpClient;
|
||||
import org.apache.http.impl.client.cache.HeapResourceFactory;
|
||||
import org.apache.http.impl.client.cache.HttpTestUtils;
|
||||
import org.apache.http.impl.client.cache.TestProtocolRequirements;
|
||||
import org.apache.http.message.BasicHttpRequest;
|
||||
import org.easymock.classextension.EasyMock;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -68,14 +62,7 @@ public class TestEhcacheProtocolRequirements extends TestProtocolRequirements{
|
|||
@Override
|
||||
@Before
|
||||
public void setUp() {
|
||||
host = new HttpHost("foo.example.com");
|
||||
|
||||
body = HttpTestUtils.makeBody(entityLength);
|
||||
|
||||
request = new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1);
|
||||
|
||||
originResponse = HttpTestUtils.make200Response();
|
||||
|
||||
super.setUp();
|
||||
params = new CacheConfig();
|
||||
params.setMaxObjectSizeBytes(MAX_BYTES);
|
||||
|
||||
|
@ -84,11 +71,9 @@ public class TestEhcacheProtocolRequirements extends TestProtocolRequirements{
|
|||
}
|
||||
CACHE_MANAGER.addCache(TEST_EHCACHE_NAME);
|
||||
HttpCacheStorage storage = new EhcacheHttpCacheStorage(CACHE_MANAGER.getCache(TEST_EHCACHE_NAME));
|
||||
cache = new BasicHttpCache(new HeapResourceFactory(), storage, params);
|
||||
mockBackend = EasyMock.createMock(HttpClient.class);
|
||||
mockCache = EasyMock.createMock(HttpCache.class);
|
||||
|
||||
impl = new CachingHttpClient(mockBackend, cache, params);
|
||||
impl = new CachingHttpClient(mockBackend, new HeapResourceFactory(), storage, params);
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
Loading…
Reference in New Issue