diff options
| author | Tom Tromey <tromey@redhat.com> | 2006-01-20 22:15:58 +0000 |
|---|---|---|
| committer | Tom Tromey <tromey@redhat.com> | 2006-01-20 22:15:58 +0000 |
| commit | 235023686df7c4ea82e391815b08b2ba621b635d (patch) | |
| tree | 4087cdceb964842c0f56c7f7517b82c65ec07501 /gnu/java/net/protocol | |
| parent | ff6fa66b998ec2a1ed8dcc4a6b50f45246ce3f37 (diff) | |
| download | classpath-235023686df7c4ea82e391815b08b2ba621b635d.tar.gz | |
* gnu/java/net/protocol/http/HTTPURLConnection.java (connect):
Read response body for redirect.
Diffstat (limited to 'gnu/java/net/protocol')
| -rw-r--r-- | gnu/java/net/protocol/http/HTTPURLConnection.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gnu/java/net/protocol/http/HTTPURLConnection.java b/gnu/java/net/protocol/http/HTTPURLConnection.java index f33e70da3..b6d7f6895 100644 --- a/gnu/java/net/protocol/http/HTTPURLConnection.java +++ b/gnu/java/net/protocol/http/HTTPURLConnection.java @@ -1,5 +1,5 @@ /* HTTPURLConnection.java -- - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -256,6 +256,22 @@ public class HTTPURLConnection if (isRedirect(response) && getInstanceFollowRedirects()) { + // Read the response body, if there is one. If the + // redirect points us back at the same server, we will use + // the cached connection, so we must make sure there is no + // pending data in it. + InputStream body = response.getBody(); + if (body != null) + { + byte[] ignore = new byte[1024]; + while (true) + { + int n = body.read(ignore, 0, ignore.length); + if (n == -1) + break; + } + } + // Follow redirect String location = response.getHeader("Location"); if (location != null) |
