hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Kohlschütter ...@rrzn.uni-hannover.de>
Subject Re: \ in path (instead of /)
Date Mon, 29 Dec 2003 13:43:04 GMT
On Monday 22 December 2003 09:23, Ortwin Glück wrote:
> Sam Berlin wrote:
> > HttpClient (rc2) currently barfs on addresses that look like:
> >
> > http://address:port\path\to\some\file.html
> >
> > It might be worthwhile to allow these slashes to be parsed as if they
> > were /'s.
>
> Why? Sorry, I don't think this sort of "URI" is defined by any URI RFC
> (teach me better). If you need this for your particular application then
> please write a convertor for it. But this is certainly not something
> that will go into HttpClient.
>
> Odi

Sam,

some time ago, I have also had to work with such backslashed http-URLs.
My solution was to extend the URI class (see below).

It was a quick hack only, but may suit your needs.
Feel free to use/modify the code in your program (feedback always 
appreciated).

I agree with Odi that working with backslashes in URIs is unwise and that 
support for this should not be included in the HttpClient core (but probably 
in contrib someday)


Christian

/**
 * A non-standards compliant URI supporting unescaped backslashes ('\')
 * and more unwise things
 *
 * @author  Christian Kohlschuetter
 */
public class UnwiseURI extends URI {

    public UnwiseURI(String uri) throws URIException {
        super(uri, true);
    }
    
    public void setRawPath(char[] escapedPath) throws URIException {
        if (escapedPath == null || escapedPath.length == 0) {
            _opaque = escapedPath;
        }

        escapedPath = removeFragmentIdentifier(escapedPath);
        _path = escapedPath;
        setURI();
    }
    
    public static void main(String[] args) throws Exception {
        System.out.println(new URI("http://www.newsclub.de/foo\\bar", false));
        System.out.println(new UnwiseURI("http://www.newsclub.de/foo\\bar"));
    }    
}

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message