0

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.

Community
  • 1
  • 1
Max
  • 1
  • Hi, thanks for reporting this. I've added an issue for that point: https://github.com/restlet/restlet-framework-java/issues/1132 . I'll have a look later. – Thierry Boileau Aug 20 '15 at 11:36
  • Hi, a fix has been developped, waiting for validation. – Thierry Boileau Aug 24 '15 at 09:31
  • Hey! Great, looks like it would fix the problem. Looking forward to it. – Max Aug 27 '15 at 06:26
  • Having read the HTTP specification: https://tools.ietf.org/html/rfc7233#section-4.1, it appears that Content-length contains the size of the payload that is to say the size of the range (in case of bytes range). – Thierry Boileau Apr 16 '16 at 09:42

1 Answers1

0

support will be added in future 2.3.8 release of Restlet Framework.

Thierry Boileau
  • 866
  • 5
  • 8