Alex,
you cannot add a Content-Length header yourself, the spray-can layer takes care of this.
However, your question raises an issue that apparently has been asked by many implementors of HTTP client functionality before:
When exactly are `Content-Length: 0` headers required?
Unfortunately RFC2616 is a bit cloudy in that regard so I've done a bit more research into this. The best discussion I could find is this one:
http://lists.w3.org/Archives/Public/ietf-http-wg/2006AprJun/0096.html
Up to now we only rendered a `Content-Length: 0` header if a request entity was actually present.
However, the best approach appears to be to include a `Content-Length: 0` in requests with a method for which the meaning of a request entity is properly defined.
This means that GET requests do not receive a `Content-Length: 0` header because the meaning of GET entities is not defined (even though the spec does not explicitly forbid them).
PUT request on the contrary should receive a `Content-Length: 0` header.
I have just added a patch implementing this, it'll be part of the next nightly.
Thanks for bringing this up!
Cheers,
Mathias
---
mat...@spray.io
http://spray.io
> --
>
>