Reputation: 1
After reading the following thread:
Setting a custom Content-Range Header using Restlet
I tried setting a custom unitname in the Range for the entity. This does not solve the Problem.
final Range range = new Range();
range.setUnitName("items");
range.setIndex(0);
range.setSize(20);
[...]
getResponseEntity().setRange(range);
getResponseEntity().setSize(100);
The response now contains the following headers:
Content-Range:"items 0-19/100"
But Restlet also reads the range.size (20 in this case) and puts this as Content-Length automatically. Which results in:
Content-Length:"20"
This causes the client (e.g. Browser to stop reading after 20Bytes. (This also causes a null-pointer exception on the server, since the outputstream gets closed unexpectedly.)
The offical Restlet Documentation: http://restlet.com/technical-resources/restlet-framework/guide/2.3/core/http-headers-mapping
says Content-Length is available as message.entity.size, but this needs to be set to 100 to achieve the desired String in the Content-Range. This looks like a bug to me since range.size is used to calculate the content-length, not the entity size.
I can not set the Content-Length manually, since this is also a standard Header, and any manual changes to the standard headers are ingored.
The "Fix" proposed in the mentioned thread, only changes the Unitname - not the real unit - of the Range specified. It is still interpreted as bytes as is unusable as such.
Using the values in Range twice - for the content-range as well as the content-legth seems to be the problem.
Is there any new way to manually override the headers , or make them dojo compatible?
Manual changes are blocked in the HeaderUtils called by the ServerAdapter, causing the: "WARNING: Addition of the standard header [...] is not allowed..." warning.
Upvotes: 0
Views: 392
Reputation: 866
support will be added in future 2.3.8 release of Restlet Framework.
Upvotes: 0