httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <>
Subject [PROPOSAL] xml-related changes to apreq2
Date Mon, 29 Mar 2004 23:41:22 GMT

One of the biggest shortcomings in apreq2
is in the overuse of the body table in 
apreq_request_t.  It's used as a flag
to mark that parsing has begun (req->body != NULL).
It's also used to hold the parser's output,
which is almost useless when a parser is
working with xml data (or any other data
that's not naturally represented by key=>value

Also there's no simple way to programmically
determine if the query_string was parsed 
successfully, which was brought up on apreq-dev

I'd like to fix apreq_request_t and apreq_parser_t
in a way that minimally impacts on existing code,
but also deals with the issues above.  What I propose
is to change those structs to something like

    struct apreq_request_t {
      apr_table_t        *args;         /**< parsed query_string */
+     unsigned            args_ok :1;   /**< 1 if it parsed successfully */
-     apr_table_t        *body;         /**< parsed post data */
      apreq_parser_t     *parser;       /**< active parser for this request */
      void               *env;          /**< request environment */

    struct apreq_parser_t {
      APREQ_DECLARE_PARSER  (*parser);
      const char             *enctype;
      apreq_hook_t           *hook;
      void                   *ctx;
+     apr_status_t (*it_init) (apr_pool_t *pool, void *ctx, void **iterator);
+     apr_status_t (*it_next) (void *iterator, const char *name, void **elt);
+     apr_status_t (*elt_to_param) (apr_pool_t *p, void *elt,
+                                   const apreq_param_t **param);
+     enum {
+       ERROR       =-1,    /**< may add more specific error types (eg,
+                              bad config, bad data, environment error) */
+       SUCCESS     = 0,    /**< parsing is complete */ 
+       INCOMPLETE  = 1,    /**< parsing is underway */
+       INITIAL     = 2     /**< parsing hasn't begun yet */
+                         }    status; /* public status of parser */
+   };

In so doing I've replaced the req->body table with new hooks in the
parser.  The hooks will provide a simple iterator api together with 
a means of converting the iterated-over elts into apreq_param_t's.  This
additional level of indirection will allow us to continue support for 
the current apreq_param(s)-related APIs by using the iterator api 
internally (instead of searching the old req->body table).

I hope it will also make it much easier to convert existing xml-parsers 
into apreq_parser_t objects: we'll allow the new hooks to remain
unimplemented if a parser author so-chooses.  Such folks can reuse the
libapreq2/mod_apreq infrastructure without necessarily supporting the 
old req->body based API's like apreq_param(s).

Joe Schaefer

View raw message