On 17/02/16 22:39, Niels Charlier wrote:
> On 16-02-16 21:14, Ben Caradoc-Davies wrote:
>> The encoding of the child href is very thin (only ampersand is
>> replaced). Encoding " to " might give a better error message. And
>> what about percent-encoding? What happens to spaces or # or other
>> characters in resource names?
> You have a point. What I am doing here is escaping the GET argument
> ampersands for HTML. But we should really convert the resource name (for
> all three formats) to use % for special characters (including
> ampersand), shouldn't we?
Niels,
- "&" should not be percent-encoded in the href or it will lose its
special meaning and not be recognised as a separator of query
parameters; your encoding of this as "&" is exactly the right thing
to do.
- All other special characters ("?" and "=") and your keys and values
are fine in the href because only "&" and '"' require special treatment
in an html attribute and '"' will require percent-encoding.
- Your operation keys and values are all unreserved characters and
require no encoding.
- You are right that all path elements must be percent-encoded. The
slashes between them must not be encoded as they are used for there
special meaning in the URL scheme. '"' is not in the unreserved set so
must be percent-encoded, which will also stop it from breaking your href
so no need to consider HTML entities here.
For example, instead of:
http://localhost:8080/geoserver/rest/resources/poëzie/café?format=xml
URLEncoder.encode("poëzie", "UTF-8") -> "po%C3%ABzie"
URLEncoder.encode("café", "UTF-8") -> "caf%C3%A9"
(but you cannot use URLEncoder.encode on the whole URL or path otherwise
it will encode *everything*)
The href should then contain:
http://localhost:8080/geoserver/rest/resources/po%C3%ABzie/caf%C3%A9?format=xml
Paste the original URL into the Firefox location bar and press enter (it
should be not found!), then Ctrl-C copy it from the location bar and
Firefox will percent-encode it for you as above. :-)
Two more questions:
- Should HTTP headers such as Resource-Parent be percent encoded? I
think so. HTTP forbids all characters outside ISO-8859-1 from headers.
How are other path fields like Location or Content-Location handled?
Percent-encoding I think.
- Should Resource-Parent be relative to the "data directory", or
relative to the server root, or an absolute URL? The next thing a
RESTful client will do is use the Resource-Parent to access the parent.
The full path relative to the server root or even the full absolute URL
would be the most useful thing to give a client in Resource-Parent. You
have the full absolute URL in the content!
At the moment this HEAD request:
curl --head
http://localhost:8080/geoserver/rest/resources/po%C3%ABzie/caf%C3%A9
is expected to contain:
Resource-Parent: /poëzie
But with percent encoding this could be either:
Resource-Parent: /po%C3%ABzie
or even better:
Resource-Parent: /geoserver/rest/resources/po%C3%ABzie
or even more betterer:
Resource-Parent: http://localhost:8080/geoserver/rest/resources/po%C3%ABzie
What do you think?
- Should Resource-Parent have the query (i.e. "?format=xml") of the
original request?
Kind regards,
--
Ben Caradoc-Davies <[email protected]>
Director
Transient Software Limited <http://transient.nz/>
New Zealand
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel