mirror of
https://github.com/YACReader/yacreader
synced 2025-07-14 11:04:25 -04:00
Move from session based state to client side tokens.
YACReaderHttpSession is still used, but it is not a http session anymore.
This commit is contained in:
@ -17,10 +17,16 @@
|
||||
ComicControllerV2::ComicControllerV2() {}
|
||||
|
||||
void ComicControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(session.getId());
|
||||
|
||||
{
|
||||
QByteArray token = request.getHeader("x-request-id");
|
||||
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(token);
|
||||
|
||||
if (ySession == nullptr) {
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
return;
|
||||
}
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
qulonglong libraryId = pathElements.at(3).toLongLong();
|
||||
@ -45,9 +51,6 @@ void ComicControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryId, comicId);
|
||||
|
||||
if(!remoteComic)
|
||||
ySession->setDownloadedComic(comic.info.hash);
|
||||
|
||||
Comic * comicFile = FactoryComic::newComic(libraries.getPath(libraryId)+comic.path);
|
||||
|
||||
if(comicFile != NULL)
|
||||
|
@ -10,9 +10,6 @@ CoverControllerV2::CoverControllerV2() {}
|
||||
|
||||
void CoverControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(session.getId());
|
||||
|
||||
response.setHeader("Content-Type", "image/jpeg");
|
||||
response.setHeader("Connection","close");
|
||||
//response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||
@ -24,8 +21,6 @@ void CoverControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
QString libraryName = DBHelper::getLibraryName(pathElements.at(3).toInt());
|
||||
QString fileName = pathElements.at(5);
|
||||
|
||||
bool folderCover = request.getParameter("folderCover").length()>0;
|
||||
|
||||
//response.writeText(path+"<br/>");
|
||||
//response.writeText(libraryName+"<br/>");
|
||||
//response.writeText(libraries.value(libraryName)+"/.yacreaderlibrary/covers/"+fileName+"<br/>");
|
||||
|
@ -11,8 +11,6 @@ LibrariesControllerV2::LibrariesControllerV2() {}
|
||||
|
||||
void LibrariesControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Connection","close");
|
||||
|
||||
|
@ -16,10 +16,16 @@
|
||||
PageControllerV2::PageControllerV2() {}
|
||||
|
||||
void PageControllerV2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(session.getId());
|
||||
|
||||
{
|
||||
QByteArray token = request.getHeader("x-request-id");
|
||||
YACReaderHttpSession *ySession = Static::yacreaderSessionStore->getYACReaderSessionHttpSession(token);
|
||||
|
||||
if (ySession == nullptr) {
|
||||
response.setStatus(404,"not found");
|
||||
response.write("404 not found",true);
|
||||
return;
|
||||
}
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
bool remote = path.endsWith("remote");
|
||||
|
||||
|
@ -15,8 +15,6 @@ UpdateComicControllerV2::UpdateComicControllerV2(){}
|
||||
|
||||
void UpdateComicControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
qulonglong libraryId = pathElements.at(3).toULongLong();
|
||||
|
Reference in New Issue
Block a user