1
0
mirror of https://github.com/square/okhttp.git synced 2026-01-24 04:02:07 +03:00

Merge pull request #398 from lingmingyb/timeout_issue

timeout issue
This commit is contained in:
Adrian Cole
2014-01-04 18:34:21 -08:00

View File

@@ -116,9 +116,23 @@ public final class SpdyStream {
* have not been received yet.
*/
public synchronized List<String> getResponseHeaders() throws IOException {
long remaining = 0;
long start = 0;
if (readTimeoutMillis != 0) {
start = (System.nanoTime() / 1000000);
remaining = readTimeoutMillis;
}
try {
while (responseHeaders == null && errorCode == null) {
wait();
if (readTimeoutMillis == 0) { // No timeout configured.
wait();
} else if (remaining > 0) {
wait(remaining);
remaining = start + readTimeoutMillis - (System.nanoTime() / 1000000);
} else {
throw new SocketTimeoutException("Read response header timeout. readTimeoutMillis: "
+ readTimeoutMillis);
}
}
if (responseHeaders != null) {
return responseHeaders;