]> granicus.if.org Git - apache/commitdiff
Add in SeeRequestTail directive, to handle the shortcoming
authorJim Jagielski <jim@apache.org>
Wed, 31 Oct 2007 12:19:54 +0000 (12:19 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 31 Oct 2007 12:19:54 +0000 (12:19 +0000)
of only storing 63 bytes of the request, when the requests
are longer than that and only vary towards the end; eg:

   GET /disk1/storage/apache/htdocs/images/image-store1/food/fruits/seeded/apples.jpg
   GET /disk1/storage/apache/htdocs/images/image-store1/food/fruits/seeded/pears.jpg
   GET /disk1/storage/apache/htdocs/images/image-store1/food/fruits/seeded/plums.jpg

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@590641 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_status.xml
include/ap_mmn.h
include/scoreboard.h
modules/generators/mod_status.c
server/scoreboard.c

diff --git a/CHANGES b/CHANGES
index 26fc1bdaa3496eeb7a35f0f985ab83a2bd9aec0d..be4f2d7130bceff4b7cf18f0a3e74f336093fe5b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,12 @@
 Changes with Apache 2.3.0
 [ When backported to 2.2.x, remove entry from this file ]
 
+  *) mod_status: Add SeeRequestTail directive, which determines if
+     ExtendedStatus displays the 1st 63 characters of the request
+     or the last 63. Useful for those requests with large string
+     lengths and which only vary with the last several characters.
+     [Jim Jagielski]
+
   *) mod_proxy: add "nocanon" keyword to ProxyPass, to suppress
      URI-canonicalisation in a reverse proxy.
      PR 41798 [Nick Kew]
index dd55ae4a76f07043a27a8f23834894dc87c10905..2c6ef9c2ac849dee0e69a5b6fd8112e89547388a 100644 (file)
@@ -140,5 +140,29 @@ later.</compatibility>
 </usage>
 
 </directivesynopsis>
+<directivesynopsis>
+
+<name>SeeRequestTail</name>
+<description>Determine if mod_status displays the first 63 characters
+of a request or the last 63, assuming the request itself is greater than
+63 chars.</description>
+<syntax>SeeRequestTail On|Off</syntax>
+<default>SeeRequestTail Off</default>
+<contextlist><context>server config</context></contextlist>
+<compatibility>SeeRequestTail is only available in Apache 2.3.x and 
+later.</compatibility>
+
+<usage>
+    <p>mod_status with ExtendedStatus On displays the actual request being
+    handled. For historical purposes, only 63 characters of the request
+    are actually stored for display purposes. This directive
+    controls whether the 1st 63 characters are stored (the previous
+    behavior and the default) or if the last 63 characters are. This
+    is only applicable, of course, if the length of the request is
+    64 characters or greater.</p>
+</usage>
+
+</directivesynopsis>
+
 </modulesynopsis>
 
index c62def9ca389b3f7f9ddba1691573bd405818fe4..241e0b50d71a6e4631766f702a54e0f0655568ef 100644 (file)
  * 20071023.0 (2.3.0-dev)  add ap_get_scoreboard(sbh) split from the less
  *                         conventional ap_get_scoreboard(proc, thread)
  * 20071023.1 (2.3.0-dev)  Add flags field to struct proxy_alias
+ * 20071023.2 (2.3.0-dev)  Add ap_mod_status_reqtail
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20071023
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                    /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 2                    /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 4688f31736d5071b55df9302f2ae5dea8712b3a6..5b79debd415fd8e706a31e7311f5b9491e3c0bff 100644 (file)
@@ -188,6 +188,7 @@ AP_DECLARE(lb_score *) ap_get_scoreboard_lb(int lb_num);
 AP_DECLARE_DATA extern scoreboard *ap_scoreboard_image;
 AP_DECLARE_DATA extern const char *ap_scoreboard_fname;
 AP_DECLARE_DATA extern int ap_extended_status;
+AP_DECLARE_DATA extern int ap_mod_status_reqtail;
 
 AP_DECLARE_DATA extern ap_generation_t volatile ap_my_generation;
 
index 8e357c9845deea4d90a32b22e6700d3830569bbe..f2649541b373d10e9d4e646b3a356cdf8357f8b5 100644 (file)
@@ -128,10 +128,24 @@ static const char *set_extended_status(cmd_parms *cmd, void *dummy, int arg)
     return NULL;
 }
 
