httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject cvs commit: httpd-apreq-2/t cookie.c
Date Sat, 28 Jun 2003 17:51:39 GMT
joes        2003/06/28 10:51:39

  Modified:    glue/perl/xsbuilder/Apache/Cookie Apache__Cookie.h
               glue/perl/xsbuilder/maps apreq_structures.map
               src      apreq.c apreq.h apreq_cookie.c apreq_cookie.h
                        apreq_params.c apreq_params.h
               t        cookie.c
  Log:
  Eliminate codependency between cookie->version and cookie->time by using max_age to
store the cookie's lifetime.
  
  Revision  Changes    Path
  1.10      +15 -13    httpd-apreq-2/glue/perl/xsbuilder/Apache/Cookie/Apache__Cookie.h
  
  Index: Apache__Cookie.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Cookie/Apache__Cookie.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Apache__Cookie.h	27 Jun 2003 18:23:18 -0000	1.9
  +++ Apache__Cookie.h	28 Jun 2003 17:51:38 -0000	1.10
  @@ -113,19 +113,21 @@
       c = apreq_xs_sv2(cookie,ST(0));
   
       if (items > 1) {
  -        apr_pool_t *p = apreq_env_pool(apreq_xs_sv2env(ST(0)));
           const char *s = SvPV_nolen(ST(1));
  -        apreq_cookie_expires(p, c, s);
  +        apreq_cookie_expires(c, s);
       }
   
  -    if (c->version == NETSCAPE)
  -        ST(0) = c->time.expires ? sv_2mortal(newSVpv(c->time.expires,0)) :
  -            &PL_sv_undef;
  -    else
  -        ST(0) = c->time.max_age >= 0 ? sv_2mortal(newSViv(c->time.max_age)) :
  -            &PL_sv_undef;
  +    if (c->max_age == -1)
  +        XSRETURN_UNDEF;
   
  -    XSRETURN(1);
  +    if (c->version == NETSCAPE) {
  +        char expires[APR_RFC822_DATE_LEN] = {0};
  +        apreq_rfc_822_date(expires, c->max_age + apr_time_now());
  +        expires[7] = '-';
  +        expires[11] = '-';
  +        XSRETURN_PV(expires);
  +    }
  +    XSRETURN_IV(c->max_age);
   }
   
   static XS(apreq_xs_cookie_set_attr)
  @@ -142,12 +144,12 @@
       p = apreq_env_pool(apreq_xs_sv2env(ST(0)));
   
       for (j = 1; j + 1 < items; j += 2) {
  -        status = apreq_cookie_attr(p, c, SvPV_nolen(ST(j)), 
  -                                         SvPV_nolen(ST(j+1)));
  +        STRLEN alen, vlen;
  +        const char *attr = SvPV(ST(j),alen), *val = SvPV(ST(j+1),vlen);
  +        status = apreq_cookie_attr(p, c, attr, alen, val, vlen); 
           if (status != APR_SUCCESS)
               break;
       }
  -    ST(0) = sv_2mortal(newSViv(status));
  -    XSRETURN(1);
  +    XSRETURN_IV(status);
   }
   
  
  
  
  1.5       +1 -2      httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_structures.map
  
  Index: apreq_structures.map
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_structures.map,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- apreq_structures.map	24 Jun 2003 22:27:44 -0000	1.4
  +++ apreq_structures.map	28 Jun 2003 17:51:38 -0000	1.5
  @@ -37,13 +37,12 @@
   !  secure
     comment
     commentURL
  -!  time
  +! max_age
   !  v
   </apreq_cookie_t>
   
   <apreq_jar_t MODULE=Apache::Cookie>
   ! cookies
  -!  pool
   !  env
   </apreq_jar_t>
   
  
  
  
  1.23      +3 -3      httpd-apreq-2/src/apreq.c
  
  Index: apreq.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- apreq.c	27 Jun 2003 18:23:18 -0000	1.22
  +++ apreq.c	28 Jun 2003 17:51:38 -0000	1.23
  @@ -130,8 +130,8 @@
       }
   }
   
  -APREQ_DECLARE(char *) apreq_expires(apr_pool_t *p, const char *time_str, 
  -                                    const apreq_expires_t type)
  +APREQ_DECLARE(char *) apreq_expires(apr_pool_t *p, const char *time_str,
  +                                          const apreq_expires_t type)
   {
       apr_time_t when;
       apr_time_exp_t tms;
  @@ -142,7 +142,7 @@
       }
   
       when = apr_time_now();
  -    if ( strcasecmp(time_str,"now") != 0 ) 
  +    if (strcasecmp(time_str,"now")) 
           when += apreq_atoi64t(time_str);
   
       if ( apr_time_exp_gmt(&tms, when) != APR_SUCCESS )
  
  
  
  1.28      +29 -0     httpd-apreq-2/src/apreq.h
  
  Index: apreq.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq.h,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- apreq.h	28 Jun 2003 00:47:57 -0000	1.27
  +++ apreq.h	28 Jun 2003 17:51:38 -0000	1.28
  @@ -316,13 +316,42 @@
   
   APREQ_DECLARE(apr_int64_t) apreq_atoi64t(const char *s);
   
  +/**
  + * Writes brigade to a file.
  + * @param f       File that gets the brigade.
  + * @param wlen    On a successful return, wlen holds the length of
  + *                the brigade, which is the amount of data written to 
  + *                the file.
  + * @param bb      Bucket brigade.
  + * @remark        In the future, this function may do something 
  + *                intelligent with file buckets.
  + */
  +
   APREQ_DECLARE(apr_status_t) apreq_brigade_fwrite(apr_file_t *f,
                                                    apr_off_t *wlen,
                                                    apr_bucket_brigade *bb);
  +/**
  + * Makes a temporary file.
  + * @param fp    Points to the temporary apr_file_t on success.
  + * @param pool  Pool to associate with the temp file.  When the
  + *              pool is destroyed, the temp file will be closed
  + *              and deleted.
  + * @param path  The base directory which will contain the temp file.
  + *              If param == NULL, the directory will be selected via
  + *              tempnam().  See the tempnam manpage for details.
  + */
   
   APREQ_DECLARE(apr_status_t) apreq_file_mktemp(apr_file_t **fp, 
                                                 apr_pool_t *pool,
                                                 const char *path);
  +
  +/**
  + * Gets the spoolfile associated to a brigade, if any.
  + * @param bb Brigade, usually associated to a file upload (apreq_param_t).
  + * @return If the last bucket in the brigade is a file bucket,
  + *         this function will return its associated file.  Otherwise,
  + *         this function returns NULL.
  + */
   
   APREQ_DECLARE(apr_file_t *) apreq_brigade_spoolfile(apr_bucket_brigade *bb);
   
  
  
  
  1.18      +56 -43    httpd-apreq-2/src/apreq_cookie.c
  
  Index: apreq_cookie.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_cookie.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- apreq_cookie.c	27 Jun 2003 18:23:18 -0000	1.17
  +++ apreq_cookie.c	28 Jun 2003 17:51:38 -0000	1.18
  @@ -76,14 +76,18 @@
                      c->v.name,c->v.data);
   }
   
  -APREQ_DECLARE(void) apreq_cookie_expires(apr_pool_t *p,
  -                                         apreq_cookie_t *c, 
  +APREQ_DECLARE(void) apreq_cookie_expires(apreq_cookie_t *c, 
                                            const char *time_str)
   {
  -    if (c->version == NETSCAPE)
  -        c->time.expires = apreq_expires(p, time_str, NSCOOKIE);
  +    if (time_str == NULL) {
  +        c->max_age = -1;
  +        return;
  +    }
  +
  +    if (!strcasecmp(time_str, "now"))
  +        c->max_age = 0;
       else
  -        c->time.max_age = apreq_atoi64t(time_str);
  +        c->max_age = apreq_atoi64t(time_str);
   }
   
   static int has_rfc_cookie(void *ctx, const char *key, const char *val)
  @@ -113,63 +117,70 @@
           return RFC;
   }
   
  -APREQ_DECLARE(apr_status_t) apreq_cookie_attr(apr_pool_t *p,
  -                                              apreq_cookie_t *c, 
  -                                              char *attr,
  -                                              char *val)
  +
  +APREQ_DECLARE(apr_status_t) 
  +    apreq_cookie_attr(apr_pool_t *p, apreq_cookie_t *c, 
  +                      const char *attr, apr_size_t alen,
  +                      const char *val, apr_size_t vlen)
   {
  -    if ( attr[0] ==  '-' || attr[0] == '$' )
  +    if (alen < 2)
  +        return APR_BADARG;
  +
  +    if ( attr[0] ==  '-' || attr[0] == '$' ) {
           ++attr;
  +        --alen;
  +    }
   
       switch (apr_tolower(*attr)) {
   
       case 'n': /* name */
  -        c->v.name = val;
  +        c->v.name = apr_pstrmemdup(p,val,vlen);
           return APR_SUCCESS;
   
       case 'v': /* version */
  -        while (*val && !apr_isdigit(*val))
  +        while (!apr_isdigit(*val)) {
  +            if (vlen == 0)
  +                return APR_BADARG;
               ++val;
  -        if (val) {
  -            c->version = *val - '0';
  -            return APR_SUCCESS;
  -        }
  -        else {
  -            return APR_BADARG;
  +            --vlen;
           }
  +        c->version = *val - '0';
  +        return APR_SUCCESS;
   
       case 'e': case 'm': /* expires, max-age */
  -        apreq_cookie_expires(p, c, val);
  +        apreq_cookie_expires(c, val);
           return APR_SUCCESS;
   
       case 'd':
  -        c->domain = val;
  +        c->domain = apr_pstrmemdup(p,val,vlen);
           return APR_SUCCESS;
   
       case 'p':
  -        if (strcasecmp("port", attr)==0) {
  -            c->port = val;
  +        if (alen != 4)
  +            break;
  +        if (!strcasecmp("port", attr)) {
  +            c->port = apr_pstrmemdup(p,val,vlen);
               return APR_SUCCESS;
           }
  -        else if (strcasecmp("path", attr)==0) {
  -            c->path = val;
  +        else if (!strcasecmp("path", attr)) {
  +            c->path = apr_pstrmemdup(p,val,vlen);
               return APR_SUCCESS;
           }
           break;
   
       case 'c':
  -        if (strcasecmp("comment", attr)==0) {
  -            c->comment = val;
  +        if (alen == 7 && !strcasecmp("comment", attr)) {
  +            c->comment = apr_pstrmemdup(p,val,vlen);
               return APR_SUCCESS;
           } 
  -        else if (strcasecmp("commentURL", attr)==0) {
  -            c->commentURL = val;
  +        else if (alen == 10 && !strcasecmp("commentURL", attr)) {
  +            c->commentURL = apr_pstrmemdup(p,val,vlen);
               return APR_SUCCESS;
           }
           break;
   
       case 's':
  -        c->secure = ( strcasecmp(val,"off")!=0 && *val != '0' );
  +        c->secure = (alen == 2 && !strcasecmp(val,"on"));
           return APR_SUCCESS;
   
       };
  @@ -192,11 +203,7 @@
       c->version = APREQ_COOKIE_VERSION;
   
       /* session cookie is the default */
  -
  -    if (c->version == NETSCAPE)
  -        c->time.expires = NULL;
  -    else
  -        c->time.max_age = -1;
  +    c->max_age = -1;
   
       c->path = NULL;
       c->domain = NULL;
  @@ -295,7 +302,6 @@
               return j;
   
           j = apr_palloc(p, sizeof *j);
  -        j->pool = p;
           j->env = env;
           j->cookies = apr_table_make(p, APREQ_NELTS);
   
  @@ -311,7 +317,6 @@
       }
       else {
           j = apr_palloc(p, sizeof *j);
  -        j->pool = p;
           j->env = env;
           j->cookies = apr_table_make(p, APREQ_NELTS);
       }
  @@ -372,8 +377,7 @@
               status = get_pair(&hdr, &name, &nlen, &value, &vlen);
   
               if (status == APR_SUCCESS)
  -                apreq_cookie_attr(p, c, apr_pstrmemdup(p, name, nlen),
  -                                        apr_pstrmemdup(p,value, vlen));    
  +                apreq_cookie_attr(p, c, name, nlen, value, vlen);    
               else {
                   c->v.status = status;
                   apreq_log(APREQ_WARN c->v.status, env,
  @@ -426,18 +430,27 @@
   
   
       if (c->version == NETSCAPE) {
  -        
  +        char expires[APR_RFC822_DATE_LEN] = {0};
  +
           ADD_ATTR(path);
           ADD_ATTR(domain);
   
  -        strcpy(f, c->time.expires ? "; expires=%s" : "");
  +        if (c->max_age != -1) {
  +            strcpy(f, "; expires=%s");
  +            apr_rfc822_date(expires, c->max_age + apr_time_now());
  +            expires[7] = '-';
  +            expires[11] = '-';
  +        }
  +        else
  +            strcpy(f, "");
  +
           f += strlen(f);
   
           if (c->secure)
               strcpy(f, "; secure");
   
           return apr_snprintf(buf, len, format, c->v.name, c->v.data,
  -           NULL2EMPTY(c->path), NULL2EMPTY(c->domain), c->time.expires);
  +           NULL2EMPTY(c->path), NULL2EMPTY(c->domain), expires);
       }
   
       /* c->version == RFC */
  @@ -453,7 +466,7 @@
   
   #undef ADD_ATTR
   
  -    strcpy(f, c->time.max_age >= 0 ? "; max-age=%" APR_INT64_T_FMT : "");
  +    strcpy(f, c->max_age != -1 ? "; max-age=%" APR_TIME_T_FMT : "");
   
       f += strlen(f);
   
  @@ -463,7 +476,7 @@
       return apr_snprintf(buf, len, format, c->v.name, c->v.data, c->version,
                           NULL2EMPTY(c->path), NULL2EMPTY(c->domain), 
                           NULL2EMPTY(c->port), NULL2EMPTY(c->comment), 
  -                        NULL2EMPTY(c->commentURL), c->time.max_age);
  +                        NULL2EMPTY(c->commentURL), c->max_age);
   }
   
   
  
  
  
  1.18      +22 -17    httpd-apreq-2/src/apreq_cookie.h
  
  Index: apreq_cookie.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_cookie.h,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- apreq_cookie.h	27 Jun 2003 18:23:18 -0000	1.17
  +++ apreq_cookie.h	28 Jun 2003 17:51:38 -0000	1.18
  @@ -77,7 +77,6 @@
   /** Cookie Jar */
   typedef struct apreq_jar_t {
       apr_table_t   *cookies;     /**< cookie table */
  -    apr_pool_t    *pool;        /**< pool cookies were allocated from */
       void          *env;         /**< environment */
   } apreq_jar_t;
   
  @@ -86,24 +85,20 @@
   #define APREQ_COOKIE_VERSION               NETSCAPE
   #define APREQ_COOKIE_LENGTH                4096
   
  +/** cookie XXX ... */
   typedef struct apreq_cookie_t {
   
  -    apreq_cookie_version_t version;
  +    apreq_cookie_version_t version; /**< RFC or Netscape compliant cookie */
   
       char           *path;
  -    char           *domain;
  +    char           *domain; 
       char           *port;
       unsigned        secure;
   
       char           *comment;
       char           *commentURL;
  -
  -    union {
  -        apr_int64_t   max_age; 
  -        const char   *expires; 
  -    } time;
  -
  -    apreq_value_t   v;           /* "raw" value (extended struct) */
  +    apr_time_t      max_age;     /**< total duration of cookie: -1 == session */
  +    apreq_value_t   v;           /**< "raw" cookie value */
   
   } apreq_cookie_t;
   
  @@ -168,11 +163,21 @@
                                     const char *name, const apr_size_t nlen, 
                                     const char *value, const apr_size_t vlen);
   
  -
  -APREQ_DECLARE(apr_status_t) apreq_cookie_attr(apr_pool_t *p,
  -                                              apreq_cookie_t *c, 
  -                                              char *attr,
  -                                              char *val);
  +/**
  + * Sets the associated cookie attribute.
  + * @param p    Pool for allocating the new attribute.
  + * @param c    Cookie.
  + * @param attr Name of attribute- leading '-' or '$' characters
  + *             are ignored.
  + * @param alen Length of attr.
  + * @param val  Value of new attribute.
  + * @param vlen Length of new attribute.
  + * @remarks    Ensures cookie version & time are kept in sync.
  + */
  +APREQ_DECLARE(apr_status_t) 
  +    apreq_cookie_attr(apr_pool_t *p, apreq_cookie_t *c, 
  +                      const char *attr, apr_size_t alen,
  +                      const char *val, apr_size_t vlen);
   
   
   /**
  @@ -207,9 +212,9 @@
    * @param c The cookie.
    * @param time_str If NULL, return the current expiry date. Otherwise
    * replace with this value instead.  The time_str should be in a format
  - * that apreq_atod() can understand, namely /[+-]?\d+\s*[YMDhms]/.
  + * that apreq_atoi64t() can understand, namely /[+-]?\d+\s*[YMDhms]/.
    */
  -APREQ_DECLARE(void) apreq_cookie_expires(apr_pool_t *p, apreq_cookie_t *c, 
  +APREQ_DECLARE(void) apreq_cookie_expires(apreq_cookie_t *c, 
                                            const char *time_str);
   
   /**
  
  
  
  1.27      +8 -10     httpd-apreq-2/src/apreq_params.c
  
  Index: apreq_params.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_params.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- apreq_params.c	27 Jun 2003 19:49:57 -0000	1.26
  +++ apreq_params.c	28 Jun 2003 17:51:38 -0000	1.27
  @@ -61,14 +61,14 @@
   #include "apreq_env.h"
   #include "apr_strings.h"
   
  -#define p2v(param) ( (param) ? &(param)->v : NULL )
  -#define UPGRADE(s) apreq_value_to_param(apreq_char_to_value(s))
  +
  +/** default parser configuration */
   
   static const apreq_cfg_t default_cfg = {
  -    1024 * 1024, /* 1MB */
  -    8192 * 2, 
  -    200, 
  -    8192 * 8
  +    1024 * 1024, /**< limit on POST data size */
  +    8192 * 2,    /**< limit on brigade size */
  +    200,         /**< maximum number of form fields */
  +    8192 * 8     /**< maximum amount of prefetch data */
   };
       
   
  @@ -134,7 +134,6 @@
           req->cfg      = apr_palloc(p, sizeof(apreq_cfg_t));
           req->body     = NULL;
           req->parser   = apreq_parser(env, NULL);
  -        req->pool     = p;
   
           *req->cfg = default_cfg;
           /* XXX need to install copy/merge callbacks for apreq_param_t */
  @@ -157,7 +156,6 @@
           req->cfg      = apr_palloc(p, sizeof(apreq_cfg_t));
           req->body     = NULL;
           req->parser   = apreq_parser(env, NULL);
  -        req->pool     = p;
   
           *req->cfg = default_cfg;
           /* XXX need to install copy/merge callbacks for apreq_param_t */ 
  @@ -176,7 +174,7 @@
       const char *val = apr_table_get(req->args, name);
   
       if (val)
  -        return UPGRADE(val);
  +        return apreq_value_to_param(apreq_strtoval(val));
       else if (req->body == NULL)
           return NULL;
   
  @@ -189,7 +187,7 @@
               val = apr_table_get(req->body, name);
           }
       }
  -    return val ? UPGRADE(val) : NULL;
  +    return val ? apreq_value_to_param(apreq_strtoval(val)) : NULL;
   }
   
   
  
  
  
  1.22      +68 -16    httpd-apreq-2/src/apreq_params.h
  
  Index: apreq_params.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/src/apreq_params.h,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- apreq_params.h	27 Jun 2003 18:23:18 -0000	1.21
  +++ apreq_params.h	28 Jun 2003 17:51:38 -0000	1.22
  @@ -79,37 +79,40 @@
   
   #define APREQ_CHARSET  UTF_8;
   
  +/** Common data structure for params and file uploads */
   typedef struct apreq_param_t {
  -    enum { ASCII, UTF_8, UTF_16, ISO_LATIN_1 } charset;
  -    apr_table_t         *info;
  -    apr_bucket_brigade  *bb;
  -    apreq_value_t        v;
  +    enum { ASCII, UTF_8, UTF_16, ISO_LATIN_1 } charset; /**< Not sure this
  +                                                         * field is needed */
  +    apr_table_t         *info; /**< header table associated with the param */
  +    apr_bucket_brigade  *bb;   /**< brigade to spool upload files */
  +    apreq_value_t        v;    /**< underlying name/value/status info */
   } apreq_param_t;
   
  +/** accessor macros */
   #define apreq_value_to_param(ptr) apreq_attr_to_type(apreq_param_t, v, ptr)
  -#define apreq_param_name(p)  ((p)->v.name)
  -#define apreq_param_value(p) ((p)->v.data)
  -#define apreq_param_info(p) ((p)->info)
  -#define apreq_param_status(p) ((p)->v.status)
  +#define apreq_param_name(p)      ((p)->v.name)
  +#define apreq_param_value(p)     ((p)->v.data)
  +#define apreq_param_info(p)      ((p)->info)
  +#define apreq_param_status(p)    ((p)->v.status)
   
  -/** returns a copy of param->bb */
  +/** yields a copy of param->bb */
   APREQ_DECLARE(apr_bucket_brigade *)
           apreq_param_brigade(const apreq_param_t *param);
   
  +/** creates a param from name/value information */
   APREQ_DECLARE(apreq_param_t *) apreq_make_param(apr_pool_t *p, 
                                                   const char *name, 
                                                   const apr_size_t nlen, 
                                                   const char *val, 
                                                   const apr_size_t vlen);
   
  -
  +/** Structure which manages the request data. */
   typedef struct apreq_request_t {
  -    apr_table_t        *args;         /* query_string */
  -    apr_table_t        *body;         /* post data */
  -    apreq_parser_t     *parser;
  -    apreq_cfg_t        *cfg;
  -    apr_pool_t         *pool;
  -    void               *env;
  +    apr_table_t        *args;         /**< parsed query_string */
  +    apr_table_t        *body;         /**< parsed post data */
  +    apreq_parser_t     *parser;       /**< active parser for this request */
  +    apreq_cfg_t        *cfg;          /**< parser configuration */
  +    void               *env;          /**< request environment */
   } apreq_request_t;
   
   
  @@ -169,24 +172,73 @@
    apreq_join(pool, ", ", apreq_params(req,pool,key), mode)
   
   
  +/**
  + * Url-decodes a name=value pair into a param.
  + * @param pool  Pool from which the param is allocated.
  + * @param word  Start of the name=value pair.
  + * @param nlen  Length of urlencoded name.
  + * @param vlen  Length of urlencoded value.
  + * @remark      Unless vlen == 0, this function assumes there is
  + *              exactly one character ('=') which separates the pair.
  + *            
  + */
   
   APREQ_DECLARE(apreq_param_t *) apreq_decode_param(apr_pool_t *pool, 
                                                     const char *word,
                                                     const apr_size_t nlen, 
                                                     const apr_size_t vlen);
  +/**
  + * Url-encodes the param into a name-value pair.
  + */
   
   APREQ_DECLARE(char *) apreq_encode_param(apr_pool_t *pool, 
                                            const apreq_param_t *param);
   
  +/**
  + * Parse a url-encoded string into a param table.
  + * @param pool    pool used to allocate the param data.
  + * @param table   table to which the params are added.
  + * @param qs      Query string to url-decode.
  + * @remark        This function uses [&;] as the set of tokens
  + *                to delineate words, and will treat a word w/o '='
  + *                as a name-value pair with value-length = 0.
  + *
  + */
  +
   APREQ_DECLARE(apr_status_t) apreq_parse_query_string(apr_pool_t *pool,
                                                        apr_table_t *t, 
                                                        const char *qs);
   
  +/**
  + * Parse a brigade as incoming POST data.
  + * @param req Current request.
  + * @param bb  Brigade to parse. See remarks below.
  + * @return    APR_INCOMPLETE if the parse is incomplete,
  + *            APR_SUCCESS if the parser is finished (saw eos),
  + *            unrecoverable error value otherwise.
  + *
  + * @remark    Polymorphic buckets (file, pipe, socket, etc.)
  + *            will generate new buckets during parsing, which
  + *            may cause problems with the configuration checks.
  + *            To be on the safe side, the caller should avoid
  + *            placing such buckets in the passed brigade.
  + */
  +
   APREQ_DECLARE(apr_status_t)apreq_parse_request(apreq_request_t *req, 
                                                  apr_bucket_brigade *bb);
  +/**
  + * Returns a table of all params in req->body with non-NULL bucket brigades.
  + * @param pool Pool which allocates the table struct.
  + * @param req  Current request.
  + */
   
   APREQ_DECLARE(apr_table_t *) apreq_uploads(apr_pool_t *pool,
                                              const apreq_request_t *req);
  +
  +/**
  + * Returns the first param in req->body which has both param->v.name 
  + * matching key and param->bb != NULL.
  + */
   
   APREQ_DECLARE(apreq_param_t *) apreq_upload(const apreq_request_t *req,
                                               const char *key);
  
  
  
  1.6       +6 -8      httpd-apreq-2/t/cookie.c
  
  Index: cookie.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/t/cookie.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- cookie.c	7 Jun 2003 20:16:23 -0000	1.5
  +++ cookie.c	28 Jun 2003 17:51:38 -0000	1.6
  @@ -108,7 +108,7 @@
       c->path = apr_pstrdup(p, "/quux");
       CuAssertStrEquals(tc, "foo=bar; path=/quux; domain=example.com",
                         apreq_cookie_as_string(p,c));
  -    apreq_cookie_expires(p, c, "+1y");
  +    apreq_cookie_expires(c, "+1y");
       CuAssertStrEquals(tc,apr_pstrcat(p,
                            "foo=bar; path=/quux; domain=example.com; expires=", 
                            apreq_expires(p,"+1y",NSCOOKIE), NULL), apreq_cookie_as_string(p,c));
  @@ -118,12 +118,10 @@
   static void rfc_cookie(CuTest *tc)
   {
       apreq_cookie_t *c = apreq_make_cookie(p,"rfc",3,"out",3);
  -    apreq_cookie_version_t version = RFC;
  -    long expires = apreq_atoi64t("+3m");
  +    long expires; 
   
       CuAssertStrEquals(tc,"out",apreq_cookie_value(c));
  -    c->version = version;
  -    c->time.max_age = -1;
  +    c->version = RFC;
   
       CuAssertStrEquals(tc,"rfc=out; Version=1", apreq_cookie_as_string(p,c));
       c->domain = apr_pstrdup(p, "example.com");
  @@ -135,10 +133,10 @@
                 "rfc=out; Version=1; path=/quux; domain=example.com",
                         apreq_cookie_as_string(p,c));
   
  -
  -    apreq_cookie_expires(p, c, "+3m");
  +    apreq_cookie_expires(c, "+3m");
  +    expires = apreq_atoi64t("+3m");
       CuAssertStrEquals(tc,apr_psprintf(p,
  -         "rfc=out; Version=1; path=/quux; domain=example.com; max-age=%ld", 
  +         "rfc=out; Version=1; path=/quux; domain=example.com; max-age=%ld",
                  expires), apreq_cookie_as_string(p,c));
   
   }
  
  
  

Mime
View raw message