added: config: base_url_redirect
when true the server checks whether HTTP_HOST environment variable is the same as base_url from the config (of course without the 'http://' part and the last slash) - if it's not the same then the server redirects you into a new location base_url+REQUEST_URI changed: variables env_* from Request are never null (after Request::Read()) if the server didn't set such a variable it will be pointing into an empty string "\0" git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@465 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -109,6 +109,23 @@ return true;
|
||||
|
||||
|
||||
|
||||
bool RequestController::BaseUrlRedirect()
|
||||
{
|
||||
if( request.env_request_uri[0] == 0 )
|
||||
return false;
|
||||
|
||||
if( data.base_url_http_host == request.env_http_host )
|
||||
return false;
|
||||
|
||||
request.result = Request::redirect;
|
||||
request.str = data.base_url + (request.env_request_uri + 1); // +1 means skipping the first slash from env_request_uri
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RequestController::Loop()
|
||||
{
|
||||
while( FCGX_Accept(&request.in, &request.out, &request.err, &request.env) == 0 )
|
||||
@@ -119,13 +136,19 @@ void RequestController::Loop()
|
||||
{
|
||||
request.Clear();
|
||||
request.Read();
|
||||
|
||||
session_manager.SetSession(); // setting request.session as well
|
||||
request.session->CheckTimers();
|
||||
|
||||
content.Make();
|
||||
|
||||
// when BaseUrlRedirect() return true we didn't have to set everything in request.Read()
|
||||
// in the future request.Read() can be split and at the beginning only environment variables will be read
|
||||
// and then BaseUrlRedirect() will be called (for performance)
|
||||
if( !BaseUrlRedirect() )
|
||||
{
|
||||
session_manager.SetSession(); // setting request.session as well
|
||||
request.session->CheckTimers();
|
||||
|
||||
content.Make();
|
||||
}
|
||||
|
||||
request.SendAll();
|
||||
|
||||
}
|
||||
catch(const std::exception & e)
|
||||
{
|
||||
|
Reference in New Issue
Block a user