fixed: dots in url-es (now only one dot is available in the whole name and it cannot be only one dot ".")
added: cmslu can act as an authorizer (fast cgi authorize role) added: Item::static_auth we can have additional static content on the file system this content is authorized through cmslu (fastcgi authorizer mode) changed: some changes in config changed: the way how the www server is using cmslu added new virtuals: static static_auth changed: cmslu returns correct http headers (200, 404, 403) changed: in cookie parser: we get the last cookie (if the server has more than one cookie with the same name) git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@540 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -45,7 +45,8 @@ void Request::Clear()
|
||||
cookie_table.clear();
|
||||
|
||||
method = none;
|
||||
|
||||
role = responder;
|
||||
|
||||
headers.str("");
|
||||
page.str("");
|
||||
debug.str("");
|
||||
@@ -58,6 +59,7 @@ void Request::Clear()
|
||||
env_http_host = &char_empty;
|
||||
env_http_user_agent = &char_empty;
|
||||
env_http_accept_encoding = &char_empty;
|
||||
env_fcgi_role = &char_empty;
|
||||
|
||||
session = 0;
|
||||
|
||||
@@ -97,7 +99,7 @@ void Request::SetCookie(const char * name, const char * value, tm * expires)
|
||||
if( expires )
|
||||
headers << "; expires=" << DateToStrCookie(expires) << " GMT";
|
||||
|
||||
headers << "; path=/\r\n";
|
||||
headers << "; path=/; domain=." << data.base_server << "\r\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +111,7 @@ void Request::SetCookie(const char * name, long value, tm * expires)
|
||||
if( expires )
|
||||
headers << "; expires=" << DateToStrCookie(expires) << " GMT";
|
||||
|
||||
headers << "; path=/\r\n";
|
||||
headers << "; path=/; domain=." << data.base_server << "\r\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -238,6 +240,7 @@ void Request::ReadEnvVariables()
|
||||
env_http_host = SetEnvVar("HTTP_HOST");
|
||||
env_http_user_agent = SetEnvVar("HTTP_USER_AGENT");
|
||||
env_http_accept_encoding = SetEnvVar("HTTP_ACCEPT_ENCODING");
|
||||
env_fcgi_role = SetEnvVar("FCGI_ROLE");
|
||||
}
|
||||
|
||||
|
||||
@@ -268,11 +271,18 @@ void Request::CheckMethod()
|
||||
{
|
||||
method = none;
|
||||
|
||||
if( env_request_method[0] == 'G' )
|
||||
if( ToSmall(env_request_method[0]) == 'g' )
|
||||
method = get;
|
||||
else
|
||||
if( env_request_method[0] == 'P' )
|
||||
if( ToSmall(env_request_method[0]) == 'p' )
|
||||
method = post;
|
||||
|
||||
|
||||
// default we assume 'responder'
|
||||
role = responder;
|
||||
|
||||
if( ToSmall(env_fcgi_role[0]) == 'a' )
|
||||
role = authorizer;
|
||||
}
|
||||
|
||||
|
||||
@@ -310,7 +320,8 @@ void Request::ReadParameters()
|
||||
void Request::StandardLog()
|
||||
{
|
||||
log.PutDate(log1);
|
||||
log << env_remote_addr << ' ' << env_request_method << ' ' << env_request_uri << ' ' << env_http_user_agent << logend;
|
||||
log << env_remote_addr << ' ' << env_request_method << ' ';
|
||||
log << env_http_host << env_request_uri << ' ' << env_http_user_agent << logend;
|
||||
}
|
||||
|
||||
|
||||
@@ -319,10 +330,14 @@ void Request::StandardLog()
|
||||
void Request::Read()
|
||||
{
|
||||
ReadEnvVariables();
|
||||
StandardLog();
|
||||
CheckMethod();
|
||||
StandardLog();
|
||||
ReadParameters();
|
||||
CheckIE();
|
||||
|
||||
if( role == authorizer )
|
||||
log << log3 << "Request: fast cgi role: authorizer" << logend;
|
||||
|
||||
CheckKonqueror();
|
||||
}
|
||||
|
||||
@@ -353,7 +368,7 @@ void Request::SendSessionCookie()
|
||||
}
|
||||
|
||||
|
||||
void Request::SendHeaders(bool compressing)
|
||||
void Request::SendHeaders(bool compressing, Header header)
|
||||
{
|
||||
if( !redirect_to.empty() )
|
||||
{
|
||||
@@ -364,8 +379,25 @@ void Request::SendHeaders(bool compressing)
|
||||
}
|
||||
else
|
||||
{
|
||||
FCGX_PutS("Status: 200 OK\r\n", out);
|
||||
FCGX_PutS("Content-Type: Text/Html\r\n", out);
|
||||
switch(header)
|
||||
{
|
||||
case h_404:
|
||||
FCGX_PutS("Status: 404 Not Found\r\n", out);
|
||||
FCGX_PutS("Content-Type: Text/Html\r\n", out);
|
||||
break;
|
||||
|
||||
case h_403:
|
||||
FCGX_PutS("Status: 403 Forbidden\r\n", out);
|
||||
FCGX_PutS("Content-Type: Text/Html\r\n", out);
|
||||
break;
|
||||
|
||||
default:
|
||||
FCGX_PutS("Status: 200 OK\r\n", out);
|
||||
|
||||
if( role != authorizer )
|
||||
FCGX_PutS("Content-Type: Text/Html\r\n", out);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( compressing )
|
||||
@@ -415,14 +447,25 @@ void Request::SendPage(bool compressing)
|
||||
void Request::SendAll()
|
||||
{
|
||||
bool compressing = data.compression && !browser_msie && !browser_konqueror && accept_encoding_parser.AcceptDeflate();
|
||||
Header header = h_200;
|
||||
|
||||
if( status == Error::db_no_item || status == Error::no_function || status == Error::unknown_param )
|
||||
header = h_404;
|
||||
|
||||
if( status == Error::permision_denied || status == Error::cant_change_user || status == Error::cant_change_group )
|
||||
header = h_403;
|
||||
|
||||
SendSessionCookie();
|
||||
SendHeaders(compressing);
|
||||
SendHeaders(compressing, header);
|
||||
|
||||
if( !redirect_to.empty() )
|
||||
// if there is a redirect we do not send a content
|
||||
return;
|
||||
|
||||
if( header == h_200 && role == authorizer && is_item && item.static_auth != Item::static_none )
|
||||
// if there is an item and the item has 'file' storage we do not send a content
|
||||
return;
|
||||
|
||||
// adding debug info if exists
|
||||
AddDebugInfo();
|
||||
|
||||
|
Reference in New Issue
Block a user