This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[4.1] Patch: FYI: fix another http protocol buglet


I'm checking this in on the 4.1 branch.

This fixes another http protocol bug that I found by chance while
fixing the last one.  Thanks to Chris Burdess for the patch.

Tom

Index: ChangeLog
from  Chris Burdess  <dog@gnu.org>

	* gnu/java/net/protocol/http/HTTPURLConnection.java: Don't follow
	redirects on 304.

Index: gnu/java/net/protocol/http/HTTPURLConnection.java
===================================================================
--- gnu/java/net/protocol/http/HTTPURLConnection.java	(revision 110042)
+++ gnu/java/net/protocol/http/HTTPURLConnection.java	(working copy)
@@ -254,7 +254,7 @@
               }
           }
         
-        if (response.getCodeClass() == 3 && getInstanceFollowRedirects())
+        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
@@ -360,6 +360,12 @@
     connected = true;
   }
 
+  private static boolean isRedirect(Response response)
+  {
+    int sc = response.getCode();
+    return (sc != 304 && (sc / 100) == 3);
+  }
+
   /**
    * Returns a connection, from the pool if necessary.
    */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]