httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <joe+gm...@sunstarsys.com>
Subject Re: [apreq-2] posting with libapreq_cgi
Date Mon, 20 Oct 2003 16:37:23 GMT
Randy Kobes <randy@theoryx5.uwinnipeg.ca> writes:

[...]

> Examining what goes wrong shows that the last key=value pair of $query
> isn't being picked up. I think this is related to the apreq_env_read
> sub of libapreq_cgi:

True- apreq parsers only finish their work when either an eos bucket
shows up,  or when a parsing error occurs (bad data).  For libapreq_cgi,
apreq_env_read may need to track the bytes seen against the
content-length header, and insert the eos bucket when the full amount is
read. 

[...]

> ===============================================================
> If an eos bucket is inserted at the end of the ctx->bb brigade,
> as in
> ================================================================
> Index: libapreq_cgi.c
> ===================================================================
> RCS file: /home/cvs/httpd-apreq-2/env/libapreq_cgi.c,v
> retrieving revision 1.11
> diff -u -r1.11 libapreq_cgi.c
> --- libapreq_cgi.c	20 Oct 2003 05:25:14 -0000	1.11
> +++ libapreq_cgi.c	20 Oct 2003 05:57:31 -0000
> @@ -187,12 +187,14 @@
>      if (ctx->bb == NULL) {
>          apr_bucket_alloc_t *alloc = apr_bucket_alloc_create(ctx->pool);
>          apr_file_t *in;
> -        apr_bucket *stdin_pipe;
> +        apr_bucket *stdin_pipe, *b;
> 
>          ctx->bb = apr_brigade_create(ctx->pool, alloc);
>          apr_file_open_stdin(&in, ctx->pool);
>          stdin_pipe = apr_bucket_pipe_create(in,alloc);
>          APR_BRIGADE_INSERT_HEAD(ctx->bb, stdin_pipe);
> +        b = apr_bucket_eos_create(alloc);
> +        APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
>      }
> 
>      return apreq_parse_request(apreq_request(env,NULL), ctx->bb);
> ===================================================================

Nice job, +1.

> then the tests with and without the filler succeed. What
> I was wondering is if the insertion of the eos bucket at the
> end should be done?

Yes, since the pipe bucket doesn't generate one.  OTOH, with this 
we're assuming the server will send an eof after reading Content-Length
bytes.  I guess Apache does this, although the CGI spec doesn't
mandate it. Documenting that assumption somewhere within the source
might be a good idea.

> 
> Although this may fix this problem, I'm not sure if it's the
> right thing in general. Trying one of the cookie tests
> ====================================================================
>     my $test  = 'netscape';
>     my $key   = 'apache';
>     my $value = 'ok';
>     my $cookie = qq{$key=$value};
>     ok t_cmp($value,
>              GET_BODY("$script?test=$test&key=$key", Cookie => $cookie),
>              $test);
> =====================================================================
> results in a failure, with or without the eos insertion patch
> above. A trace shows that a "Cookie" header is being found, but
> there's no data associated with it. However, this may be
> an unrelated problem ... Thanks.

I'm sure it's unrelated.  I made no attempt to do anything sane
with libapreq_cgi.c, so take you best whack at it (Taking a look
at the source, it appears I conflated "env" and "ctx" here and 
there. I'm somewhat surprised it even compiles).

-- 
Joe Schaefer


Mime
View raw message