From d02f5c7aba32a38aa21c00947d2b2681e543ab65 Mon Sep 17 00:00:00 2001 From: Greg Stein Date: Tue, 4 Jul 2000 00:28:25 +0000 Subject: [PATCH] add ap_get_status_line() so that modules can get a standardized Status-Line value for their response. Submitted by: Joe Orton Reviewed by: Greg Stein git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85762 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_protocol.h | 7 +++++++ modules/dav/main/mod_dav.c | 8 +++++--- modules/http/http_protocol.c | 5 +++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/http_protocol.h b/include/http_protocol.h index 43a0a6aa45..c52b141d1f 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -165,6 +165,13 @@ API_EXPORT(int) ap_rflush(request_rec *r); API_EXPORT(int) ap_index_of_response(int status); +/* + * Return the Status-Line for a given status code (excluding the + * HTTP-Version field). If an invalid or unknown status code is + * passed, "500 Internal Server Error" will be returned. + */ +API_EXPORT(const char *) ap_get_status_line(int status); + /* Reading a block of data from the client connection (e.g., POST arg) */ API_EXPORT(int) ap_setup_client_block(request_rec *r, int read_policy); diff --git a/modules/dav/main/mod_dav.c b/modules/dav/main/mod_dav.c index ab7709313e..a320a9a179 100644 --- a/modules/dav/main/mod_dav.c +++ b/modules/dav/main/mod_dav.c @@ -595,10 +595,12 @@ static void dav_send_multistatus(request_rec *r, int status, ap_rputs("" DEBUG_CR, r); if (first->propresult.propstats == NULL) { - /* ### it would be nice to get a status line from Apache */ + /* use the Status-Line text from Apache. Note, this will + * default to 500 Internal Server Error if first->status + * is not a known (or valid) status code. */ ap_rprintf(r, - "HTTP/1.1 %d status text goes here" - DEBUG_CR, first->status); + "HTTP/1.1 %s" DEBUG_CR, + ap_get_status_line(first->status)); } else { /* assume this includes and is quoted properly */ diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index bb08a8ee40..4fd5608370 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -1466,6 +1466,11 @@ API_EXPORT(int) ap_index_of_response(int status) return LEVEL_500; /* 600 or above is also illegal */ } +API_EXPORT(const char *) ap_get_status_line(int status) +{ + return status_lines[ap_index_of_response(status)]; +} + /* Send a single HTTP header field to the client. Note that this function * is used in calls to table_do(), so their interfaces are co-dependent. * In other words, don't change this one without checking table_do in alloc.c. -- 2.50.1