You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Oleg Kalnichevski <o....@dplanet.ch> on 2003/01/25 18:25:24 UTC

Question about parsing of ambiguous URIs

Sung-Gu

Please have a look at the following code snippet:

URI uri = new URI( "/yadayada/blabla" );
uri.getHost()); // produces null. 
uri.getPath()); // produces '/yadayada/blabla'. 

Everything is cool. However the following behavior appears a bit
illogical to me:

URI uri = new URI( "yadayada/blabla" );
uri.getHost()); // produces null. Should not it be 'yadayada'?
uri.getPath()); // produces 'host/path'. Should not it be '/blabla'?

I believe if uri is incomplete (no explicit protocol specified) and it
does not begin with / per default URI class constructor should assume
URI to begin with a host name followed by path, rather then a path with
host being null.

Is there a reason for current behavior of the URI class constructor?

Thanks

Oleg


Re: Question about parsing of ambiguous URIs

Posted by Oleg Kalnichevski <o....@dplanet.ch>.
Thanks for clarifications, Mike
Cheers
Oleg


On Sun, 2003-01-26 at 07:15, Michael Becke wrote:
> I believe this behavior is correct.  The "yadayada/blabla" URI is a 
> relative path, like "../index.html".  I think what you're looking for 
> is called a net path.  Net paths are required to begin with "//" (e.g. 
> "//yadayada/blabla" ).  The BNF for this part is:
> 
>        net_path      = "//" authority [ abs_path ]
>        abs_path      = "/"  path_segments
>        rel_path      = rel_segment [ abs_path ]
> 
> Mike
> 
> 
> On Saturday, January 25, 2003, at 12:25 PM, Oleg Kalnichevski wrote:
> 
> > Sung-Gu
> >
> > Please have a look at the following code snippet:
> >
> > URI uri = new URI( "/yadayada/blabla" );
> > uri.getHost()); // produces null.
> > uri.getPath()); // produces '/yadayada/blabla'.
> >
> > Everything is cool. However the following behavior appears a bit
> > illogical to me:
> >
> > URI uri = new URI( "yadayada/blabla" );
> > uri.getHost()); // produces null. Should not it be 'yadayada'?
> > uri.getPath()); // produces 'host/path'. Should not it be '/blabla'?
> >
> > I believe if uri is incomplete (no explicit protocol specified) and it
> > does not begin with / per default URI class constructor should assume
> > URI to begin with a host name followed by path, rather then a path with
> > host being null.
> >
> > Is there a reason for current behavior of the URI class constructor?
> >
> > Thanks
> >
> > Oleg
> >
> >
> > --
> > To unsubscribe, e-mail:   
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail: 
> > <ma...@jakarta.apache.org>
> >
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
-- 
Oleg Kalnichevski <o....@dplanet.ch>


Re: Question about parsing of ambiguous URIs

Posted by Michael Becke <be...@u.washington.edu>.
I believe this behavior is correct.  The "yadayada/blabla" URI is a 
relative path, like "../index.html".  I think what you're looking for 
is called a net path.  Net paths are required to begin with "//" (e.g. 
"//yadayada/blabla" ).  The BNF for this part is:

       net_path      = "//" authority [ abs_path ]
       abs_path      = "/"  path_segments
       rel_path      = rel_segment [ abs_path ]

Mike


On Saturday, January 25, 2003, at 12:25 PM, Oleg Kalnichevski wrote:

> Sung-Gu
>
> Please have a look at the following code snippet:
>
> URI uri = new URI( "/yadayada/blabla" );
> uri.getHost()); // produces null.
> uri.getPath()); // produces '/yadayada/blabla'.
>
> Everything is cool. However the following behavior appears a bit
> illogical to me:
>
> URI uri = new URI( "yadayada/blabla" );
> uri.getHost()); // produces null. Should not it be 'yadayada'?
> uri.getPath()); // produces 'host/path'. Should not it be '/blabla'?
>
> I believe if uri is incomplete (no explicit protocol specified) and it
> does not begin with / per default URI class constructor should assume
> URI to begin with a host name followed by path, rather then a path with
> host being null.
>
> Is there a reason for current behavior of the URI class constructor?
>
> Thanks
>
> Oleg
>
>
> --
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>