WCF REST: generate correct Content-Length header for HEAD request

The point of a HEAD request is to return a Content-Length header, but with an empty body. The WCF transport stack has the annoying ‘feature’ that it ‘corrects’ the Content-Length header based on the stream that is returned. With the aid of Carlos Figueira’s MyLengthOnlyStream i was able to workaround that ‘feature’ :) (I know, i know, a good old HttpHandler is so much easier to implement!)

  1. Norman Harebottle III

    Did you ever try:

    WebOperationContext.Current.OutgoingResponse.SuppressEntityBody = true;

    ??

  2. No. And I hope I never have to go back to that painful piece of code :)

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>