Tab police
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1055725 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3b4b68fe68
commit
4896d1752c
|
@ -228,7 +228,7 @@ public class HttpCacheEntry implements Serializable {
|
|||
public Map<String, String> getVariantMap() {
|
||||
if (variantMap == null) {
|
||||
throw new UnsupportedOperationException("variant maps not" +
|
||||
"supported if constructed with deprecated variant set");
|
||||
"supported if constructed with deprecated variant set");
|
||||
}
|
||||
return Collections.unmodifiableMap(variantMap);
|
||||
}
|
||||
|
|
|
@ -100,12 +100,12 @@ class CacheEntryUpdater {
|
|||
|
||||
if (entryAndResponseHaveDateHeader(entry, response)
|
||||
&& entryDateHeaderNewerThenResponse(entry, response)) {
|
||||
// Don't merge headers, keep the entry's headers as they are newer.
|
||||
return entry.getAllHeaders();
|
||||
// Don't merge headers, keep the entry's headers as they are newer.
|
||||
return entry.getAllHeaders();
|
||||
}
|
||||
|
||||
List<Header> cacheEntryHeaderList = new ArrayList<Header>(Arrays.asList(entry
|
||||
.getAllHeaders()));
|
||||
.getAllHeaders()));
|
||||
removeCacheHeadersThatMatchResponse(cacheEntryHeaderList, response);
|
||||
removeCacheEntry1xxWarnings(cacheEntryHeaderList, entry);
|
||||
cacheEntryHeaderList.addAll(Arrays.asList(response.getAllHeaders()));
|
||||
|
|
|
@ -666,8 +666,8 @@ public class CachingHttpClient implements HttpClient {
|
|||
|
||||
}
|
||||
|
||||
private boolean revalidationResponseIsTooOld(HttpResponse backendResponse,
|
||||
HttpCacheEntry cacheEntry) {
|
||||
private boolean revalidationResponseIsTooOld(HttpResponse backendResponse,
|
||||
HttpCacheEntry cacheEntry) {
|
||||
final Header entryDateHeader = cacheEntry.getFirstHeader("Date");
|
||||
final Header responseDateHeader = backendResponse.getFirstHeader("Date");
|
||||
if (entryDateHeader != null && responseDateHeader != null) {
|
||||
|
@ -682,8 +682,8 @@ public class CachingHttpClient implements HttpClient {
|
|||
// unconditional retry recommended in 13.2.6 of RFC 2616.
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
HttpResponse negotiateResponseFromVariants(HttpHost target,
|
||||
HttpRequest request, HttpContext context,
|
||||
|
@ -716,7 +716,7 @@ public class CachingHttpClient implements HttpClient {
|
|||
HttpCacheEntry matchedEntry = matchingVariant.getEntry();
|
||||
|
||||
if (revalidationResponseIsTooOld(backendResponse, matchedEntry)) {
|
||||
return retryRequestUnconditionally(target, request, context,
|
||||
return retryRequestUnconditionally(target, request, context,
|
||||
matchedEntry);
|
||||
}
|
||||
|
||||
|
@ -740,7 +740,7 @@ public class CachingHttpClient implements HttpClient {
|
|||
HttpRequest request, HttpContext context,
|
||||
HttpCacheEntry matchedEntry) throws IOException {
|
||||
HttpRequest unconditional = conditionalRequestBuilder
|
||||
.buildUnconditionalRequest(request, matchedEntry);
|
||||
.buildUnconditionalRequest(request, matchedEntry);
|
||||
return callBackend(target, unconditional, context);
|
||||
}
|
||||
|
||||
|
@ -779,18 +779,18 @@ public class CachingHttpClient implements HttpClient {
|
|||
HttpContext context,
|
||||
HttpCacheEntry cacheEntry) throws IOException, ProtocolException {
|
||||
|
||||
HttpRequest conditionalRequest = conditionalRequestBuilder.buildConditionalRequest(request, cacheEntry);
|
||||
HttpRequest conditionalRequest = conditionalRequestBuilder.buildConditionalRequest(request, cacheEntry);
|
||||
|
||||
Date requestDate = getCurrentDate();
|
||||
HttpResponse backendResponse = backend.execute(target, conditionalRequest, context);
|
||||
Date responseDate = getCurrentDate();
|
||||
|
||||
if (revalidationResponseIsTooOld(backendResponse, cacheEntry)) {
|
||||
HttpRequest unconditional = conditionalRequestBuilder
|
||||
.buildUnconditionalRequest(request, cacheEntry);
|
||||
requestDate = getCurrentDate();
|
||||
backendResponse = backend.execute(target, unconditional, context);
|
||||
responseDate = getCurrentDate();
|
||||
HttpRequest unconditional = conditionalRequestBuilder
|
||||
.buildUnconditionalRequest(request, cacheEntry);
|
||||
requestDate = getCurrentDate();
|
||||
backendResponse = backend.execute(target, unconditional, context);
|
||||
responseDate = getCurrentDate();
|
||||
}
|
||||
|
||||
backendResponse.addHeader("Via", generateViaHeader(backendResponse));
|
||||
|
@ -822,11 +822,11 @@ public class CachingHttpClient implements HttpClient {
|
|||
backendResponse);
|
||||
}
|
||||
|
||||
private boolean staleIfErrorAppliesTo(int statusCode) {
|
||||
return statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR
|
||||
|| statusCode == HttpStatus.SC_BAD_GATEWAY
|
||||
|| statusCode == HttpStatus.SC_SERVICE_UNAVAILABLE
|
||||
|| statusCode == HttpStatus.SC_GATEWAY_TIMEOUT;
|
||||
private boolean staleIfErrorAppliesTo(int statusCode) {
|
||||
return statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR
|
||||
|| statusCode == HttpStatus.SC_BAD_GATEWAY
|
||||
|| statusCode == HttpStatus.SC_SERVICE_UNAVAILABLE
|
||||
|| statusCode == HttpStatus.SC_GATEWAY_TIMEOUT;
|
||||
}
|
||||
|
||||
HttpResponse handleBackendResponse(
|
||||
|
|
|
@ -31,25 +31,25 @@ import org.apache.http.client.cache.HttpCacheEntry;
|
|||
/** Records a set of information describing a cached variant. */
|
||||
class Variant {
|
||||
|
||||
private final String variantKey;
|
||||
private final String cacheKey;
|
||||
private final HttpCacheEntry entry;
|
||||
private final String variantKey;
|
||||
private final String cacheKey;
|
||||
private final HttpCacheEntry entry;
|
||||
|
||||
public Variant(String variantKey, String cacheKey, HttpCacheEntry entry) {
|
||||
this.variantKey = variantKey;
|
||||
this.cacheKey = cacheKey;
|
||||
this.entry = entry;
|
||||
}
|
||||
public Variant(String variantKey, String cacheKey, HttpCacheEntry entry) {
|
||||
this.variantKey = variantKey;
|
||||
this.cacheKey = cacheKey;
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
public String getVariantKey() {
|
||||
return variantKey;
|
||||
}
|
||||
|
||||
public String getCacheKey() {
|
||||
return cacheKey;
|
||||
}
|
||||
|
||||
public HttpCacheEntry getEntry() {
|
||||
return entry;
|
||||
}
|
||||
public String getVariantKey() {
|
||||
return variantKey;
|
||||
}
|
||||
|
||||
public String getCacheKey() {
|
||||
return cacheKey;
|
||||
}
|
||||
|
||||
public HttpCacheEntry getEntry() {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ class WarningValue {
|
|||
char c = src.charAt(offs);
|
||||
if (offs + 1 < src.length() && c == '\\'
|
||||
&& isChar(src.charAt(offs+1))) {
|
||||
offs += 2; // consume quoted-pair
|
||||
offs += 2; // consume quoted-pair
|
||||
} else if (c == '\"') {
|
||||
foundEnd = true;
|
||||
offs++;
|
||||
|
|
|
@ -5549,7 +5549,7 @@ public class TestProtocolRequirements extends AbstractProtocolTest {
|
|||
|
||||
|
||||
private void assertValidViaHeader(String via) {
|
||||
// Via = "Via" ":" 1#( received-protocol received-by [ comment ] )
|
||||
// Via = "Via" ":" 1#( received-protocol received-by [ comment ] )
|
||||
// received-protocol = [ protocol-name "/" ] protocol-version
|
||||
// protocol-name = token
|
||||
// protocol-version = token
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.junit.Test;
|
|||
*/
|
||||
public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||
|
||||
/*
|
||||
/*
|
||||
* "The stale-if-error Cache-Control extension indicates that when an
|
||||
* error is encountered, a cached stale response MAY be used to satisfy
|
||||
* the request, regardless of other freshness information.When used as a
|
||||
|
@ -62,11 +62,11 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
|||
*/
|
||||
@Test
|
||||
public void testStaleIfErrorInResponseIsTrueReturnsStaleEntryWithWarning()
|
||||
throws Exception{
|
||||
throws Exception{
|
||||
Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
|
||||
HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
|
||||
HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
|
||||
"public, max-age=5, stale-if-error=60");
|
||||
"public, max-age=5, stale-if-error=60");
|
||||
|
||||
backendExpectsAnyRequest().andReturn(resp1);
|
||||
|
||||
|
@ -183,11 +183,11 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
|||
|
||||
@Test
|
||||
public void testStaleIfErrorInRequestIsTrueReturnsStaleEntryWithWarning()
|
||||
throws Exception{
|
||||
throws Exception{
|
||||
Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
|
||||
HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
|
||||
HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
|
||||
"public, max-age=5");
|
||||
"public, max-age=5");
|
||||
|
||||
backendExpectsAnyRequest().andReturn(resp1);
|
||||
|
||||
|
@ -207,12 +207,12 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
|||
|
||||
@Test
|
||||
public void testStaleIfErrorInResponseIsFalseReturnsError()
|
||||
throws Exception{
|
||||
Date now = new Date();
|
||||
throws Exception{
|
||||
Date now = new Date();
|
||||
Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
|
||||
HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
|
||||
HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
|
||||
"public, max-age=5, stale-if-error=2");
|
||||
"public, max-age=5, stale-if-error=2");
|
||||
|
||||
backendExpectsAnyRequest().andReturn(resp1);
|
||||
|
||||
|
@ -232,12 +232,12 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
|||
|
||||
@Test
|
||||
public void testStaleIfErrorInRequestIsFalseReturnsError()
|
||||
throws Exception{
|
||||
Date now = new Date();
|
||||
throws Exception{
|
||||
Date now = new Date();
|
||||
Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
|
||||
HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
|
||||
HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
|
||||
"public, max-age=5");
|
||||
"public, max-age=5");
|
||||
|
||||
backendExpectsAnyRequest().andReturn(resp1);
|
||||
|
||||
|
|
Loading…
Reference in New Issue