MSDN documentation can be incomplete.

Well, incomplete in my opinion anyway.

A co-worker was having a problem with his in-process HTTP server written using the very cool HttpListener class available in .NET 2.0 (on Win2k3 and WinXP SP2 only). In his code he was attempting to enable chunking of the response by setting the HttpListenerResponse.SendChunked property to true. Great! But it didn’t chunk. Why? Because his code looked like this:

HttpListener listener; // Created elsewhere
HttpListenerContext context = listener.GetContext();
// Open a file/stream/whatever, etc.
System.IO.Stream stream; // = …
context.Response.SendChunked = true;
context.Response.ContentLength64 = stream.Length;
// etc.

According to the documentation, there’s nothing wrong with that. What they don’t tell you, however, is that SendChunked and ContentLength64 are mutually exclusive. Setting one negates the effect of the other. After a couple of minutes of reflection (both mentally, theoretically, and most importantly programmatically) on the subject, this fact started rising to the surface.

To me, that’s worth putting in at least a comment in the documentation.

This entry was posted on Wednesday, August 23rd, 2006 at 12:14 am and is filed under microsoft. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

One Response to “MSDN documentation can be incomplete.”

  1. More fun with documentation | Aaron Lerch Says:

    [...] November 13th @ 2:36 pm by aaron Over a year ago I posted about some incomplete MSDN documentation. In continuing my “annual” series on [...]