What is the right way to create objects with non "URL-friendly" characters,
such as spaces, using the namespace interface and the REST API?
For example, if I want to create a file named "/dir/file with spaces", I found that:
- doing a "POST /rest/namespace/dir/file with spaces" doesn't work;
- doing a "POST /rest/namespace/dir/file%20with%20spaces" and using "/rest/namespace/dir/file%20with%20spaces" as the canonicalized resource for authentication returns a signature mismatch error;
- doing a "POST /rest/namespace/dir/file%20with%20spaces" and using "/rest/namespace/dir/file with spaces" as the canonicalized resource for authentication (the URL is encoded, but not for authentication), the call succeeds, but the file is created as "file%20with%20spaces", and not as "file with spaces", as I believe it should.
Try using a plus sign (+) where a space is otherwise required in the request header. Illegal characters such as the percent symbol or a question mark will cause signature mismatch errors.
I'll give it a try, but what about other possible problematic characters, such as '&'?
When calculating the signature for the authentication, I can even use normal spaces (' ') instead of its encoded value ("%20"), so my guess is that two things in Atmos would have to be changed to permanently address this issue:
- the code for the namespace interface would have to decode the URL, taking care of characters encoded with %XX;
- it would be nice if the signature verification code accepted the same set of characters as the real request URL, so callers could use the same string for both, and not having to worry about keeping an encoded and an unencoded version.
I tried with '+' instead of ' ', and it really doesn't do the right thing. Just like the case where I used '%20' in the request URL and ' ' in the url used when calculating the signature, the operation succeeds, but the object is created with the wrong name - in this case, it was created as "/test+dir", and not "/test dir".
LeoLeung
1 Rookie
•
49 Posts
471
0
Posted July 20th, 2009 14:00
Good catch, Luis. Can you file this in the feedback section of the portal please? Many thanks. - Leo