mirror of
https://github.com/square/okhttp.git
synced 2026-01-25 16:01:38 +03:00
Test gzipped HTTP 304 response bodies
This commit is contained in:
@@ -950,6 +950,24 @@ public final class HttpResponseCacheTest {
|
||||
assertEquals("ABCABCABC", readAscii(openConnection(server.getUrl("/"))));
|
||||
}
|
||||
|
||||
@Test public void notModifiedSpecifiesEncoding() throws Exception {
|
||||
server.enqueue(new MockResponse()
|
||||
.setBody(gzip("ABCABCABC".getBytes("UTF-8")))
|
||||
.addHeader("Content-Encoding: gzip")
|
||||
.addHeader("Last-Modified: " + formatDate(-2, TimeUnit.HOURS))
|
||||
.addHeader("Expires: " + formatDate(-1, TimeUnit.HOURS)));
|
||||
server.enqueue(new MockResponse()
|
||||
.setResponseCode(HttpURLConnection.HTTP_NOT_MODIFIED)
|
||||
.addHeader("Content-Encoding: gzip"));
|
||||
server.enqueue(new MockResponse()
|
||||
.setBody("DEFDEFDEF"));
|
||||
|
||||
server.play();
|
||||
assertEquals("ABCABCABC", readAscii(openConnection(server.getUrl("/"))));
|
||||
assertEquals("ABCABCABC", readAscii(openConnection(server.getUrl("/"))));
|
||||
assertEquals("DEFDEFDEF", readAscii(openConnection(server.getUrl("/"))));
|
||||
}
|
||||
|
||||
@Test public void expiresDateBeforeModifiedDate() throws Exception {
|
||||
assertConditionallyCached(
|
||||
new MockResponse().addHeader("Last-Modified: " + formatDate(-1, TimeUnit.HOURS))
|
||||
|
||||
Reference in New Issue
Block a user