Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [orion-dev] Usage of Slug Header, Name Attribute in the Body and URL encoding

Hi Timur

1) The "Slug" header must contain a %-encoded value (the encoding algorithm is given by the Atom spec, here). The server decodes the Slug to obtain the filename on disk. So the following Slug:

Slug: http%3A%2F%2Fwww.example.org%2Fwinery%2FTEST%2Fjclouds2221

…will produce a file on disk named "http://www.example.org/winery/TEST/jclouds2221", which is not a legal filename on most OS's (hence the 400 error).

2) The "Name" field is different -- since it's within the request body, it does not have to be encoded -- any valid JSON character can be used. Therefore this Name:

{  "Name": "http%3A%2F%2Fwww.example.org%2Fwinery%2FTEST%2Fjclouds2221"  }

…produces a file named "http%3A%2F%2Fwww.example.org%2Fwinery%2FTEST%2Fjclouds2221".

Both (1) and (2) are expected behavior.

Prior to Orion 4.0, the server handled case (1) incorrectly: the Slug was used as-is. This meant that the Slug could not be used to create files containing special characters. To complicate matters, pre-4.0 servers prioritized Name over Slug if both were provided. This was fixed in 4.0.

So to summarize, in Orion 4.0:
  • If you choose to provide a Slug, it must be encoded.
  • If both a Slug and a Name are provided, the Slug takes priority.
  • To minimize encoding headaches, you can just provide a Name in the request body and omit the Slug.
Mark


On Thu, Nov 14, 2013 at 12:21 PM, Timur Sungur <timurhan.s@xxxxxxxxx> wrote:
Hi everyone,

The result of using slug header and name attribute is different during file creation. Is it the expected behavior? 

Whenever I want to create a file under project test using slug header:

-------------------------cut--------------------------
Orion-Version: 1.0
Slug: http%3A%2F%2Fwww.example.org%2Fwinery%2FTEST%2Fjclouds2221
Content-Type: text/xml
{
"Directory":"false"
}

 -- response --
400 Bad Request
Content-Type:  application/json; charset=UTF-8

Content-Length:  118

Server:  Jetty(8.1.10.v20130312)

{"Severity":"Error","Message":"Bad file name: http://www.example.org/winery/TEST/jclouds2221","HttpCode":400,"Code":0}
-------------------------end--------------------------

In contrast, it works fine with the name attribute:

-------------------------cut--------------------------
Orion-Version: 1.0
Content-Type: text/xml
{
"Directory":"false",
"Name":"http%3A%2F%2Fwww.example.org%2Fwinery%2FTEST%2Fjclouds2221"
}

 -- response --
201 Created
Cache-Control:  no-store

Content-Type:  application/json; charset=UTF-8

Location:  /file/timur/test/http%253A%252F%252Fwww.example.org%252Fwinery%252FTEST%252Fjclouds2221

Content-Length:  630

Server:  Jetty(8.1.10.v20130312)

{
  "Attributes": {
    "Executable": false,
    "ReadOnly": false,
    "SymLink": false
  },
  "Directory": false,
  "ImportLocation": "/xfer/import/timur/test/http%253A%252F%252Fwww.example.org%252Fwinery%252FTEST%252Fjclouds2221",
  "Length": 0,
  "LocalTimeStamp": 1384448839000,
  "Location": "/file/timur/test/http%253A%252F%252Fwww.example.org%252Fwinery%252FTEST%252Fjclouds2221",
  "Name": "http%3A%2F%2Fwww.example.org%2Fwinery%2FTEST%2Fjclouds2221",
  "Parents": [{
    "ChildrenLocation": "/file/timur/test/?depth=1",
    "Location": "/file/timur/test/",
    "Name": "test"
  }],
  "SearchLocation": "/filesearch?q="
}

-------------------------end--------------------------

The above case occurs only if the url encoding has been applied once. In case of multiple URL encodings the result is: 

-------------------------cut--------------------------

Orion-Version: 1.0
Slug: http%25253A%25252F%25252Fwww.example.org%25252Fwinery%25252FTEST%25252Fjclouds2221
Content-Type: text/xml
{
"Directory":"false"
}

 -- response --
201 Created
Cache-Control:  no-store

Content-Type:  application/json; charset=UTF-8

Location:  /file/timur/test/http%25253A%25252F%25252Fwww.example.org%25252Fwinery%25252FTEST%25252Fjclouds2221

Content-Length:  666

Server:  Jetty(8.1.10.v20130312)

{
  "Attributes": {
    "Executable": false,
    "ReadOnly": false,
    "SymLink": false
  },
  "Directory": false,
  "ImportLocation": "/xfer/import/timur/test/http%25253A%25252F%25252Fwww.example.org%25252Fwinery%25252FTEST%25252Fjclouds2221",
  "Length": 0,
  "LocalTimeStamp": 1384449060000,
  "Location": "/file/timur/test/http%25253A%25252F%25252Fwww.example.org%25252Fwinery%25252FTEST%25252Fjclouds2221",
  "Name": "http%253A%252F%252Fwww.example.org%252Fwinery%252FTEST%252Fjclouds2221",
  "Parents": [{
    "ChildrenLocation": "/file/timur/test/?depth=1",
    "Location": "/file/timur/test/",
    "Name": "test"
  }],
  "SearchLocation": "/filesearch?q="
}
-------------------------end--------------------------


In this request, the location is not encoded one more time unlike the behavior mentioned here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=416118

Is it a bug or the expected behavior of Orion? In the previous version, there was no such behavior.

Regards,

Timur
  

_______________________________________________
orion-dev mailing list
orion-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/orion-dev



Back to the top