classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] HTTPURLConnection redirects to absolute paths


From: Mark Wielaard
Subject: [cp-patches] HTTPURLConnection redirects to absolute paths
Date: Tue, 26 Apr 2005 14:58:55 +0200

Hi,

As explained in [bug #12815] URL.openStream doesn't handle 302 and 404
HTTP response codes properly:
(http://savannah.gnu.org/bugs/?func=detailitem&item_id=12815)
For 30x redirects we expect (as the spec says) an absoluteUri as
Location header. Some servers sent just an absolute path
(Sun-ONE-Web-Server/6.1 for example) not a fill URI. Since our old code
accepted this I think we should be liberal in what we accept.

2005-04-26  Mark Wielaard  <address@hidden>

        * java/net/protocol/http/HTTPURLConnection.java (connect): Accept
        locations starting with '/' for CodeClass 3.

Chris, you wrote this code originally following the spec precisely. Do
you think this is a good patch/idea?

I haven't yet looked into the second part of that bug report (throwing
FileNotFoundException on 404 handling).

Cheers,

Mark
Index: gnu/java/net/protocol/http/HTTPURLConnection.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java,v
retrieving revision 1.6
diff -u -r1.6 HTTPURLConnection.java
--- gnu/java/net/protocol/http/HTTPURLConnection.java   2 Mar 2005 17:29:09 
-0000       1.6
+++ gnu/java/net/protocol/http/HTTPURLConnection.java   26 Apr 2005 12:55:13 
-0000
@@ -239,6 +239,13 @@
                 file = location.substring(start);
                 retry = true;
               }
+           if (location.charAt(0) == '/')
+             {
+               // Location URLs should be full absoluteURIs,
+               // but in practise some servers send just an absolute path.
+               file = location;
+               retry = true;
+             }
             else if (location.startsWith("http:"))
               {
                 connection.close();

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]