<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Alan,<BR>
 <BR>
insensititvity is in deed best and often the goal.<BR>
 <BR>
Although, sometimes things are best explicit and sometimes best implicit. Knowing when and how is often a black art; a combination of ignorance, wishes, knowledge, experience and preference.<BR>
 <BR>
Uri, at least on .net, in deed adds a trailing slash:<BR>
 <BR><FONT size=2>
</FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Yields http://www.sunet.se/ <BR></FONT></FONT><FONT size=2>
</FONT><FONT face="" color=#2b91af size=2><FONT color=#2b91af size=2>Console</FONT></FONT><FONT face="" size=2>.WriteLine(</FONT><FONT face="" color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT face="" size=2> </FONT><FONT face="" color=#2b91af size=2><FONT color=#2b91af size=2>Uri</FONT></FONT><FONT face="" size=2>(</FONT><FONT face="" color=#a31515 size=2><FONT color=#a31515 size=2>"http://www.sunet.se"</FONT></FONT><FONT face="" size=2>).ToString());<BR>
</FONT> <BR>
So, the easy fix would be to let the RestClient strip any trailing slashes from the supplied base url.<BR>
 <BR>
When lloking thru the RestClient, I noticed some other things:<BR>
 <BR>
The rest client takes the url (set form the ini) - RestClient rc = new RestClient(_assetServerUrl);<BR>
 <BR>
 The AddResourcePath only trims one slash from the end<BR>
 <BR>
 _pathElements.Add(element.Substring(0, element.Length - 1));<BR>
 <BR>
 which is a presumption; maybe better to use TrimStart() and TrimEnd() - or even better to just throw an exception saying "you shouldn't supply slashes, we take care of that"<BR>
 <BR>
In the RestClient, we build the uri ourselves (with query and fragments) from scratch, why not just depend on the UriBuilder where it provides what we need?<BR>
 <BR>
 When we build the request,  private Uri buildUri()<BR>
 does<BR>
 foreach (string e in _pathElements)<BR>
 {<BR>
 sb.Append("/");<BR>
 sb.Append(e);<BR>
 }<BR>
 which presumes the root url to be slash-less<BR>
 <BR>
As said above, the easyfix(tm) would be to let the rest client trim off trailing slashes from the incoming root url.<BR>
 <BR>
 Then again, the best approach would be to peruse Uri and UriBuilder internally, <BR>
and only supply the functionality that isn't already there.<BR><BR>
on the issue of trilaing slashes, I do know that there is no 'right' answer, and that it's been subject to holy wars, but the trailing slash has the good benefit that the node itself definies explicitly whether it's referencing a file or a directory. (as opposed to the prefix notation which actually defines the node _before_ it to be a hierarchy node)<BR>
 <BR>
leaving this to the web server to figure out can lead to ambiguities and errors, especially when doing REST (ie, is that guid referencing a node or a leaf?) or writing parsing url rewriters.<BR>
 <BR>
so, in general, the trailing slash approach leads to less screw-up potential.<BR>
<BR>Best regards,<BR>Stefan Andersson<BR>Tribal Media AB<BR> <BR>Join the 3d web revolution : <A href="http://tribalnet.se/" target=_blank>http://tribalnet.se/</A><BR> <BR><BR><BR><BR>

