I'm checking this in.

We weren't properly discarding the response body when we saw an http
redirect response.  This was found when debugging the Eclipse
bugzilla plugin, see

    https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=178445

Tom

Index: ChangeLog
from  Tom Tromey  <[EMAIL PROTECTED]>

        * gnu/java/net/protocol/http/HTTPURLConnection.java (connect):
        Read response body for redirect.

Index: gnu/java/net/protocol/http/HTTPURLConnection.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java,v
retrieving revision 1.16
diff -u -r1.16 HTTPURLConnection.java
--- gnu/java/net/protocol/http/HTTPURLConnection.java 20 Jan 2006 20:56:03 
-0000 1.16
+++ gnu/java/net/protocol/http/HTTPURLConnection.java 20 Jan 2006 22:13:50 -0000
@@ -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 @@
         
         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)


_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to