+static const char *set_reqtail(cmd_parms *cmd, void *dummy, int arg)
+{
+    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+    if (err != NULL) {
+        return err;
+    }
+    ap_mod_status_reqtail = arg;
+    return NULL;
+}
+
+
 static const command_rec status_module_cmds[] =
 {
     AP_INIT_FLAG("ExtendedStatus", set_extended_status, NULL, RSRC_CONF,
       "\"On\" to enable extended status information, \"Off\" to disable"),
+    AP_INIT_FLAG("SeeRequestTail", set_reqtail, NULL, RSRC_CONF,
+      "For verbose requests, \"On\" to see the last 63 chars of the request, "
+      "\"Off\" (default) to see the first 63 in extended status display"),
     {NULL}
 };
 
index 54d1fc864838f703bd17a4d9ca34e737880f33b1..dd7de5563d2bebaeb32cbb125833046d16382740 100644 (file)
@@ -40,6 +40,7 @@
 AP_DECLARE_DATA scoreboard *ap_scoreboard_image = NULL;
 AP_DECLARE_DATA const char *ap_scoreboard_fname = NULL;
 AP_DECLARE_DATA int ap_extended_status = 0;
+AP_DECLARE_DATA int ap_mod_status_reqtail = 0;
 
 #if APR_HAS_SHARED_MEMORY
 
@@ -388,6 +389,42 @@ AP_DECLARE(void) ap_create_sb_handle(ap_sb_handle_t **new_sbh, apr_pool_t *p,
     (*new_sbh)->thread_num = thread_num;
 }
 
+static void copy_request(char *rbuf, apr_size_t rbuflen, request_rec *r)
+{
+    char *p;
+
+    if (r->the_request == NULL) {
+        apr_cpystrn(rbuf, "NULL", rbuflen);
+        return; /* short circuit below */
+    }
+
+    if (r->parsed_uri.password == NULL) {
+        p = r->the_request;
+    }
+    else {
+        /* Don't reveal the password in the server-status view */
+        p = apr_pstrcat(r->pool, r->method, " ",
+                        apr_uri_unparse(r->pool, &r->parsed_uri,
+                        APR_URI_UNP_OMITPASSWORD),
+                        r->assbackwards ? NULL : " ", r->protocol, NULL);
+    }
+
+    /* now figure out if we copy over the 1st rbuflen chars or the last */
+    if (!ap_mod_status_reqtail) {
+        apr_cpystrn(rbuf, p, rbuflen);
+    }
+    else {
+        apr_size_t slen = strlen(p);
+        if (slen < rbuflen) {
+            /* it all fits anyway */
+            apr_cpystrn(rbuf, p, rbuflen);
+        }
+        else {
+            apr_cpystrn(rbuf, p+(slen-rbuflen+1), rbuflen);
+        }
+    }
+}
+
 AP_DECLARE(int) ap_update_child_status_from_indexes(int child_num,
                                                     int thread_num,
                                                     int status,
@@ -430,18 +467,7 @@ AP_DECLARE(int) ap_update_child_status_from_indexes(int child_num,
             conn_rec *c = r->connection;
             apr_cpystrn(ws->client, ap_get_remote_host(c, r->per_dir_config,
                         REMOTE_NOLOOKUP, NULL), sizeof(ws->client));
-            if (r->the_request == NULL) {
-                apr_cpystrn(ws->request, "NULL", sizeof(ws->request));
-            } else if (r->parsed_uri.password == NULL) {
-                apr_cpystrn(ws->request, r->the_request, sizeof(ws->request));
-            } else {
-                /* Don't reveal the password in the server-status view */
-                apr_cpystrn(ws->request, apr_pstrcat(r->pool, r->method, " ",
-                            apr_uri_unparse(r->pool, &r->parsed_uri,
-                            APR_URI_UNP_OMITPASSWORD),
-                            r->assbackwards ? NULL : " ", r->protocol, NULL),
-                            sizeof(ws->request));
-            }
+            copy_request(ws->request, sizeof(ws->request), r);
             apr_cpystrn(ws->vhost, r->server->server_hostname,
                         sizeof(ws->vhost));
         }