Added getter for arbitrary environment variables
authorMartin Willi <martin@revosec.ch>
Wed, 17 Nov 2010 15:46:23 +0000 (16:46 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 17 Nov 2010 15:46:23 +0000 (16:46 +0100)
src/libfast/request.c
src/libfast/request.h

index 16c1ae5..89e91b3 100644 (file)
@@ -204,6 +204,14 @@ static char* get_query_data(private_request_t *this, char *name)
 }
 
 /**
+ * Implementation of request_t.get_env_var.
+ */
+static char* get_env_var(private_request_t *this, char *name)
+{
+       return FCGX_GetParam(name, this->req.envp);
+}
+
+/**
  * Implementation of request_t.read_data.
  */
 static int read_data(private_request_t *this, char *buf, int len)
@@ -415,6 +423,7 @@ request_t *request_create(int fd, bool debug)
        this->public.add_cookie = (void(*)(request_t*, char *name, char *value))add_cookie;
        this->public.get_cookie = (char*(*)(request_t*,char*))get_cookie;
        this->public.get_query_data = (char*(*)(request_t*, char *name))get_query_data;
+       this->public.get_env_var = (char*(*)(request_t*, char *name))get_env_var;
        this->public.read_data = (int(*)(request_t*, char*, int))read_data;
        this->public.session_closed = (bool(*)(request_t*))session_closed;
        this->public.close_session = (void(*)(request_t*))close_session;
index 9ca74a9..c9c1f13 100644 (file)
@@ -86,6 +86,14 @@ struct request_t {
        char* (*get_query_data)(request_t *this, char *name);
 
        /**
+        * Get an arbitrary environment variable.
+        *
+        * @param name          name of the environment variable
+        * @return                      value, NULL if not found
+        */
+       char* (*get_env_var)(request_t *this, char *name);
+
+       /**
         * Read raw POST/PUT data from HTTP request.
         *
         * @param buf           buffer to read data into