TABS -> SPACES
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1044639 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f1add71205
commit
ef148fc522
|
@ -806,63 +806,63 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
assertNull(captured.getFirstHeader("If-Match"));
|
assertNull(captured.getFirstHeader("If-Match"));
|
||||||
assertNull(captured.getFirstHeader("If-Unmodified-Since"));
|
assertNull(captured.getFirstHeader("If-Unmodified-Since"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "If an entity tag was assigned to a cached representation, the
|
/* "If an entity tag was assigned to a cached representation, the
|
||||||
* forwarded request SHOULD be conditional and include the entity
|
* forwarded request SHOULD be conditional and include the entity
|
||||||
* tags in an If-None-Match header field from all its cache entries
|
* tags in an If-None-Match header field from all its cache entries
|
||||||
* for the resource."
|
* for the resource."
|
||||||
*
|
*
|
||||||
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.6
|
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.6
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSendsAllVariantEtagsInConditionalRequest()
|
public void testSendsAllVariantEtagsInConditionalRequest()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
HttpRequest req1 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
HttpRequest req1 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
||||||
req1.setHeader("User-Agent","agent1");
|
req1.setHeader("User-Agent","agent1");
|
||||||
HttpResponse resp1 = HttpTestUtils.make200Response();
|
HttpResponse resp1 = HttpTestUtils.make200Response();
|
||||||
resp1.setHeader("Cache-Control","max-age=3600");
|
resp1.setHeader("Cache-Control","max-age=3600");
|
||||||
resp1.setHeader("Vary","User-Agent");
|
resp1.setHeader("Vary","User-Agent");
|
||||||
resp1.setHeader("Etag","\"etag1\"");
|
resp1.setHeader("Etag","\"etag1\"");
|
||||||
|
|
||||||
backendExpectsAnyRequest().andReturn(resp1);
|
|
||||||
|
|
||||||
HttpRequest req2 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
backendExpectsAnyRequest().andReturn(resp1);
|
||||||
req2.setHeader("User-Agent","agent2");
|
|
||||||
HttpResponse resp2 = HttpTestUtils.make200Response();
|
|
||||||
resp2.setHeader("Cache-Control","max-age=3600");
|
|
||||||
resp2.setHeader("Vary","User-Agent");
|
|
||||||
resp2.setHeader("Etag","\"etag2\"");
|
|
||||||
|
|
||||||
backendExpectsAnyRequest().andReturn(resp2);
|
HttpRequest req2 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
||||||
|
req2.setHeader("User-Agent","agent2");
|
||||||
Capture<HttpRequest> cap = new Capture<HttpRequest>();
|
HttpResponse resp2 = HttpTestUtils.make200Response();
|
||||||
HttpRequest req3 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
resp2.setHeader("Cache-Control","max-age=3600");
|
||||||
req3.setHeader("User-Agent","agent3");
|
resp2.setHeader("Vary","User-Agent");
|
||||||
HttpResponse resp3 = HttpTestUtils.make200Response();
|
resp2.setHeader("Etag","\"etag2\"");
|
||||||
|
|
||||||
EasyMock.expect(mockBackend.execute(EasyMock.eq(host),
|
backendExpectsAnyRequest().andReturn(resp2);
|
||||||
EasyMock.capture(cap), (HttpContext)EasyMock.isNull()))
|
|
||||||
.andReturn(resp3);
|
Capture<HttpRequest> cap = new Capture<HttpRequest>();
|
||||||
|
HttpRequest req3 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
||||||
replayMocks();
|
req3.setHeader("User-Agent","agent3");
|
||||||
impl.execute(host,req1);
|
HttpResponse resp3 = HttpTestUtils.make200Response();
|
||||||
impl.execute(host,req2);
|
|
||||||
impl.execute(host,req3);
|
EasyMock.expect(mockBackend.execute(EasyMock.eq(host),
|
||||||
verifyMocks();
|
EasyMock.capture(cap), (HttpContext)EasyMock.isNull()))
|
||||||
|
.andReturn(resp3);
|
||||||
HttpRequest captured = cap.getValue();
|
|
||||||
boolean foundEtag1 = false;
|
replayMocks();
|
||||||
boolean foundEtag2 = false;
|
impl.execute(host,req1);
|
||||||
for(Header h : captured.getHeaders("If-None-Match")) {
|
impl.execute(host,req2);
|
||||||
for(String etag : h.getValue().split(",")) {
|
impl.execute(host,req3);
|
||||||
if ("\"etag1\"".equals(etag.trim())) {
|
verifyMocks();
|
||||||
foundEtag1 = true;
|
|
||||||
}
|
HttpRequest captured = cap.getValue();
|
||||||
if ("\"etag2\"".equals(etag.trim())) {
|
boolean foundEtag1 = false;
|
||||||
foundEtag2 = true;
|
boolean foundEtag2 = false;
|
||||||
}
|
for(Header h : captured.getHeaders("If-None-Match")) {
|
||||||
}
|
for(String etag : h.getValue().split(",")) {
|
||||||
}
|
if ("\"etag1\"".equals(etag.trim())) {
|
||||||
assertTrue(foundEtag1 && foundEtag2);
|
foundEtag1 = true;
|
||||||
|
}
|
||||||
|
if ("\"etag2\"".equals(etag.trim())) {
|
||||||
|
foundEtag2 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(foundEtag1 && foundEtag2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue