]> granicus.if.org Git - apache/blobdiff - modules/proxy/ajp_header.c
hostname: Test and log useragent_host per-request across various modules,
[apache] / modules / proxy / ajp_header.c
index c40a88a496572873d50bc7408b0bd0c50c60c4d0..4f94f7b684788a4c4daeb08d701c8460941fd24a 100644 (file)
@@ -37,7 +37,7 @@ static const char *long_res_header_for_sc(int sc)
 {
     const char *rc = NULL;
     sc = sc & 0X00FF;
-    if(sc <= SC_RES_HEADERS_NUM && sc > 0) {
+    if (sc <= SC_RES_HEADERS_NUM && sc > 0) {
         rc = response_trans_headers[sc - 1];
     }
 
@@ -89,39 +89,39 @@ static int sc_for_req_header(const char *header_name)
                 return UNKNOWN_METHOD;
         break;
         case 'C':
-            if(strcmp(p, "OOKIE2") == 0)
+            if (strcmp(p, "OOKIE2") == 0)
                 return SC_COOKIE2;
             else if (strcmp(p, "OOKIE") == 0)
                 return SC_COOKIE;
-            else if(strcmp(p, "ONNECTION") == 0)
+            else if (strcmp(p, "ONNECTION") == 0)
                 return SC_CONNECTION;
-            else if(strcmp(p, "ONTENT-TYPE") == 0)
+            else if (strcmp(p, "ONTENT-TYPE") == 0)
                 return SC_CONTENT_TYPE;
-            else if(strcmp(p, "ONTENT-LENGTH") == 0)
+            else if (strcmp(p, "ONTENT-LENGTH") == 0)
                 return SC_CONTENT_LENGTH;
             else
                 return UNKNOWN_METHOD;
         break;
         case 'H':
-            if(strcmp(p, "OST") == 0)
+            if (strcmp(p, "OST") == 0)
                 return SC_HOST;
             else
                 return UNKNOWN_METHOD;
         break;
         case 'P':
-            if(strcmp(p, "RAGMA") == 0)
+            if (strcmp(p, "RAGMA") == 0)
                 return SC_PRAGMA;
             else
                 return UNKNOWN_METHOD;
         break;
         case 'R':
-            if(strcmp(p, "EFERER") == 0)
+            if (strcmp(p, "EFERER") == 0)
                 return SC_REFERER;
             else
                 return UNKNOWN_METHOD;
         break;
         case 'U':
-            if(strcmp(p, "SER-AGENT") == 0)
+            if (strcmp(p, "SER-AGENT") == 0)
                 return SC_USER_AGENT;
             else
                 return UNKNOWN_METHOD;
@@ -139,7 +139,7 @@ static const unsigned char sc_for_req_method_table[] = {
     SC_M_PUT,
     SC_M_POST,
     SC_M_DELETE,
-    0,                      /* M_DELETE */
+    0,                      /* M_CONNECT */
     SC_M_OPTIONS,
     SC_M_TRACE,
     0,                      /* M_PATCH  */
@@ -226,10 +226,10 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
     ap_log_rerror(APLOG_MARK, APLOG_TRACE8, 0, r, "Into ajp_marshal_into_msgb");
 
     if ((method = sc_for_req_method_by_id(r)) == UNKNOWN_METHOD) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-               "ajp_marshal_into_msgb - No such method %s",
+        ap_log_rerror(APLOG_MARK, APLOG_TRACE8, 0, r, APLOGNO(02437)
+               "ajp_marshal_into_msgb - Sending unknown method %s as request attribute",
                r->method);
-        return AJP_EBAD_METHOD;
+        method = SC_M_JK_STORED;
     }
 
     is_ssl = (apr_byte_t) ap_proxy_conn_is_https(r->connection);
@@ -239,7 +239,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
         num_headers = t->nelts;
     }
 
-    remote_host = (char *)ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_HOST, NULL);
+    remote_host = (char *)ap_get_useragent_host(r, REMOTE_HOST, NULL);
 
     ajp_msg_reset(msg);
 
