commit-classpath
[Top][All Lists]
Advanced

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

[commit-cp] [bug #12815] URL.openStream doesn't handle 302 and 404 HTTP


From: Mark Wielaard
Subject: [commit-cp] [bug #12815] URL.openStream doesn't handle 302 and 404 HTTP response codes properly
Date: Tue, 26 Apr 2005 12:40:33 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050324 Galeon/1.3.20 (Debian package 1.3.20-1)

Follow-up Comment #1, bug #12815 (project classpath):

The 30x redirect issue was explained a bit more on irc.
What happens is that some servers just sent a absolutePath as Location:
header while the spec says (and our code expects) a full absoluteUri.
Proposed patch to be liberal in what we accept:

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:34:05
-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();


The 40x transformation to FileNotFoundException looks strange to me. We do
properly return the 404 when you ask for getResponseCode(). Then we do indeed
return as InputStream the page that the server sends us.

Maybe the behavior should different between uc.openConnection() and
uc.openStream()?

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=12815>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

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