hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Becke <be...@u.washington.edu>
Subject Re: Bug in URI constructor?
Date Mon, 13 Jan 2003 14:59:17 GMT
Not sure this is a bug.  The relative URI you are using is not relative.

Mike

Armando Antón wrote:
> I think there is a bug in this uri constructor:
> 
> public URI(URI base, URI relative) throws URIException
> 
> the problem consist on the resolverPath method called when the relative URI is really
relative or when the base scheme and the relative scheme are equals.
> In that case, the method is invoked and the new path is resolved. I think that this resolved
method must be only invoked if the relative uri has not got an authority (like in the examples
in RFC2396) because of how the resolved method works (if the relative path is null then the
base path is used and the new uri is composed of the relative authority and the base path!)
> 
> You can test it with this example:
> 
> import org.apache.commons.httpclient.URI;
> 
> public class TestBugConstruccionURISRelativas {
> 
>     public static void main(String[] args) throws Exception {
>         String _base = "http://host:8080/dir/dir2/dir3/doc.html?a=b";
>         URI base = new URI(_base);
>         String _relative = "http://newHost";
>         URI relative = new URI(_relative);
>         URI newURI = new URI(base, relative);
>         System.out.println("Base: " + base.toString());
>         System.out.println("Relative: " + relative.toString());
>         System.out.println("New URI: " + newURI.toString());());
>     }
> 
> }
> 
> The results are:
> 
> Base: http://host:8080/dir/dir2/dir3/doc.html?a=b
> Relative: http://newHost
> New URI: http://newHost/dir/dir2/dir3/
> 
> and the correct new URI should be: http://newHost (this problem does not occur if the
relative URI has got a final '/' char)
> 
> any suggestions?? or this check must be changed?
> 
> URI lines 498-501
> 
>         if (relative._scheme == null && relative._authority == null || 
>                 equals(base._scheme, relative._scheme)) {
>             this._path = resolvePath(base._path, relative._path);
>         }
> 
> i have changed it to:
> 
>         if (relative._scheme == null && relative._authority == null) {
>             this._path = resolvePath(base._path, relative._path);
>         }
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-httpclient-dev-help@jakarta.apache.org>
> 


Mime
View raw message