It revealed:
The following .Net Fx source code was found (in the HttpWebResponse class):
/// <devdoc> /// <para>Gets the stream used for reading the body of the response from the /// server.</para> /// </devdoc> public override Stream GetResponseStream() { if (Logging.On) Logging.Enter(Logging.Web, this, "GetResponseStream", ""); CheckDisposed(); if (!CanGetResponseStream()) { // give a blank stream in the HEAD case, which = 0 bytes of data if (Logging.On) Logging.Exit(Logging.Web, this, "GetResponseStream", Stream.Null); return Stream.Null; } if (Logging.On) Logging.PrintInfo(Logging.Web, "ContentLength=" + m_ContentLength); if (Logging.On) Logging.Exit(Logging.Web, this, "GetResponseStream", m_ConnectStream); return m_ConnectStream; }
As you can see, it explicitly returns an empty stream for "HEAD" requests. "Why do this?" I'm asking.
I found this at http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html :
9.4 HEAD
The HEAD method is identical to GET, except that the server SHOULD NOT return the message body in response. The metadata contained in the HTTP headers in response to the HEAD request MUST be identical to the information sent in response to the GET request. This method can be used to obtain meta-information about the entity implied by the request, without transferring the object-object itself. This method is often used to check for hypertext links for authenticity, accessibility, and recent modification.
Wow. I took from the book of Richardson and Ruby RESTful Web Services that you can be smart and respond to a "HEAD" request with an empty XHTML form that would fully describe the structure of resource elements, including mandatory, data type, length, etc. Using all attributes of the XHTML form field (5). However, after reading the HTTP specification, it is clear that all the "HEAD" response data must go into the HTTP headers.
Well, you learn something new every day ...
source share