httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <ra...@theoryx5.uwinnipeg.ca>
Subject Re: cvs commit: httpd-apreq-2/env/t/cgi-bin .cvsignore
Date Fri, 24 Oct 2003 21:55:44 GMT
On Fri, 24 Oct 2003, Joe Schaefer wrote:

> Joe Schaefer <joe+apache@sunstarsys.com> writes:
>
> [...]
>
> > 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.
>
> After looking some more at test_cgi.c, there *is* one natural
> candidate there for an "env"- the pool!  Here's the (longish) patch
> to libapreq_cgi.c and test_cgi.c that implements the above- let me
> know if it's ok to commit (all cgi tests still pass).

I'll look at this over the weekend on my Win32 machine, but
it looks fine, so please, go ahead - using the pool as the
env is more natural in this context ... I have one question
below related to

> Index: env/libapreq_cgi.c
> ===================================================================
> RCS file: /home/cvs/httpd-apreq-2/env/libapreq_cgi.c,v
> retrieving revision 1.14
> diff -u -r1.14 libapreq_cgi.c
[ ... ]
>  APREQ_DECLARE(const char *)apreq_env_header_in(void *env,
>                                                 const char *name)
>  {
> -    dCTX;
> -    char *key = apr_pstrdup(ctx->pool, name);
> -    char *k, *value=NULL, *http_key, http[] = "HTTP_";
> +    dP;
> +    char *key = apr_pstrcat(p, "HTTP_", name, NULL);
> +    char *k, *value = NULL;
>      for (k = key; *k; ++k) {
>          if (*k == '-')
>              *k = '_';
> @@ -130,67 +128,63 @@
>              *k = apr_toupper(*k);
>      }
>
> -    if (!strcmp(key, "CONTENT_TYPE") || !strcmp(key, "CONTENT_LENGTH")) {
> -        APREQ_ENV_STATUS(apr_env_get(&value, key, ctx->pool), key);
> -    }
> -    else {
> -        http_key = (char *) apr_palloc(ctx->pool, sizeof(http) + strlen(key));
> -        http_key = strcat(strcpy(http_key, http), key);
> -        APREQ_ENV_STATUS(apr_env_get(&value, http_key, ctx->pool), http_key);
> +    if (!strcmp(key, "HTTP_CONTENT_TYPE")
> +        || !strcmp(key, "HTTP_CONTENT_LENGTH")) {
> +
> +        key += 5; /* strlen("HTTP_") */
>      }
>
> +    APREQ_ENV_STATUS(apr_env_get(&value, key, p), key);
> +
>      return value;
>  }

If I understand this correctly, HTTP_ is being prepended to
the "name" being passed in ... What I had before (which may
well have been wrong) was HTTP_ being prepended except for
CONTENT_TYPE or CONTENT_LENGTH - this I inferred from the
util_script.c under httpd-2.0.47/server/, in the
ap_add_common_vars() sub, where http2env() is called (to
prepend HTTP_) except for Content-Type and Content-Length
(and a couple of others). But maybe I'm not interpreting
this right? Thanks.

-- 
best regards,
randy

Mime
View raw message