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: [apreq-2] libapreq_cgi and getenv
Date Mon, 20 Oct 2003 05:17:45 GMT
On Sun, 19 Oct 2003, Stas Bekman wrote:

> Randy Kobes wrote:
> > Hi,
> >    I've been looking at libapreq_cgi, and am having some
> > problems getting cookie data from within a cgi program
> > (which I'll describe in a separate message). I don't know if
> > this is related, but would there be any objection (or harm?)
> > in using, within libapreq_cgi.c, the apr function
> > apr_env_get(), rather than getenv(), as in the following:
>
> +1, apr_env_get is better since it doesn't require running Perl ;) and we use
> it in mp2. It's probably faster as well...
>
> Though since you get a status anyway:
>
>  > s = apr_env_get(&value, "QUERY_STRING", ctx->pool);
>
> it doesn't hurt to check for failure. Probabaly write a macro to avoid noise
> (adopted from mp2):
>
> + #define APREQ_ASSERT(rc_run) do { \
> +         apr_status_t rc = rc_run; \
> +         if (rc != APR_SUCCESS) { \
> +             ap_log_error(APLOG_MARK, APLOG_ERR, rc, NULL, "failed: "); \
> +         } \
> +     } while (0)
> {
> -    return getenv("QUERY_STRING");
> +    dCTX;
> +    char *value;
> +    APREQ_ASSERT(apr_env_get(&value, "QUERY_STRING", ctx->pool));
> +    return value;
>   }
>
> may be a better error message...

Thanks, Stas! That is a good check ...

-- 
best regards,
randy

Mime
View raw message