[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/22927] URL.openStream doesn't handle 302 and 404 HTTP res
From: |
gcc-bugzilla at gcc dot gnu dot org |
Subject: |
[Bug classpath/22927] URL.openStream doesn't handle 302 and 404 HTTP response codes properly |
Date: |
16 Oct 2005 01:27:41 -0000 |
For HTTP URLs that return response code 302 (Moved Temporarily), URL.openStream
should follow the redirect to the new location. Currently it returns null.
For HTTP URLs that return response code 404 (Not Found), URL.openStream should
raise a FileNotFoundException. Currently it returns a stream with the error
document as if it received the response code 200 (OK).
------- Comment #1 from from-classpath at savannah dot gnu dot org 2005-04-26
12:40 -------
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()?
------- Comment #2 from from-classpath at savannah dot gnu dot org 2005-04-27
08:57 -------
Fixed by the following two changes:
2005-04-27 Chris Burdess <address@hidden>
* java/net/protocol/http/HTTPURLConnection.java (connect): Accept
absolute and relative paths in Location header.
2005-04-26 Chris Burdess <address@hidden>
* gnu/java/net/protocol/http/HTTPURLConnection.java: Throw
FileNotFoundException and implement getErrorStream on 404.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22927
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug classpath/22927] URL.openStream doesn't handle 302 and 404 HTTP response codes properly,
gcc-bugzilla at gcc dot gnu dot org <=