[Opensim-dev] Uris: Errors/Inconsistencies/TBD

Alan M Webb alan_webb at us.ibm.com
Wed Sep 10 12:07:47 UTC 2008


Hi Stefan

The .NET behavior is bemusing. Running mono on Linux, the behavior is NOT 
the same - which may be cause for even bigger concern. On Linux, given:

Uri absURI = new Uri("http://localhost:9000/abc");
Uri relURI = new Uri("abc", UriKind.Relative);
Uri simURI = new Uri("http://localhost:9000/abc);

then Console.WriteLine(xxxURI) and Console.WriteLine(xxxURI.ToString()) 
both produce exactly what went into the constuctor. If I change the 
initial string to have a trailing slash, only then do I see a trailing 
slash on output. On the face of it I agree with your assertion that using 
the existing behavior of Uri should be preferred, and yet if our goal is 
to obtain consistent behaviour for OpenSim on multiple platforms, the 
tests above would suggest that Uri is not going to do that for us, and 
that the RestClient code, in doing things explicitly, is more likely to 
succeed. It would be nice to get the same behavior from mono and .net, but 
that's probably much harder to achieve.

I probably take issue with your criticism of the RestClient's (who wrote 
this code - they should be defending this!) removal of a single trailing 
slash. A single trailing slash is an accepted, if not entirely proper, 
redundancy. Two trailing slashes would be an invalid URI in my opinion and 
should always be rejected. As an externally supplied value we can not 
adopt a pre-condition stance as to its validity, so testing and rejection 
should be preferred I think. In the subsequent code that you used in your 
example, given the preceding, then this IS based upon a slashless URL 
representation.

If I were writing the RestClient I think I would prefer to see the 
decomposition of the URI into its component pieces, and reconstruction 
from that abstract form immediately prior to use.

So my vote would be for a single class in OpenSim that provides a 
guaranteed URI behaviour for everybody who deals in this area. No URI 
would be admitted into OpenSim except via this class, and none generated 
from any other source. All modifications to the URI would also be made 
using the class.

By the way, just so the original issue doesn't get lost, our objective 
here is for OpenSim to have an HTTP interface (REST, XMLRPC, whatever) 
that does not behave differently when a supplied URI has, or does not 
have, a trailing "/", right?

Best regards
Alan
-------------------
T.J. Watson Research Center, Hawthorne, NY
1-914-784-7286
alan_webb at us.ibm.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-dev/attachments/20080910/c5c329e5/attachment-0001.html>


More information about the Opensim-dev mailing list