embedthis/http — pull request #6 by jchampio (2012-07-20 17:39:21+00:00)
Title: passHandler Fixes

The first patch explicitly provides a Content-Length of zero for an empty OPTIONS response. This is required by [section 9.2 of RFC 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.2):

> The OPTIONS method represents a request for information about the communication options available on the request/response chain identified by the Request-URI. [...] If no response body is included, the response MUST include a Content-Length field with a field-value of "0".

----

The second patch moves OPTIONS and TRACE handling in the passHandler from the ```open``` callback to the ```start``` callback. Since ```open``` is always called, it is possible that the passHandler will try to continue processing a request that has already been finalized because of an error.

One example of such behavior is with an OPTIONS request on a basic-auth route. If authentication fails, an error response body will be created, but the passHandler will still be invoked and process the request. In this particular case, ```httpOmitBody``` is called on the finalized connection and what emerges is an invalid HTTP response. Moving this processing to ```start``` ensures that it does not occur if the connection is finalized early.