|
|
|
@ -711,6 +711,22 @@ void App::LogEnvironmentVariables()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void App::LogEnvironmentHTTPVariables()
|
|
|
|
|
{
|
|
|
|
|
PT::Space::Table::iterator i = cur.request->headers_in.table.begin();
|
|
|
|
|
|
|
|
|
|
for( ; i != cur.request->headers_in.table.end() ; ++i)
|
|
|
|
|
{
|
|
|
|
|
log << log1 << "HTTP Env: " << i->first << "=";
|
|
|
|
|
|
|
|
|
|
if( i->second.size() == 1 )
|
|
|
|
|
log << i->second[0] << logend;
|
|
|
|
|
else
|
|
|
|
|
log << "(incorrect value table size, should be one but is " << i->second.size() << ")" << logend;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* reading the request (without GET parameters in the URL)
|
|
|
|
@ -724,6 +740,7 @@ void App::ReadRequest()
|
|
|
|
|
SetSubdomain();
|
|
|
|
|
|
|
|
|
|
LogAccess();
|
|
|
|
|
ReadEnvHTTPVariables();
|
|
|
|
|
|
|
|
|
|
ReadPostVars();
|
|
|
|
|
|
|
|
|
@ -733,6 +750,9 @@ void App::ReadRequest()
|
|
|
|
|
if( config.log_env_variables )
|
|
|
|
|
LogEnvironmentVariables();
|
|
|
|
|
|
|
|
|
|
if( config.log_env_http_variables )
|
|
|
|
|
LogEnvironmentHTTPVariables();
|
|
|
|
|
|
|
|
|
|
CheckIE();
|
|
|
|
|
CheckKonqueror();
|
|
|
|
|
|
|
|
|
@ -759,17 +779,102 @@ void App::ReadEnvVariables()
|
|
|
|
|
{
|
|
|
|
|
SetEnv("REQUEST_METHOD", cur.request->env_request_method);
|
|
|
|
|
SetEnv("REQUEST_URI", cur.request->env_request_uri);
|
|
|
|
|
SetEnv("HTTP_COOKIE", cur.request->env_http_cookie);
|
|
|
|
|
SetEnv("REMOTE_ADDR", cur.request->env_remote_addr);
|
|
|
|
|
SetEnv("HTTP_HOST", cur.request->env_http_host);
|
|
|
|
|
SetEnv("HTTP_USER_AGENT", cur.request->env_http_user_agent);
|
|
|
|
|
SetEnv("FCGI_ROLE", cur.request->env_fcgi_role);
|
|
|
|
|
SetEnv("CONTENT_TYPE", cur.request->env_content_type);
|
|
|
|
|
SetEnv("HTTP_ACCEPT_ENCODING", cur.request->env_http_accept_encoding);
|
|
|
|
|
SetEnv("HTTPS", cur.request->env_https);
|
|
|
|
|
|
|
|
|
|
SetEnv("HTTP_HOST", cur.request->env_http_host);
|
|
|
|
|
SetEnv("HTTP_USER_AGENT", cur.request->env_http_user_agent);
|
|
|
|
|
SetEnv("HTTP_COOKIE", cur.request->env_http_cookie);
|
|
|
|
|
SetEnv("HTTP_ACCEPT_ENCODING", cur.request->env_http_accept_encoding);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// reading from fastcgi env
|
|
|
|
|
void App::ReadEnvHTTPVariables()
|
|
|
|
|
{
|
|
|
|
|
const char http_prefix[] = "HTTP_";
|
|
|
|
|
size_t http_prefix_len = sizeof(http_prefix) / sizeof(char) - 1; // 1 means terminating null character
|
|
|
|
|
size_t http_headers_saved = 0;
|
|
|
|
|
|
|
|
|
|
for(char ** e = fcgi_request.envp ; *e && http_headers_saved < Request::MAX_INPUT_HEADERS ; ++e)
|
|
|
|
|
{
|
|
|
|
|
char * env = *e;
|
|
|
|
|
|
|
|
|
|
if( IsSubStringNoCasep("HTTP_", env) )
|
|
|
|
|
{
|
|
|
|
|
env += http_prefix_len;
|
|
|
|
|
|
|
|
|
|
// cookies we have in a different table
|
|
|
|
|
if( !IsSubStringNoCasep("COOKIE=", env) )
|
|
|
|
|
{
|
|
|
|
|
if( SaveEnvHTTPVariable(env) )
|
|
|
|
|
{
|
|
|
|
|
http_headers_saved += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( http_headers_saved == Request::MAX_INPUT_HEADERS )
|
|
|
|
|
{
|
|
|
|
|
log << log4 << "App: the maximum number of HTTP headers has been reached, skipping the rest" << logend;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* headers in fcgi are in the form of name=value
|
|
|
|
|
*/
|
|
|
|
|
bool App::SaveEnvHTTPVariable(const char * env)
|
|
|
|
|
{
|
|
|
|
|
// CHECK ME may move to a better place? Request::INPUT_HEADER_VALUE_MAX_LENGTH is a high value
|
|
|
|
|
char header_name[Request::INPUT_HEADER_NAME_MAX_LENGTH + 1];
|
|
|
|
|
char header_value[Request::INPUT_HEADER_VALUE_MAX_LENGTH + 1];
|
|
|
|
|
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
|
|
for( ; env[i] != 0 && env[i] != '=' && i < Request::INPUT_HEADER_NAME_MAX_LENGTH ; ++i)
|
|
|
|
|
{
|
|
|
|
|
header_name[i] = ToSmall(env[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header_name[i] = 0;
|
|
|
|
|
|
|
|
|
|
if( env[i] != '=' )
|
|
|
|
|
{
|
|
|
|
|
// too long header name, skipping
|
|
|
|
|
log << log4 << "App: skipped HTTP header \"" << env << "\" because the header name is too long" << logend;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i += 1; // skipping '=' character
|
|
|
|
|
size_t h = 0;
|
|
|
|
|
|
|
|
|
|
for( ; env[i] != 0 && h < Request::INPUT_HEADER_VALUE_MAX_LENGTH ; ++i, ++h)
|
|
|
|
|
{
|
|
|
|
|
header_value[h] = env[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header_value[h] = 0;
|
|
|
|
|
|
|
|
|
|
if( env[i] != 0 )
|
|
|
|
|
{
|
|
|
|
|
// too long header value, skipping
|
|
|
|
|
log << log4 << "App: skipped HTTP header \"" << env << "\" because the header value is too long" << logend;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PT::UTF8ToWide(header_name, http_header);
|
|
|
|
|
|
|
|
|
|
std::wstring & inserted_header = cur.request->headers_in.Add(http_header, L"", true);
|
|
|
|
|
PT::UTF8ToWide(header_value, inserted_header);
|
|
|
|
|
http_header.clear();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void App::ReadEnvRemoteIP()
|
|
|
|
|
{
|
|
|
|
@ -798,6 +903,9 @@ void App::CheckRequestMethod()
|
|
|
|
|
else
|
|
|
|
|
if( ToSmall(cur.request->env_request_method[0]) == 'h' )
|
|
|
|
|
cur.request->method = Request::head;
|
|
|
|
|
else
|
|
|
|
|
if( ToSmall(cur.request->env_request_method[0]) == 'd' )
|
|
|
|
|
cur.request->method = Request::delete_;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|