<HR id=EC_stopSpelling>
<BR>
To: opensim-dev@lists.berlios.de<BR>From: alan_webb@us.ibm.com<BR>Date: Tue, 9 Sep 2008 08:51:55 -0400<BR>Subject: Re: [Opensim-dev] Uris: Errors/Inconsistencies/TBD<BR><BR><BR><FONT face=sans-serif size=2>Stefan</FONT> <BR><BR><FONT face=sans-serif size=2>Consistency would be nice, but I think insensitivity would be better.</FONT> <BR><BR><FONT face=sans-serif size=2>Can you give some specific examples, I trawled through the code but couldn't be sure i was finding the code you have issue with.</FONT> <BR><BR><FONT face=sans-serif size=2>In the REST code in ApplicationPlugins/Rest all inbound URL's are canonicalized to eliminate any issues WRT trailing "/".</FONT> <BR><BR><FONT face=sans-serif size=2>BTW as far as I can tell, The Uri class' ToString echoes whatever you provide. If you don't supply a trailing slash when the URI is</FONT> <BR><FONT face=sans-serif size=2>created, then ToString does not generate one.</FONT> <BR><BR><FONT face=sans-serif size=2>The ABNF in RFC 3986 (URI Generic Syntax) always shows "/" as a prefixing notion - conversely, many of their textual examples indicate that a trailing "/" is perfectly valid. I think this is an area where human interaction will always produce either, and REST is certanly not limited to machine-to-machine communications, so I do think we need to code this is in a way that says it doesn't matter.</FONT> <BR><FONT face=sans-serif size=2><BR>Best regards<BR>Alan<BR>-------------------<BR>T.J. Watson Research Center, Hawthorne, NY<BR>1-914-784-7286<BR>alan_webb@us.ibm.com</FONT> <BR><BR><BR><BR>
<TABLE width="100%">
<TBODY>
<TR vAlign=top>
<TD width="40%"><FONT face=sans-serif size=1><B>Stefan Andersson <stefan@tribalmedia.se></B> </FONT><BR><FONT face=sans-serif size=1>Sent by: opensim-dev-bounces@lists.berlios.de</FONT> 
<FONT face=sans-serif size=1>09/09/2008 04:20 AM</FONT> 
<TABLE border=1>
<TBODY>
<TR vAlign=top>
<TD bgColor=white>
<DIV align=center><FONT face=sans-serif size=1>Please respond to<BR>opensim-dev@lists.berlios.de</FONT></DIV></TD></TR></TBODY></TABLE><BR><BR>
<TD width="59%">
<TABLE width="100%">
<TBODY>
<TR vAlign=top>
<TD>
<DIV align=right><FONT face=sans-serif size=1>To</FONT></DIV>
<TD><FONT face=sans-serif size=1><opensim-dev@lists.berlios.de></FONT> 
<TR vAlign=top>
<TD>
<DIV align=right><FONT face=sans-serif size=1>cc</FONT></DIV>
<TD>
<TR vAlign=top>
<TD>
<DIV align=right><FONT face=sans-serif size=1>Subject</FONT></DIV>
<TD><FONT face=sans-serif size=1>[Opensim-dev] Uris: Errors/Inconsistencies/TBD</FONT></TD></TR></TBODY></TABLE><BR>
<TABLE>
<TBODY>
<TR vAlign=top>
<TD>
<TD></TD></TR></TBODY></TABLE><BR></TD></TR></TBODY></TABLE><BR><BR><BR><FONT face=Tahoma size=2>Just a quick one,<BR><BR>I don't have time to fix this up, and I guess we should discuss it first;<BR><BR>the issue is that parts of the code presumes url segments _ends_ with '/' and others they _begin_ with '/'<BR><BR>this leads to heavy confusion and easily done mistakes<BR><BR>now, the Uri class (which, together with UriBuilder, is poorly underused) ToString _appends_ an '/'<BR><BR>which I consider the proper behaviour: all segments appends an '/' to show they represent a hierarchy node.<BR><BR>I've already made the inventoryUrl wrapping an Uri to safeguard against missing trailing '/' in the ini, which is/was one of our most common mistakes, it seems. (and a bloody easy one at that)<BR><BR>Now, for example, the REST code, presumes the opposite<BR><BR>which means we can't combine the output of a Uri with the output from the RestClient.<BR><BR>So I can't wrap the asset url the same way.<BR><BR>Which sucks.<BR><BR>Either way, I suggest we use postfix notation in accordance with Uri class standard, but most of all I would want us to harmonize on one or the other.<BR><BR>Discussions?<BR><BR>/Stefan<BR></FONT><TT><FONT size=2>_______________________________________________<BR>Opensim-dev mailing list<BR>Opensim-dev@lists.berlios.de<BR>https://lists.berlios.de/mailman/listinfo/opensim-dev<BR></FONT></TT><BR></body>
</html>