@@ -247,16 +247,16 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
         ajp_msg_append_uint8(msg, (apr_byte_t) method)           ||
         ajp_msg_append_string(msg, r->protocol)                  ||
         ajp_msg_append_string(msg, uri->path)                    ||
-        ajp_msg_append_string(msg, r->connection->remote_ip)     ||
+        ajp_msg_append_string(msg, r->useragent_ip)              ||
         ajp_msg_append_string(msg, remote_host)                  ||
         ajp_msg_append_string(msg, ap_get_server_name(r))        ||
         ajp_msg_append_uint16(msg, (apr_uint16_t)r->connection->local_addr->port) ||
         ajp_msg_append_uint8(msg, is_ssl)                        ||
         ajp_msg_append_uint16(msg, (apr_uint16_t) num_headers)) {
 
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00968)
                "ajp_marshal_into_msgb: "
-               "Error appending the message begining");
+               "Error appending the message beginning");
         return APR_EGENERAL;
     }
 
@@ -267,7 +267,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
 
         if ((sc = sc_for_req_header(elts[i].key)) != UNKNOWN_METHOD) {
             if (ajp_msg_append_uint16(msg, (apr_uint16_t)sc)) {
-                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00969)
                        "ajp_marshal_into_msgb: "
                        "Error appending the header name");
                 return AJP_EOVERFLOW;
@@ -275,7 +275,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
         }
         else {
             if (ajp_msg_append_string(msg, elts[i].key)) {
-                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00970)
                        "ajp_marshal_into_msgb: "
                        "Error appending the header name");
                 return AJP_EOVERFLOW;
@@ -283,7 +283,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
         }
 
         if (ajp_msg_append_string(msg, elts[i].val)) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00971)
                    "ajp_marshal_into_msgb: "
                    "Error appending the header value");
             return AJP_EOVERFLOW;
@@ -297,7 +297,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
     if (s->secret) {
         if (ajp_msg_append_uint8(msg, SC_A_SECRET) ||
             ajp_msg_append_string(msg, s->secret)) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(03228)
                    "Error ajp_marshal_into_msgb - "
                    "Error appending secret");
             return APR_EGENERAL;
@@ -308,7 +308,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
     if (r->user) {
         if (ajp_msg_append_uint8(msg, SC_A_REMOTE_USER) ||
             ajp_msg_append_string(msg, r->user)) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00972)
                    "ajp_marshal_into_msgb: "
                    "Error appending the remote user");
             return AJP_EOVERFLOW;
@@ -317,7 +317,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
     if (r->ap_auth_type) {
         if (ajp_msg_append_uint8(msg, SC_A_AUTH_TYPE) ||
             ajp_msg_append_string(msg, r->ap_auth_type)) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00973)
                    "ajp_marshal_into_msgb: "
                    "Error appending the auth type");
             return AJP_EOVERFLOW;
@@ -327,7 +327,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
     if (uri->query) {
         if (ajp_msg_append_uint8(msg, SC_A_QUERY_STRING) ||
             ajp_msg_append_string(msg, uri->query)) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00974)
                    "ajp_marshal_into_msgb: "
                    "Error appending the query string");
             return AJP_EOVERFLOW;
@@ -336,7 +336,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
     if ((session_route = apr_table_get(r->notes, "session-route"))) {
         if (ajp_msg_append_uint8(msg, SC_A_JVM_ROUTE) ||
             ajp_msg_append_string(msg, session_route)) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00975)
                    "ajp_marshal_into_msgb: "
                    "Error appending the jvm route");
             return AJP_EOVERFLOW;
@@ -359,7 +359,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
             && envvar[0]) {
             if (ajp_msg_append_uint8(msg, SC_A_SSL_CERT)
                 || ajp_msg_append_string(msg, envvar)) {
-                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00976)
                               "ajp_marshal_into_msgb: "
                               "Error appending the SSL certificates");
                 return AJP_EOVERFLOW;
@@ -371,7 +371,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
             && envvar[0]) {
             if (ajp_msg_append_uint8(msg, SC_A_SSL_CIPHER)
                 || ajp_msg_append_string(msg, envvar)) {
-                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00977)
                               "ajp_marshal_into_msgb: "
                               "Error appending the SSL ciphers");
                 return AJP_EOVERFLOW;
