httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <...@orton.demon.co.uk>
Subject [PATCH] Add "ap_get_response_status_line"
Date Mon, 03 Jul 2000 23:59:59 GMT
This patch adds an exported "ap_get_response_status_line" function to
http_protocol.[ch], which returns the Status-Line for a given status
code. This is useful to DAV, since the error response body of DAV
methods use Status-Line for arbitrary status codes.

I'm not sure about the name of this function; better suggestions?

Also included a patch to mod_dav.c to use this function.

joe

Index: main/http_protocol.c
===================================================================
RCS file: /home/joe/lib/cvsroot/apache2/src/main/http_protocol.c,v
retrieving revision 1.89
diff -u -p -r1.89 http_protocol.c
--- http_protocol.c	2000/06/28 14:33:32	1.89
+++ http_protocol.c	2000/07/03 16:38:20
@@ -1466,6 +1466,11 @@ API_EXPORT(int) ap_index_of_response(int
     return LEVEL_500;           /* 600 or above is also illegal */
 }
 
+API_EXPORT(const char *) ap_get_response_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.
Index: include/http_protocol.h
===================================================================
RCS file: /home/joe/lib/cvsroot/apache2/src/include/http_protocol.h,v
retrieving revision 1.16
diff -u -p -r1.16 http_protocol.h
--- http_protocol.h	2000/06/24 17:33:53	1.16
+++ http_protocol.h	2000/07/03 23:40:11
@@ -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_response_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);

And the mod_dav patch:

Index: mod_dav.c
===================================================================
RCS file: /home/joe/lib/cvsroot/apache2/src/modules/dav/main/mod_dav.c,v
retrieving revision 1.6
diff -u -p -r1.6 mod_dav.c
--- mod_dav.c	2000/07/03 22:50:58	1.6
+++ mod_dav.c	2000/07/03 23:20:52
@@ -595,10 +595,12 @@ static void dav_send_multistatus(request
 	ap_rputs("</D:href>" 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,
-		       "<D:status>HTTP/1.1 %d status text goes here</D:status>"
-		       DEBUG_CR, first->status);
+		       "<D:status>HTTP/1.1 %s</D:status>" DEBUG_CR, 
+		       ap_get_response_status_line(first->status));
 	}
 	else {
 	    /* assume this includes <propstat> and is quoted properly */

Mime
View raw message