added: to config: 'content_type_header' parameter
the kind of "Content-Type" header send to the client if utf8 is enabled then 'charset=UTF-8' will also be appended added: to templates: an index pattern for 'rawcontent' used when 'rawcontent' parameter is present by default the template has only one [content] ezc function useful in AJAX requests git-svn-id: svn://ttmath.org/publicrep/winix/trunk@784 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
29
core/app.cpp
29
core/app.cpp
@@ -667,12 +667,35 @@ void App::SendHeadersStatic()
|
||||
}
|
||||
|
||||
|
||||
void App::SendHeaderContentType()
|
||||
{
|
||||
switch( config.content_type_header )
|
||||
{
|
||||
case 1:
|
||||
FCGX_PutS("Content-Type: application/xhtml+xml", fcgi_request.out);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
FCGX_PutS("Content-Type: application/xml", fcgi_request.out);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
FCGX_PutS("Content-Type: text/html", fcgi_request.out);
|
||||
}
|
||||
|
||||
if( config.utf8 )
|
||||
FCGX_PutS("; charset=UTF-8", fcgi_request.out);
|
||||
|
||||
FCGX_PutS("\r\n", fcgi_request.out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void App::SendHeadersForbidden()
|
||||
{
|
||||
FCGX_PutS("Status: 403 Forbidden\r\n", fcgi_request.out);
|
||||
FCGX_PutS("Content-Type: text/html\r\n", fcgi_request.out);
|
||||
SendHeaderContentType();
|
||||
log << log2 << "App: response: 403 Forbidden" << logend;
|
||||
}
|
||||
|
||||
@@ -739,7 +762,7 @@ void App::SendHeadersNormal(Header header)
|
||||
{
|
||||
case h_404:
|
||||
FCGX_PutS("Status: 404 Not Found\r\n", fcgi_request.out);
|
||||
FCGX_PutS("Content-Type: text/html\r\n", fcgi_request.out);
|
||||
SendHeaderContentType();
|
||||
log << log2 << "App: response: 404 Not Found" << logend;
|
||||
break;
|
||||
|
||||
@@ -751,7 +774,7 @@ void App::SendHeadersNormal(Header header)
|
||||
FCGX_PutS("Status: 200 OK\r\n", fcgi_request.out);
|
||||
|
||||
if( cur.request->role != Request::authorizer )
|
||||
FCGX_PutS("Content-Type: text/html\r\n", fcgi_request.out);
|
||||
SendHeaderContentType();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -152,6 +152,7 @@ private:
|
||||
void FilterCompressSend(bool compressing, int compress_encoding, const std::wstring & source_ref);
|
||||
bool SendHeadersStaticCreateResource();
|
||||
void SendHeadersStatic();
|
||||
void SendHeaderContentType();
|
||||
void SendHeadersForbidden();
|
||||
void SendHeadersRedirect();
|
||||
void SendHeadersSendFile();
|
||||
|
@@ -227,6 +227,8 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
|
||||
pattern_cacher_when_delete = Size(L"pattern_cacher_when_delete", 130);
|
||||
pattern_cacher_how_many_delete = Size(L"pattern_cacher_how_many_delete", 30);
|
||||
|
||||
content_type_header = Int(L"content_type_header", 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -245,6 +247,9 @@ void Config::SetAdditionalVariables()
|
||||
|
||||
CheckLocale();
|
||||
CheckPasswd();
|
||||
|
||||
if( content_type_header < 0 || content_type_header > 2 )
|
||||
content_type_header = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -445,8 +445,13 @@ public:
|
||||
size_t pattern_cacher_when_delete;
|
||||
size_t pattern_cacher_how_many_delete;
|
||||
|
||||
|
||||
|
||||
// header "Content-Type" send to the client
|
||||
// 0 - text/html - for HTML
|
||||
// 1 - application/xhtml+xml - for XHTML 1.0
|
||||
// 2 - application/xml - for XHTML 1.0 or for XHTML 1.1
|
||||
// default: 0
|
||||
// if utf8 is true then "; charset=UTF-8" will also be appended
|
||||
int content_type_header;
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user