Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting a custom Content-Range Header using Restlet
    primarykey
    data
    text
    <p>I'm using restlet 2.0.11 to provide data for a Dojo-based web application via a REST-Web-Interface.</p> <p>According to the documentation of dojo, pagination is realized using the "content-range" header of HTTP, thus dojo expects a header like: </p> <pre><code>Content-Range: items 0-19/100 </code></pre> <p>(Source: <a href="http://dojotoolkit.org/reference-guide/1.7/dojox/data/JsonRestStore.html" rel="nofollow">http://dojotoolkit.org/reference-guide/1.7/dojox/data/JsonRestStore.html</a>)</p> <p>Which means that the REST-Api provides the first 20 of 100 total items.</p> <p>Setting the Content-Range header manually like this</p> <pre><code>getResponse().getAttributes().get("org.restlet.http.headers").add(new Parameter("Content-Range", "FooBar") </code></pre> <p>Results in the following error:</p> <pre><code>WARNING: Addition of the standard header "Content-Range" is not allowed. Please use the equivalent property in the Restlet API. </code></pre> <p>According to restlet's documentation the property is "message.entity.range" (Source: <a href="http://wiki.restlet.org/docs_2.0/130-restlet.html" rel="nofollow">http://wiki.restlet.org/docs_2.0/130-restlet.html</a>)</p> <p>The direct modification of this hash-map was also without success:</p> <pre><code>getResponse().getAttributes().put("message.entity.range", "FooBat"); </code></pre> <p>Another way which seemed to be promising is using the "Representation"-object of restlet, since it has a setRange() method, but during request time, the object reference is null:</p> <pre><code>getResponse().getEntity() </code></pre> <p>So my question is: How to set a Content-Range header to a Restlet response?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload