mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
nhttpd: disable range handling for cached content
This commit is contained in:
@@ -301,7 +301,7 @@ std::string CyhookHandler::BuildHeader(bool cache) {
|
|||||||
|
|
||||||
strftime(timeStr, sizeof(timeStr), RFC1123FMT, gmtime(&mod_time));
|
strftime(timeStr, sizeof(timeStr), RFC1123FMT, gmtime(&mod_time));
|
||||||
result += string_printf("Last-Modified: %s\r\n", timeStr);
|
result += string_printf("Last-Modified: %s\r\n", timeStr);
|
||||||
if (status == HANDLED_SENDFILE) {
|
if (status == HANDLED_SENDFILE && !cached) {
|
||||||
result += string_printf("Accept-Ranges: bytes\r\n");
|
result += string_printf("Accept-Ranges: bytes\r\n");
|
||||||
result += string_printf("Content-Length: %lld\r\n", RangeEnd - RangeStart + 1);
|
result += string_printf("Content-Length: %lld\r\n", RangeEnd - RangeStart + 1);
|
||||||
if (httpStatus == HTTP_PARTIAL_CONTENT)
|
if (httpStatus == HTTP_PARTIAL_CONTENT)
|
||||||
|
@@ -135,16 +135,17 @@ public:
|
|||||||
time_t LastModified; // Last Modified Time of Item to send / -1 dynamic content
|
time_t LastModified; // Last Modified Time of Item to send / -1 dynamic content
|
||||||
std::string Sendfile; // Path & Name (local os style) of file to send
|
std::string Sendfile; // Path & Name (local os style) of file to send
|
||||||
bool keep_alive;
|
bool keep_alive;
|
||||||
|
bool cached; // cached by mod_cache
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
CStringList ParamList; // local copy of ParamList (Request)
|
CStringList ParamList; // local copy of ParamList (Request)
|
||||||
CStringList UrlData; // local copy of UrlData (Request)
|
CStringList UrlData; // local copy of UrlData (Request)
|
||||||
CStringList HeaderList; // local copy of HeaderList (Request)
|
CStringList HeaderList; // local copy of HeaderList (Request)
|
||||||
CStringList WebserverConfigList;// Reference (writable) to ConfigList
|
CStringList WebserverConfigList; // Reference (writable) to ConfigList
|
||||||
CStringList HookVarList; // Variables in Hook-Handling passing to other Hooks
|
CStringList HookVarList; // Variables in Hook-Handling passing to other Hooks
|
||||||
THttp_Method Method; // HTTP Method (requested)
|
THttp_Method Method; // HTTP Method (requested)
|
||||||
// constructor & deconstructor
|
// constructor & deconstructor
|
||||||
CyhookHandler(){ContentLength = 0; RangeStart = 0; RangeEnd = -1; keep_alive = 0; _outIndent = 0;status = HANDLED_NONE;Method = M_UNKNOWN;httpStatus = HTTP_NIL;outType = plain;};
|
CyhookHandler(){ContentLength = 0; RangeStart = 0; RangeEnd = -1; cached = false; keep_alive = 0; _outIndent = 0;status = HANDLED_NONE;Method = M_UNKNOWN;httpStatus = HTTP_NIL;outType = plain;};
|
||||||
virtual ~CyhookHandler(){};
|
virtual ~CyhookHandler(){};
|
||||||
|
|
||||||
// hook slot handler
|
// hook slot handler
|
||||||
|
@@ -135,7 +135,7 @@ bool CWebserverResponse::SendResponse() {
|
|||||||
// Send static file
|
// Send static file
|
||||||
if (Connection->HookHandler.status == HANDLED_SENDFILE
|
if (Connection->HookHandler.status == HANDLED_SENDFILE
|
||||||
&& !Connection->RequestCanceled) {
|
&& !Connection->RequestCanceled) {
|
||||||
bool cache = true;
|
bool cache = !Connection->HookHandler.cached;
|
||||||
// if(Connection->HookHandler.UrlData["path"] == "/tmp/")//TODO: un-cachable dirs
|
// if(Connection->HookHandler.UrlData["path"] == "/tmp/")//TODO: un-cachable dirs
|
||||||
// cache = false;
|
// cache = false;
|
||||||
Write(Connection->HookHandler.BuildHeader(cache));
|
Write(Connection->HookHandler.BuildHeader(cache));
|
||||||
|
@@ -32,6 +32,8 @@ THandleStatus CmodCache::Hook_PrepareResponse(CyhookHandler *hh) {
|
|||||||
std::string url = hh->UrlData["fullurl"];
|
std::string url = hh->UrlData["fullurl"];
|
||||||
if (CacheList.find(url) != CacheList.end()) // is in Cache. Rewrite URL or not modified
|
if (CacheList.find(url) != CacheList.end()) // is in Cache. Rewrite URL or not modified
|
||||||
{
|
{
|
||||||
|
hh->cached = true;
|
||||||
|
|
||||||
pthread_mutex_lock(&mutex); // yeah, its mine
|
pthread_mutex_lock(&mutex); // yeah, its mine
|
||||||
|
|
||||||
// Check if modified
|
// Check if modified
|
||||||
@@ -82,6 +84,7 @@ THandleStatus CmodCache::Hook_SendResponse(CyhookHandler *hh) {
|
|||||||
{
|
{
|
||||||
AddToCache(hh, url, hh->yresult, hh->HookVarList["CacheMimeType"],
|
AddToCache(hh, url, hh->yresult, hh->HookVarList["CacheMimeType"],
|
||||||
category); // create cache file and add to cache list
|
category); // create cache file and add to cache list
|
||||||
|
hh->cached = true;
|
||||||
hh->ContentLength = (hh->yresult).length();
|
hh->ContentLength = (hh->yresult).length();
|
||||||
hh->RangeEnd = (hh->yresult).length()-1;
|
hh->RangeEnd = (hh->yresult).length()-1;
|
||||||
hh->SendFile(CacheList[url].filename); // Send as file
|
hh->SendFile(CacheList[url].filename); // Send as file
|
||||||
|
Reference in New Issue
Block a user