[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] Re: HTTPURLConnection redirects to absolute paths
From: |
Mark Wielaard |
Subject: |
Re: [cp-patches] Re: HTTPURLConnection redirects to absolute paths |
Date: |
Wed, 27 Apr 2005 10:55:48 +0200 |
Hi Chris,
On Wed, 2005-04-27 at 07:40 +0100, Chris Burdess wrote:
> Mark Wielaard wrote:
> > Could you commit both your patches?
> > Or I can do it. I would like to get this in before the next snapshot
> > release tomorrow because it breaks -link support for some people in the
> > new gjdoc.
>
> I committed the last one last night. I won't have any time today until
> this evening so if you could do the first one that would be appreciated
OK. Committed as follows.
2005-04-27 Chris Burdess <address@hidden>
* java/net/protocol/http/HTTPURLConnection.java (connect): Accept
absolute and relative paths in Location header.
Thanks,
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.7
diff -u -r1.7 HTTPURLConnection.java
--- gnu/java/net/protocol/http/HTTPURLConnection.java 26 Apr 2005 19:00:28
-0000 1.7
+++ gnu/java/net/protocol/http/HTTPURLConnection.java 27 Apr 2005 08:51:53
-0000
@@ -283,7 +283,23 @@
file = location.substring(end);
retry = true;
}
- // Otherwise this is not an HTTP redirect, can't follow
+ else if (location.length() > 0)
+ {
+ // Malformed absolute URI, treat as file part of URI
+ if (location.charAt(0) == '/')
+ {
+ // Absolute path
+ file = location;
+ }
+ else
+ {
+ // Relative path
+ int lsi = file.lastIndexOf('/');
+ file = (lsi == -1) ? "/" : file.substring(0, lsi + 1);
+ file += location;
+ }
+ retry = true;
+ }
}
else
{
signature.asc
Description: This is a digitally signed message part