41a6c3
--- a/modules/http/http_filters.c	2013/10/08 14:17:33	1530279
41a6c3
+++ b/modules/http/http_filters.c	2013/10/08 14:18:44	1530280
41a6c3
@@ -825,7 +825,7 @@
41a6c3
  * handler.
41a6c3
  * Zap r->status_line if bad.
41a6c3
  */
41a6c3
-static void validate_status_line(request_rec *r)
41a6c3
+static apr_status_t validate_status_line(request_rec *r)
41a6c3
 {
41a6c3
     char *end;
41a6c3
 
41a6c3
@@ -836,15 +836,19 @@
41a6c3
             || (end - 3) != r->status_line
41a6c3
             || (len >= 4 && ! apr_isspace(r->status_line[3]))) {
41a6c3
             r->status_line = NULL;
41a6c3
+            return APR_EGENERAL;
41a6c3
         }
41a6c3
         /* Since we passed the above check, we know that length three
41a6c3
          * is equivalent to only a 3 digit numeric http status.
41a6c3
          * RFC2616 mandates a trailing space, let's add it.
41a6c3
          */
41a6c3
-        else if (len == 3) {
41a6c3
+        if (len == 3) {
41a6c3
             r->status_line = apr_pstrcat(r->pool, r->status_line, " ", NULL);
41a6c3
+            return APR_EGENERAL;
41a6c3
         }
41a6c3
+        return APR_SUCCESS;
41a6c3
     }
41a6c3
+    return APR_EGENERAL;
41a6c3
 }
41a6c3
 
41a6c3
 /*
41a6c3
@@ -856,15 +860,25 @@
41a6c3
 static void basic_http_header_check(request_rec *r,
41a6c3
                                     const char **protocol)
41a6c3
 {
41a6c3
+    apr_status_t rv;
41a6c3
+
41a6c3
     if (r->assbackwards) {
41a6c3
         /* no such thing as a response protocol */
41a6c3
         return;
41a6c3
     }
41a6c3
 
41a6c3
-    validate_status_line(r);
41a6c3
+    rv = validate_status_line(r);
41a6c3
 
41a6c3
     if (!r->status_line) {
41a6c3
         r->status_line = ap_get_status_line(r->status);
41a6c3
+    } else if (rv != APR_SUCCESS) {
41a6c3
+        /* Status line is OK but our own reason phrase
41a6c3
+         * would be preferred if defined
41a6c3
+         */
41a6c3
+        const char *tmp = ap_get_status_line(r->status);
41a6c3
+        if (!strncmp(tmp, r->status_line, 3)) {
41a6c3
+            r->status_line = tmp;
41a6c3
+        }
41a6c3
     }
41a6c3
 
41a6c3
     /* Note that we must downgrade before checking for force responses. */