You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Stas Bekman <st...@stason.org> on 2002/07/01 17:49:03 UTC

[patch mod_example.c] various fixes, mostly docs

a bunch of mod_example improvements, most docs:
- added the missing header_parser_handler
- correct some copy-n-paste errors
- place XXX: where the doc was wrong but I wasn't sure what's the right 
thing to replace with, so those who know can easily spot what should be 
fixed.

of course this module requires much more work.

(i'm afraid that my patch will get wrapped, so I've attached it as well)

Index: modules/experimental/mod_example.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/experimental/mod_example.c,v
retrieving revision 1.40
diff -u -r1.40 mod_example.c
--- modules/experimental/mod_example.c	17 Jun 2002 01:59:32 -0000	1.40
+++ modules/experimental/mod_example.c	1 Jul 2002 15:45:13 -0000
@@ -512,7 +512,7 @@
  /* see.  (See mod_mime's SetHandler and AddHandler directives, and the 
      */
  /* mod_info and mod_status examples, for more details.) 
       */
  /* 
       */
-/* Since content handlers are dumping data directly into the connexion 
      */
+/* Since content handlers are dumping data directly into the connection 
     */
  /* (using the r*() routines, such as rputs() and rprintf()) without 
       */
  /* intervention by other parts of the server, they need to make 
       */
  /* sure any accumulated HTTP headers are sent first.  This is done by 
       */
@@ -877,8 +877,8 @@
  }

  /*
- * This routine is called to perform any module-specific fixing of header
- * fields, et cetera.  It is invoked just before any content-handler.
+ * This routine is called to perform any module-specific log file
+ * openings. It is invoked just before the post_config phase
   *
   * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
   * server will still call any remaining modules with an handler for this
@@ -937,8 +937,7 @@
  }

  /*
- * This routine is called to perform any module-specific fixing of header
- * fields, et cetera.  It is invoked just before any content-handler.
+ * XXX: This routine is called XXX
   *
   * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
   * server will still call any remaining modules with an handler for this
@@ -953,13 +952,12 @@
      /*
       * Log the call and exit.
       */
-    trace_add(r->server, NULL, cfg, "x_post_config()");
+    trace_add(r->server, NULL, cfg, "x_http_method()");
      return "foo";
  }

  /*
- * This routine is called to perform any module-specific fixing of header
- * fields, et cetera.  It is invoked just before any content-handler.
+ * XXX: This routine is called XXX
   *
   * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
   * server will still call any remaining modules with an handler for this
@@ -973,14 +971,13 @@
      /*
       * Log the call and exit.
       */
-    trace_add(r->server, NULL, cfg, "x_post_config()");
+    trace_add(r->server, NULL, cfg, "x_default_port()");
      return 80;
  }
  #endif /*0*/

  /*
- * This routine is called to perform any module-specific fixing of header
- * fields, et cetera.  It is invoked just before any content-handler.
+ * XXX: This routine is called XXX
   *
   * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
   * server will still call any remaining modules with an handler for this
@@ -994,15 +991,11 @@
      /*
       * Log the call and exit.
       */
-    trace_add(r->server, NULL, cfg, "x_post_config()");
+    trace_add(r->server, NULL, cfg, "x_insert_filter()");
  }

  /*
- * XXX fix my comment!!!!!!  this sounds like the comment for a fixup
- *     handler
- *
- * This routine is called to perform any module-specific fixing of header
- * fields, et cetera.  It is invoked just before any content-handler.
+ * XXX: This routine is called XXX
   *
   * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
   * server will still call any remaining modules with an handler for this
@@ -1103,6 +1096,33 @@
  }

  /*
+ * this routine gives our module another chance to examine the request
+ * headers and to take special action. This is the first phase whose
+ * hooks' configuration directives can appear inside the <Directory>
+ * and similar sections, because at this stage the URI has been mapped
+ * to the filename. For example this phase can be used to block evil
+ * clients, while little resources were wasted on these.
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK,
+ * the server will still call any remaining modules with an handler
+ * for this phase.
+ */
+static int x_header_parser_handler(request_rec *r)
+{
+
+    x_cfg *cfg;
+
+    cfg = our_dconfig(r);
+    /*
+     * We don't actually *do* anything here, except note the fact that 
we were
+     * called.
+     */
+    trace_add(r->server, r, cfg, "header_parser_handler()");
+    return DECLINED;
+}
+
+
+/*
   * This routine is called to check the authentication information sent 
with
   * the request (such as looking up the user in a database and 
verifying that
   * the [encrypted] password sent matches the one in the database).
@@ -1278,6 +1298,7 @@
      ap_hook_default_port(x_default_port, NULL, NULL, APR_HOOK_MIDDLE);
  #endif
      ap_hook_translate_name(x_translate_handler, NULL, NULL, 
APR_HOOK_MIDDLE);
+    ap_hook_header_parser(x_header_parser_handler, NULL, NULL, 
APR_HOOK_MIDDLE);
      ap_hook_check_user_id(x_check_user_id, NULL, NULL, APR_HOOK_MIDDLE);
      ap_hook_fixups(x_fixer_upper, NULL, NULL, APR_HOOK_MIDDLE);
      ap_hook_type_checker(x_type_checker, NULL, NULL, APR_HOOK_MIDDLE);


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: [patch mod_example.c] various fixes, mostly docs

Posted by Thomas Eibner <th...@stderr.net>.
On Mon, Jul 01, 2002 at 11:49:03PM +0800, Stas Bekman wrote:
> a bunch of mod_example improvements, most docs:
> - added the missing header_parser_handler
> - correct some copy-n-paste errors
> - place XXX: where the doc was wrong but I wasn't sure what's the right 
> thing to replace with, so those who know can easily spot what should be 
> fixed.
> 
> of course this module requires much more work.

I hear you on that point, anyone interested in a little hacking session
on mod_example?

-- 
  Thomas Eibner <http://thomas.eibner.dk/> DnsZone <http://dnszone.org/>
  mod_pointer <http://stderr.net/mod_pointer> <http://photos.eibner.dk/>
  !(C)<http://copywrong.dk/>                  <http://apachegallery.dk/>
          Putting the HEST in .COM <http://www.hestdesign.com/>