Tim Van Wassenhove

Passionate geek, interested in Technology. Proud father of two

28 May 2010

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!)