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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]