httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [apreq-2] libapreq_cgi and getenv
Date Mon, 20 Oct 2003 03:46:39 GMT
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...

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Mime
View raw message