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