You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Sam Berlin <sb...@limepeer.com> on 2003/12/21 03:19:10 UTC

\ in path (instead of /)

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.

(Note that I have purposely not used the words forward or backward slash
because I have never been able to figure out which is which.)

Thanks,
 Sam


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


Re: \ in path (instead of /)

Posted by Christian Kohlschütter <ck...@rrzn.uni-hannover.de>.
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


Re: \ in path (instead of /)

Posted by Ortwin Glück <or...@nose.ch>.
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


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


Re: \ in path (instead of /)

Posted by Sven Köhler <sk...@upb.de>.
> such URLs are totally invalid in my eyes. it's nice that some browsers 
> accept them, but i wouldn't care if HttpClient doesn't. Additional it's 
> farely easy to replace them by yourself.

for example IE accepts them (who wonders: \ is windows-style) but 
Mozilla doesn't. Try entering
   http://www.google.com/test\test
and Mozilla will transform it to
   http://www.google.com/test%5Ctest
for you, which means that Mozilla doesn't accept them.


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


Re: \ in path (instead of /)

Posted by Sven Köhler <sk...@upb.de>.
> http://address:port\path\to\some\file.html
> 
> It might be worthwhile to allow these slashes to be parsed as if they were
> /'s.

such URLs are totally invalid in my eyes. it's nice that some browsers 
accept them, but i wouldn't care if HttpClient doesn't. Additional it's 
farely easy to replace them by yourself.


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