@@ -383,7 +383,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
             && envvar[0]) {
             if (ajp_msg_append_uint8(msg, SC_A_SSL_SESSION)
                 || ajp_msg_append_string(msg, envvar)) {
-                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00978)
                               "ajp_marshal_into_msgb: "
                               "Error appending the SSL session");
                 return AJP_EOVERFLOW;
@@ -397,13 +397,44 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
 
             if (ajp_msg_append_uint8(msg, SC_A_SSL_KEY_SIZE)
                 || ajp_msg_append_uint16(msg, (unsigned short) atoi(envvar))) {
-                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00979)
                               "ajp_marshal_into_msgb: "
                               "Error appending the SSL key size");
                 return APR_EGENERAL;
             }
         }
     }
+    /* If the method was unrecognized, encode it as an attribute */
+    if (method == SC_M_JK_STORED) {
+        if (ajp_msg_append_uint8(msg, SC_A_STORED_METHOD)
+            || ajp_msg_append_string(msg, r->method)) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02438)
+                          "ajp_marshal_into_msgb: "
+                          "Error appending the method '%s' as request attribute",
+                          r->method);
+            return AJP_EOVERFLOW;
+        }
+    }
+    /* Forward the SSL protocol name.
+     * Modern Tomcat versions know how to retrieve
+     * the protocol name from this attribute.
+     */
+    if (is_ssl) {
+        if ((envvar = ap_proxy_ssl_val(r->pool, r->server, r->connection, r,
+                                       AJP13_SSL_PROTOCOL_INDICATOR))
+            && envvar[0]) {
+            const char *key = SC_A_SSL_PROTOCOL;
+            if (ajp_msg_append_uint8(msg, SC_A_REQ_ATTRIBUTE) ||
+                ajp_msg_append_string(msg, key)   ||
+                ajp_msg_append_string(msg, envvar)) {
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02830)
+                        "ajp_marshal_into_msgb: "
+                        "Error appending attribute %s=%s",
+                        key, envvar);
+                return AJP_EOVERFLOW;
+            }
+        }
+    }
     /* Forward the remote port information, which was forgotten
      * from the builtin data of the AJP 13 protocol.
      * Since the servlet spec allows to retrieve it via getRemotePort(),
@@ -413,11 +444,31 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
      */
     {
         const char *key = SC_A_REQ_REMOTE_PORT;
-        char *val = apr_itoa(r->pool, r->connection->remote_addr->port);
+        char *val = apr_itoa(r->pool, r->useragent_addr->port);
+        if (ajp_msg_append_uint8(msg, SC_A_REQ_ATTRIBUTE) ||
+            ajp_msg_append_string(msg, key)   ||
+            ajp_msg_append_string(msg, val)) {
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00980)
+                    "ajp_marshal_into_msgb: "
+                    "Error appending attribute %s=%s",
+                    key, val);
+            return AJP_EOVERFLOW;
+        }
+    }
+    /* Forward the local ip address information, which was forgotten
+     * from the builtin data of the AJP 13 protocol.
+     * Since the servlet spec allows to retrieve it via getLocalAddr(),
+     * we provide the address to the Tomcat connector as a request
+     * attribute. Modern Tomcat versions know how to retrieve
+     * the local address from this attribute.
+     */
+    {
+        const char *key = SC_A_REQ_LOCAL_ADDR;
+        char *val = r->connection->local_ip;
         if (ajp_msg_append_uint8(msg, SC_A_REQ_ATTRIBUTE) ||
             ajp_msg_append_string(msg, key)   ||
             ajp_msg_append_string(msg, val)) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02646)
                     "ajp_marshal_into_msgb: "
                     "Error appending attribute %s=%s",
                     key, val);
@@ -432,7 +483,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
             if (ajp_msg_append_uint8(msg, SC_A_REQ_ATTRIBUTE) ||
                 ajp_msg_append_string(msg, elts[i].key + 4)   ||
                 ajp_msg_append_string(msg, elts[i].val)) {
-                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00981)
                         "ajp_marshal_into_msgb: "
                         "Error appending attribute %s=%s",
                         elts[i].key, elts[i].val);
