Add a getter for the HTTP referer
authorMartin Willi <martin@revosec.ch>
Tue, 9 Mar 2010 14:03:57 +0000 (15:03 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 10 Mar 2010 14:09:12 +0000 (15:09 +0100)
src/libfast/request.c
src/libfast/request.h

index 3f4894c..0f743e3 100644 (file)
@@ -232,6 +232,14 @@ static void redirect(private_request_t *this, char *fmt, ...)
 }
 
 /**
+ * Implementation of request_t.get_referer.
+ */
+static char* get_referer(private_request_t *this)
+{
+       return FCGX_GetParam("HTTP_REFERER", this->req.envp);
+}
+
+/**
  * Implementation of request_t.to_referer.
  */
 static void to_referer(private_request_t *this)
@@ -396,6 +404,7 @@ request_t *request_create(int fd, bool debug)
        this->public.session_closed = (bool(*)(request_t*))session_closed;
        this->public.close_session = (void(*)(request_t*))close_session;
        this->public.redirect = (void(*)(request_t*, char *fmt,...))redirect;
+       this->public.get_referer = (char*(*)(request_t*))get_referer;
        this->public.to_referer = (void(*)(request_t*))to_referer;
        this->public.render = (void(*)(request_t*,char*))render;
        this->public.streamf = (int(*)(request_t*, char *format, ...))streamf;
index 61e2d59..dd3b568 100644 (file)
@@ -106,6 +106,13 @@ struct request_t {
        void (*redirect)(request_t *this, char *fmt, ...);
 
        /**
+        * Get the HTTP referer.
+        *
+        * @return                      HTTP referer
+        */
+       char* (*get_referer)(request_t *this);
+
+       /**
         * Redirect the client to the referer.
         */
        void (*to_referer)(request_t *this);