diff options
author | William A. Rowe Jr <wrowe@apache.org> | 2006-06-22 08:46:39 +0200 |
---|---|---|
committer | William A. Rowe Jr <wrowe@apache.org> | 2006-06-22 08:46:39 +0200 |
commit | 61e25cc07a08b6bac68ef0a1f786dce4c325935b (patch) | |
tree | cb252c0f60953a0896ff1a5fc38658f76da281c4 /modules | |
parent | Note new (old) feature (diff) | |
download | apache2-61e25cc07a08b6bac68ef0a1f786dce4c325935b.tar.xz apache2-61e25cc07a08b6bac68ef0a1f786dce4c325935b.zip |
mod_isapi: Ensure we walk through all the methods the developer may have
employed to report their HTTP status result code.
PR: 16637, 30033
Submitted by: Matt Lewandowsky <matt iamcode.net>
Reviewed by: William Rowe
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@416272 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules')
-rw-r--r-- | modules/arch/win32/mod_isapi.c | 80 |
1 files changed, 62 insertions, 18 deletions
diff --git a/modules/arch/win32/mod_isapi.c b/modules/arch/win32/mod_isapi.c index c7352d2a2f..230e706077 100644 --- a/modules/arch/win32/mod_isapi.c +++ b/modules/arch/win32/mod_isapi.c @@ -630,6 +630,8 @@ static apr_ssize_t send_response_header(isapi_cid *cid, { int head_present = 1; int termarg; + int res; + int old_status; const char *termch; apr_size_t ate = 0; @@ -709,29 +711,71 @@ static apr_ssize_t send_response_header(isapi_cid *cid, * * Parse them out, or die trying */ + old_status = cid->r->status; + if (stat) { - cid->r->status = ap_scan_script_header_err_strs(cid->r, NULL, - &termch, &termarg, stat, head, NULL); + res = ap_scan_script_header_err_strs(cid->r, NULL, &termch, &termarg, + stat, head, NULL); + } + else { + res = ap_scan_script_header_err_strs(cid->r, NULL, &termch, &termarg, + head, NULL); + } + + /* Set our status. */ + if (res) { + /* This is an immediate error result from the parser + */ + cid->r->status = res; + cid->r->status_line = ap_get_status_line(cid->r->status); + cid->ecb->dwHttpStatusCode = cid->r->status; + } + else if (cid->r->status) { + /* We have a status in r->status, so let's just use it. + * This is likely to be the Status: parsed above, and + * may also be a delayed error result from the parser. + * If it was filled in, status_line should also have + * been filled in. + */ + cid->ecb->dwHttpStatusCode = cid->r->status; + } + else if (cid->ecb->dwHttpStatusCode + && cid->ecb->dwHttpStatusCode != HTTP_OK) { + /* Now we fall back on dwHttpStatusCode if it appears + * ap_scan_script_header fell back on the default code. + * Any other results set dwHttpStatusCode to the decoded + * status value. + */ + cid->r->status = cid->ecb->dwHttpStatusCode; + cid->r->status_line = ap_get_status_line(cid->r->status); + } + else if (old_status) { + /* Well... either there is no dwHttpStatusCode or it's HTTP_OK. + * In any case, we don't have a good status to return yet... + * Perhaps the one we came in with will be better. Let's use it, + * if we were given one (note this is a pendantic case, it would + * normally be covered above unless the scan script code unset + * the r->status). Should there be a check here as to whether + * we are setting a valid response code? + */ + cid->r->status = old_status; + cid->r->status_line = ap_get_status_line(cid->r->status); cid->ecb->dwHttpStatusCode = cid->r->status; } else { - cid->r->status = ap_scan_script_header_err_strs(cid->r, NULL, - &termch, &termarg, head, NULL); - if (cid->ecb->dwHttpStatusCode && cid->r->status == HTTP_OK - && cid->ecb->dwHttpStatusCode != HTTP_OK) { - /* We tried every way to Sunday to get the status... - * so now we fall back on dwHttpStatusCode if it appears - * ap_scan_script_header fell back on the default code. - * Any other results set dwHttpStatusCode to the decoded - * status value. - */ - cid->r->status = cid->ecb->dwHttpStatusCode; - cid->r->status_line = ap_get_status_line(cid->r->status); - } - else { - cid->ecb->dwHttpStatusCode = cid->r->status; - } + /* None of dwHttpStatusCode, the parser's r->status nor the + * old value of r->status were helpful, and nothing was decoded + * from Status: string passed to us. Let's just say HTTP_OK + * and get the data out, this was the isapi dev's oversight. + */ + cid->r->status = HTTP_OK; + cid->r->status_line = ap_get_status_line(cid->r->status); + cid->ecb->dwHttpStatusCode = cid->r->status; + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, cid->r, + "ISAPI: Could not determine HTTP response code; using %d", + cid->r->status); } + if (cid->r->status == HTTP_INTERNAL_SERVER_ERROR) { return -1; } |