mirror of https://github.com/kiwix/libkiwix.git
Small clean-up
This commit is contained in:
parent
6b8d6232f0
commit
9fd1423100
|
@ -218,11 +218,11 @@ struct CustomizedResourceData
|
||||||
std::string resourceFilePath;
|
std::string resourceFilePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool etag_not_needed(const RequestContext& request)
|
bool responseMustBeETaggedWithLibraryId(const Response& response, const RequestContext& request)
|
||||||
{
|
{
|
||||||
const std::string url = request.get_url();
|
return response.getReturnCode() == MHD_HTTP_OK
|
||||||
return kiwix::startsWith(url, "/skin")
|
&& response.get_kind() == Response::DYNAMIC_CONTENT
|
||||||
|| url == "/random";
|
&& request.get_url() != "/random";
|
||||||
}
|
}
|
||||||
|
|
||||||
ETag
|
ETag
|
||||||
|
@ -528,10 +528,9 @@ MHD_Result InternalServer::handlerCallback(struct MHD_Connection* connection,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response->getReturnCode() == MHD_HTTP_OK
|
if ( responseMustBeETaggedWithLibraryId(*response, request) ) {
|
||||||
&& response->get_kind() == Response::DYNAMIC_CONTENT
|
|
||||||
&& !etag_not_needed(request))
|
|
||||||
response->set_etag_body(getLibraryId());
|
response->set_etag_body(getLibraryId());
|
||||||
|
}
|
||||||
|
|
||||||
auto ret = response->send(request, connection);
|
auto ret = response->send(request, connection);
|
||||||
auto end_time = std::chrono::steady_clock::now();
|
auto end_time = std::chrono::steady_clock::now();
|
||||||
|
|
Loading…
Reference in New Issue