I’m creating a pretty simple HTTP service using OpenRasta. For HEAD requests, the HTTP 1.1 spec states that HEAD requests should have the Content-Length set to “the size of the entity-body that would have been sent had the request been a GET” (section 14.13).
However, OpenRasta apparently sees that the response body is empty and automatically sets the Content-Length header to “0”.
What is the recommended way to override this behavior?
Thanks-
Faced with exactly this problem my solution was to add an IPipelineContributor to deal with HEAD requests. The contributor was initialized as follows:
In the pre-process step I swapped the HTTP method from HEAD to GET in order to allow the request to be processed as normal.
At the end of the pipeline the response headers get written as expected, but nothing is written to the body.