1
0
mirror of https://github.com/square/okhttp.git synced 2026-01-18 20:40:58 +03:00

Merge pull request #4472 from amirlivneh/calltimeout-redirect-test

Test call timeout after following redirect on a new connection
This commit is contained in:
Jesse Wilson
2018-12-28 09:34:00 -05:00
committed by GitHub

View File

@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicReference;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okio.BufferedSink;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -256,6 +257,31 @@ public final class WholeOperationTimeoutTest {
}
}
@Ignore(
"timeout.exit() is called when the first connection is released but timeout.enter() is not called again")
@Test
public void timeoutFollowingRedirectOnNewConnection() throws Exception {
MockWebServer otherServer = new MockWebServer();
server.enqueue(
new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_MOVED_TEMP)
.setHeader("Location", otherServer.url("/")));
otherServer.enqueue(new MockResponse().setHeadersDelay(500, TimeUnit.MILLISECONDS));
Request request = new Request.Builder().url(server.url("/")).build();
Call call = client.newCall(request);
call.timeout().timeout(250, TimeUnit.MILLISECONDS);
try {
Response response = call.execute();
fail();
} catch (IOException e) {
assertTrue(call.isCanceled());
}
}
@Test public void noTimeout() throws Exception {
server.enqueue(new MockResponse()
.setHeadersDelay(250, TimeUnit.MILLISECONDS)