Bug 16637 - ISAPI: HTTP 200 OK error response is still returned
Summary: ISAPI: HTTP 200 OK error response is still returned
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_isapi (show other bugs)
Version: 2.0.44
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks: 30033
  Show dependency tree
 
Reported: 2003-01-31 13:14 UTC by Laimutis Ignatavicius
Modified: 2006-07-18 11:06 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laimutis Ignatavicius 2003-01-31 13:14:51 UTC
Thank you for fixing the Bug#: 10216 in version 2.0.44. It stopped displaying 
HTTP 200 OK error response in very most cases.

But there is one more case when this "error" response is displayed: when ISAPI 
extension does not include any HTTP header in it response. 

We traced mod_isapi.c and found such a situation:

1. ISAPI extension calls ServerSupportFunction with '200 OK' in buf_data 
parameter, 0 in buf_size parameter, and pointer to a "null-terminated string 
pointing to optional headers or data to be appended and sent with the header" 
(excerpt from Microsoft MFC Library Reference) in data_type parameter.

2. ServerSupportFunction calls send_response_header function, and it returns 
at line 795:

    /* If only Status was passed, we consumed nothing 
     */
    if (!head_present)
        return 0;             /* <- line 795 */

    cid->headers_set = 1;     /* <- line 797 */

3. Line 797, added in version 2.0.44, is not entered, and bug fix code, added 
for correcting the buggy '200 OK' response, is not entered (line 1597). Line 
1595 returns the value 200, causing the result to run through the core die 
handler:

    /* Flush the response now, including headers-only responses */
    if (cid->headers_set) {
<...>
        cid->response_sent = 1;

        return OK;  /* NOT r->status or cid->r->status, even if it has 
changed. */
    }
    
    /* As the client returned no error, and if we did not error out
     * ourselves, trust dwHttpStatusCode to say something relevant.
     */
    if (!ap_is_HTTP_SERVER_ERROR(r->status) && cid->ecb->dwHttpStatusCode) {
        r->status = cid->ecb->dwHttpStatusCode;
    }

    /* For all missing-response situations simply return the status.
     * and let the core deal respond to the client.
     */
    return r->status; /* <- line 1595 */


Recommendations for solving the problem: move code line 797 four lines above.


Another minor problem, considering the same bug-fix code added, is that HTTP 
status code 200 is not logged in 'access.log' for all successful calls of an 
ISAPI extension, with exception to the problem described above. These 
responses are logged normally. :-)

Recommendations for solving problem: insert one line of code in mod_isapi.c, 
line 1582:

        r->status = cid->ecb->dwHttpStatusCode; /* <- line 1582 */

        return OK;  /* NOT r->status or cid->r->status, even if it has 
changed. */
Comment 1 William A. Rowe Jr. 2003-02-26 18:54:43 UTC
  Actually, there was a small logic error related to the way that some
  calls were processed in send_response_header.  We believe the new code
  is cleaner, but it may or may not resolve your issue altogether.

  If you are building Apache yourself, please replace your mod_isapi.c module
  with the current CVS available from;

http://cvs.apache.org/viewcvs.cgi/*checkout*/httpd-2.0/modules/arch/win32/mod_isapi.c?rev=1.88.2.2

  And let us know if the error remains.  I suspect it does.

  One thing you mention is that we call from ServerSupportFunction() ... in
  fact we have several potential calls from that code - please identify which
  call to ServerSupportFunction is't working.

  I guess that sending any body, whatsoever should toggle cid->headers_set to
  1 so that everything else works.

  Let me make certain; are you trying to send a response 200 OK with *no*
  headers, *AND* no body?
Comment 2 William A. Rowe Jr. 2006-06-22 06:46:57 UTC
  Closed 30033, presuming fixed in trunk.
Comment 3 Matt Lewandowsky 2006-07-05 13:10:39 UTC
Will Rowe has posted a zipfile containing compiled mod_isapi modules which
include the patch correcting this bug (for use with 2.0.58 and 2.2.2), for
testing purposes. It is available at:

http://people.apache.org/~wrowe/mod_isapi-416293.zip

You may read his full email to the dev@httpd.apache.org list here:

http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=115206683718140&w=2

If you test this version of mod_isapi, please post your feedback to the
dev@httpd.apache.org list. Your feedback will help ensure that there are no
regressions or other issues in this version of mod_isapi.
Comment 4 William A. Rowe Jr. 2006-07-18 18:06:54 UTC
*** Bug 40067 has been marked as a duplicate of this bug. ***