httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <joe+apa...@sunstarsys.com>
Subject Re: cvs commit: httpd-apreq-2/env/t/cgi-bin .cvsignore
Date Fri, 24 Oct 2003 04:38:27 GMT
randyk@apache.org writes:

> randyk      2003/10/23 16:58:15
> 
>   Modified:    env      Makefile.am .cvsignore
>   Added:       env      test_cgi.c
>                env/t    cgi.t
>                env/t/conf extra.conf.in
>                env/t/cgi-bin .cvsignore
>   Log:
>   add libapreq_cgi tests.

After the Marlins big win tonight, I had some problems running the
tests with apr's current cvs- apr_env_get's behavior may have changed
slightly, and I was getting segfaults on cgi tests 1-9. Initializing
value = NULL took care of those.  Also test 22 uses GET_BODY with a
"Content" argument; I'm not sure if that's legit or not, so I changed
it to POST_BODY.

The last criticism is that we should eventually get rid of the 
env_ctx struct in test_cgi.c, and use a static global variable in 
libapreq_cgi instead.  There's no natural candidate for "env" in a cgi
context, so IMO we should probably ignore all the "env" arguments and
let users put anything they like in that slot.

Anyways, for now here's the diff from env/ that fixes the segfaults.
Let me know if it works ok.

Index: libapreq_cgi.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/env/libapreq_cgi.c,v
retrieving revision 1.13
diff -u -r1.13 libapreq_cgi.c
--- libapreq_cgi.c	21 Oct 2003 19:31:47 -0000	1.13
+++ libapreq_cgi.c	24 Oct 2003 04:22:27 -0000
@@ -122,7 +122,7 @@
 {
     dCTX;
     char *key = apr_pstrdup(ctx->pool, name);
-    char *k, *value, *http_key, http[] = "HTTP_";
+    char *k, *value=NULL, *http_key, http[] = "HTTP_";
     for (k = key; *k; ++k) {
         if (*k == '-')
             *k = '_';
Index: test_cgi.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/env/test_cgi.c,v
retrieving revision 1.3
diff -u -r1.3 test_cgi.c
--- test_cgi.c	23 Oct 2003 23:58:14 -0000	1.3
+++ test_cgi.c	24 Oct 2003 04:22:27 -0000
@@ -61,14 +61,14 @@
 #include "apr_lib.h"
 #include "apr_tables.h"
 
-typedef struct {
+struct env_ctx {
     apr_pool_t         *pool;
     apreq_request_t    *req;
     apreq_jar_t        *jar;
     apr_bucket_brigade *bb;
     int                 loglevel;
     apr_status_t        status;
-} env_ctx;
+};
 
 static int dump_table(void *count, const char *key, const char *value)
 {
@@ -80,7 +80,7 @@
 
 int main(int argc, char const * const * argv)
 {
-    env_ctx *ctx;
+    struct env_ctx *ctx;
     apr_pool_t *pool;
     const apreq_param_t *foo, *bar, *test, *key;
     apr_table_t *params;
@@ -103,7 +103,7 @@
         exit(-1);
     }
 
-    ctx = (env_ctx *) apr_palloc(pool, sizeof(*ctx));
+    ctx = (struct env_ctx *) apr_pcalloc(pool, sizeof *ctx);
     ctx->loglevel = 0;
     ctx->pool = pool;
     apreq_log(APREQ_DEBUG 0, ctx, "%s", "Creating apreq_request");
Index: t/cgi.t
===================================================================
RCS file: /home/cvs/httpd-apreq-2/env/t/cgi.t,v
retrieving revision 1.1
diff -u -r1.1 cgi.t
--- t/cgi.t	23 Oct 2003 23:58:15 -0000	1.1
+++ t/cgi.t	24 Oct 2003 04:22:28 -0000
@@ -68,7 +68,7 @@
 }
 
 ok t_cmp("\tfoo => 1$line_end", 
-         GET_BODY("$script?foo=1", Content => $filler));
+         POST_BODY("$script?foo=1", Content => $filler), "simple post");
 
 ok t_cmp("\tfoo => ?$line_end\tbar => hello world$line_end", 
          GET_BODY("$script?foo=%3F&bar=hello+world"), "simple get");

-- 
Joe Schaefer

Mime
View raw message