Reintroduce to_referer(), redirect() does not work with get_referer()

This commit is contained in:
Martin Willi
2010-04-28 09:03:08 +02:00
parent 69e492f2e2
commit 40fb7165a9
2 changed files with 25 additions and 0 deletions
+20
View File
@@ -244,6 +244,25 @@ 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)
{
char *referer;
referer = get_referer(this);
if (referer)
{
FCGX_FPrintF(this->req.out, "Status: 303 See Other\n");
FCGX_FPrintF(this->req.out, "Location: %s\n\n", referer);
}
else
{
redirect(this, "/");
}
}
/**
* Implementation of request_t.session_closed.
*/
@@ -392,6 +411,7 @@ request_t *request_create(int fd, bool debug)
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;
this->public.serve = (void(*)(request_t*,char*,chunk_t))serve;
+5
View File
@@ -112,6 +112,11 @@ struct request_t {
*/
char* (*get_referer)(request_t *this);
/**
* Redirect back to the referer.
*/
void (*to_referer)(request_t *this);
/**
* Set a template value.
*