@@ -442,7 +493,7 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
     }
 
     if (ajp_msg_append_uint8(msg, SC_A_ARE_DONE)) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00982)
                "ajp_marshal_into_msgb: "
                "Error appending the message end");
         return AJP_EOVERFLOW;
@@ -497,7 +548,7 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
     rc = ajp_msg_get_uint16(msg, &status);
 
     if (rc != APR_SUCCESS) {
-         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00983)
                 "ajp_unmarshal_response: Null status");
         return rc;
     }
@@ -510,7 +561,8 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
         ap_xlate_proto_from_ascii(ptr, strlen(ptr));
 #endif
         r->status_line =  apr_psprintf(r->pool, "%d %s", status, ptr);
-    } else {
+    }
+    else {
         r->status_line = NULL;
     }
 
@@ -530,7 +582,8 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
         apr_table_do(addit_dammit, save_table, r->headers_out,
                      "Set-Cookie", NULL);
         r->headers_out = save_table;
-    } else {
+    }
+    else {
         r->headers_out = NULL;
         num_headers = 0;
     }
@@ -539,7 +592,7 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
            "ajp_unmarshal_response: Number of headers is = %d",
            num_headers);
 
-    for(i = 0 ; i < (int) num_headers ; i++) {
+    for (i = 0; i < (int)num_headers; i++) {
         apr_uint16_t name;
         const char *stringname;
         const char *value;
@@ -552,17 +605,18 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
             ajp_msg_get_uint16(msg, &name);
             stringname = long_res_header_for_sc(name);
             if (stringname == NULL) {
-                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00984)
                        "ajp_unmarshal_response: "
                        "No such sc (%08x)",
                        name);
                 return AJP_EBAD_HEADER;
             }
-        } else {
+        }
+        else {
             name = 0;
             rc = ajp_msg_get_string(msg, &stringname);
             if (rc != APR_SUCCESS) {
-                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00985)
                        "ajp_unmarshal_response: "
                        "Null header name");
                 return rc;
@@ -572,22 +626,22 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
 
         rc = ajp_msg_get_string(msg, &value);
         if (rc != APR_SUCCESS) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00986)
                    "ajp_unmarshal_response: "
                    "Null header value");
             return rc;
         }
 
         /* Set-Cookie need additional processing */
-        if (!strcasecmp(stringname, "Set-Cookie")) {
+        if (!ap_casecmpstr(stringname, "Set-Cookie")) {
             value = ap_proxy_cookie_reverse_map(r, dconf, value);
         }
         /* Location, Content-Location, URI and Destination need additional
          * processing */
-        else if (!strcasecmp(stringname, "Location")
-                 || !strcasecmp(stringname, "Content-Location")
-                 || !strcasecmp(stringname, "URI")
-                 || !strcasecmp(stringname, "Destination"))
+        else if (!ap_casecmpstr(stringname, "Location")
+                 || !ap_casecmpstr(stringname, "Content-Location")
+                 || !ap_casecmpstr(stringname, "URI")
+                 || !ap_casecmpstr(stringname, "Destination"))
         {
           value = ap_proxy_location_reverse_map(r, dconf, value);
         }
@@ -600,7 +654,7 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
         apr_table_add(r->headers_out, stringname, value);
 
         /* Content-type needs an additional handling */
-        if (strcasecmp(stringname, "Content-Type") == 0) {
+        if (ap_casecmpstr(stringname, "Content-Type") == 0) {
              /* add corresponding filter */
             ap_set_content_type(r, apr_pstrdup(r->pool, value));
             ap_log_rerror(APLOG_MARK, APLOG_TRACE5, 0, r,
@@ -624,14 +678,14 @@ apr_status_t ajp_send_header(apr_socket_t *sock,
 
     rc = ajp_msg_create(r->pool, buffsize, &msg);
     if (rc != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00987)
                "ajp_send_header: ajp_msg_create failed");
         return rc;
     }
 
     rc = ajp_marshal_into_msgb(msg, r, uri);
     if (rc != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00988)
                "ajp_send_header: ajp_marshal_into_msgb failed");
         return rc;
     }
@@ -639,7 +693,7 @@ apr_status_t ajp_send_header(apr_socket_t *sock,
     rc = ajp_ilink_send(sock, msg);
     ajp_msg_log(r, msg, "ajp_send_header: ajp_ilink_send packet dump");
     if (rc != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00989)
                "ajp_send_header: ajp_ilink_send failed");
         return rc;
     }
