diff options
author | Jesse Wilson <jessewilson@google.com> | 2010-12-17 16:41:31 -0800 |
---|---|---|
committer | Jesse Wilson <jessewilson@google.com> | 2010-12-17 16:47:41 -0800 |
commit | 091f7ca4958c6f41c79808913c84ceea56d73b12 (patch) | |
tree | b2ac1bf1db89300636c7d0457464abf95c087037 /src/org/apache/http/impl/AbstractHttpClientConnection.java | |
parent | 3dafdc28e38c2720a85d8581b068e09e709ac434 (diff) | |
download | external_apache-http-091f7ca4958c6f41c79808913c84ceea56d73b12.zip external_apache-http-091f7ca4958c6f41c79808913c84ceea56d73b12.tar.gz external_apache-http-091f7ca4958c6f41c79808913c84ceea56d73b12.tar.bz2 |
Fix Apache HTTP client to recover from half-closed connections.
android.net.http.DefaultHttpClientTest demonstrates a problem where
half-closed connections get pooled, causing subsequent connections
to timeout.
Change-Id: I7275d99f12eafa28bb2336a3dd67546ffecb4dce
http://b/2612240
Diffstat (limited to 'src/org/apache/http/impl/AbstractHttpClientConnection.java')
-rw-r--r-- | src/org/apache/http/impl/AbstractHttpClientConnection.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/org/apache/http/impl/AbstractHttpClientConnection.java b/src/org/apache/http/impl/AbstractHttpClientConnection.java index ebfaabb..ac3f4d1 100644 --- a/src/org/apache/http/impl/AbstractHttpClientConnection.java +++ b/src/org/apache/http/impl/AbstractHttpClientConnection.java @@ -47,6 +47,7 @@ import org.apache.http.impl.entity.LaxContentLengthStrategy; import org.apache.http.impl.entity.StrictContentLengthStrategy; import org.apache.http.impl.io.HttpRequestWriter; import org.apache.http.impl.io.HttpResponseParser; +import org.apache.http.impl.io.SocketInputBuffer; import org.apache.http.io.HttpMessageParser; import org.apache.http.io.HttpMessageWriter; import org.apache.http.io.SessionInputBuffer; @@ -198,6 +199,12 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti return true; } try { + // BEGIN android-added + // don't reuse connections when the socket input stream is exhausted + if (inbuffer instanceof SocketInputBuffer) { + return ((SocketInputBuffer) inbuffer).isStale(); + } + // END android-added this.inbuffer.isDataAvailable(1); return false; } catch (IOException ex) { |