@@ -661,7 +715,7 @@ apr_status_t ajp_read_header(apr_socket_t *sock,
     if (*msg) {
         rc = ajp_msg_reuse(*msg);
         if (rc != APR_SUCCESS) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00990)
                    "ajp_read_header: ajp_msg_reuse failed");
             return rc;
         }
@@ -669,7 +723,7 @@ apr_status_t ajp_read_header(apr_socket_t *sock,
     else {
         rc = ajp_msg_create(r->pool, buffsize, msg);
         if (rc != APR_SUCCESS) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00991)
                    "ajp_read_header: ajp_msg_create failed");
             return rc;
         }
@@ -677,12 +731,17 @@ apr_status_t ajp_read_header(apr_socket_t *sock,
     ajp_msg_reset(*msg);
     rc = ajp_ilink_receive(sock, *msg);
     if (rc != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00992)
                "ajp_read_header: ajp_ilink_receive failed");
         return rc;
     }
     ajp_msg_log(r, *msg, "ajp_read_header: ajp_ilink_receive packet dump");
     rc = ajp_msg_peek_uint8(*msg, &result);
+    if (rc != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00993)
+                      "ajp_read_header: ajp_msg_peek_uint8 failed");
+        return rc;
+    }
     ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r,
                "ajp_read_header: ajp_ilink_received %s (0x%02x)",
                ajp_type_str(result), result);
@@ -709,12 +768,12 @@ apr_status_t ajp_parse_header(request_rec  *r, proxy_dir_conf *conf,
 
     rc = ajp_msg_get_uint8(msg, &result);
     if (rc != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00994)
                "ajp_parse_headers: ajp_msg_get_byte failed");
         return rc;
     }
     if (result != CMD_AJP13_SEND_HEADERS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00995)
                "ajp_parse_headers: wrong type %s (0x%02x) expecting %s (0x%02x)",
                ajp_type_str(result), result,
                ajp_type_str(CMD_AJP13_SEND_HEADERS), CMD_AJP13_SEND_HEADERS);
@@ -733,12 +792,12 @@ apr_status_t  ajp_parse_data(request_rec  *r, ajp_msg_t *msg,
 
     rc = ajp_msg_get_uint8(msg, &result);
     if (rc != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00996)
                "ajp_parse_data: ajp_msg_get_byte failed");
         return rc;
     }
     if (result != CMD_AJP13_SEND_BODY_CHUNK) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00997)
                "ajp_parse_data: wrong type %s (0x%02x) expecting %s (0x%02x)",
                ajp_type_str(result), result,
                ajp_type_str(CMD_AJP13_SEND_BODY_CHUNK), CMD_AJP13_SEND_BODY_CHUNK);
@@ -760,7 +819,7 @@ apr_status_t  ajp_parse_data(request_rec  *r, ajp_msg_t *msg,
      */
     expected_len = msg->len - (AJP_HEADER_LEN + AJP_HEADER_SZ_LEN + 1 + 1);
     if (*len != expected_len) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00998)
                "ajp_parse_data: Wrong chunk length. Length of chunk is %i,"
                " expected length is %i.", *len, expected_len);
         return AJP_EBAD_HEADER;
@@ -778,12 +837,12 @@ apr_status_t ajp_parse_reuse(request_rec *r, ajp_msg_t *msg,
 
     rc = ajp_msg_get_uint8(msg, &result);
     if (rc != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00999)
                "ajp_parse_reuse: ajp_msg_get_byte failed");
         return rc;
     }
     if (result != CMD_AJP13_END_RESPONSE) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01000)
                "ajp_parse_reuse: wrong type %s (0x%02x) expecting %s (0x%02x)",
                ajp_type_str(result), result,
                ajp_type_str(CMD_AJP13_END_RESPONSE), CMD_AJP13_END_RESPONSE);