mirror of
https://github.com/YACReader/yacreader
synced 2025-08-15 02:34:59 -04:00
QsLog
YACReader
YACReaderLibrary
comic_vine
db
qml
server
controllers
lib
httpserver
httpconnectionhandler.cpp
httpconnectionhandler.h
httpconnectionhandlerpool.cpp
httpconnectionhandlerpool.h
httpcookie.cpp
httpcookie.h
httpglobal.cpp
httpglobal.h
httplistener.cpp
httplistener.h
httprequest.cpp
httprequest.h
httprequesthandler.cpp
httprequesthandler.h
httpresponse.cpp
httpresponse.h
httpserver.pri
httpsession.cpp
httpsession.h
httpsessionstore.cpp
httpsessionstore.h
staticfilecontroller.cpp
staticfilecontroller.h
logging
templateengine
documentcache.h
requestmapper.cpp
requestmapper.h
server.pri
startup.cpp
startup.h
static.cpp
static.h
yacreader_http_session.cpp
yacreader_http_session.h
yacreader_http_session_store.cpp
yacreader_http_session_store.h
yacreader_server_data_helper.cpp
yacreader_server_data_helper.h
YACReaderLibrary.icns
YACReaderLibrary.pro
add_label_dialog.cpp
add_label_dialog.h
add_library_dialog.cpp
add_library_dialog.h
bundle_creator.cpp
bundle_creator.h
classic_comics_view.cpp
classic_comics_view.h
comic_files_manager.cpp
comic_files_manager.h
comic_flow.cpp
comic_flow.h
comic_flow_widget.cpp
comic_flow_widget.h
comics_remover.cpp
comics_remover.h
comics_view.cpp
comics_view.h
comics_view_transition.cpp
comics_view_transition.h
create_library_dialog.cpp
create_library_dialog.h
current_comic_view_helper.cpp
current_comic_view_helper.h
db_helper.cpp
db_helper.h
empty_container_info.cpp
empty_container_info.h
empty_folder_widget.cpp
empty_folder_widget.h
empty_label_widget.cpp
empty_label_widget.h
empty_reading_list_widget.cpp
empty_reading_list_widget.h
empty_special_list.cpp
empty_special_list.h
export_comics_info_dialog.cpp
export_comics_info_dialog.h
export_library_dialog.cpp
export_library_dialog.h
files.qrc
grid_comics_view.cpp
grid_comics_view.h
icon.ico
icon.rc
icon2.ico
icon3.ico
images.qrc
images_osx.qrc
images_win.qrc
import_comics_info_dialog.cpp
import_comics_info_dialog.h
import_library_dialog.cpp
import_library_dialog.h
import_widget.cpp
import_widget.h
info_comics_view.cpp
info_comics_view.h
library_creator.cpp
library_creator.h
library_window.cpp
library_window.h
main.cpp
no_libraries_widget.cpp
no_libraries_widget.h
no_search_results_widget.cpp
no_search_results_widget.h
options_dialog.cpp
options_dialog.h
package_manager.cpp
package_manager.h
properties_dialog.cpp
properties_dialog.h
qml.qrc
qml_osx.qrc
qml_win.qrc
rename_library_dialog.cpp
rename_library_dialog.h
server_config_dialog.cpp
server_config_dialog.h
yacreader_comic_info_helper.cpp
yacreader_comic_info_helper.h
yacreader_comics_selection_helper.cpp
yacreader_comics_selection_helper.h
yacreader_comics_views_manager.cpp
yacreader_comics_views_manager.h
yacreader_folders_view.cpp
yacreader_folders_view.h
yacreader_history_controller.cpp
yacreader_history_controller.h
yacreader_libraries.cpp
yacreader_libraries.h
yacreader_local_server.cpp
yacreader_local_server.h
yacreader_main_toolbar.cpp
yacreader_main_toolbar.h
yacreader_navigation_controller.cpp
yacreader_navigation_controller.h
yacreader_reading_lists_view.cpp
yacreader_reading_lists_view.h
yacreaderlibrary_de.ts
yacreaderlibrary_es.ts
yacreaderlibrary_fr.ts
yacreaderlibrary_nl.ts
yacreaderlibrary_pt.ts
yacreaderlibrary_ru.ts
yacreaderlibrary_source.ts
yacreaderlibrary_tr.ts
YACReaderLibraryServer
common
compressed_archive
custom_widgets
dependencies
files
images
release
shortcuts_management
tests
.gitignore
CHANGELOG.md
COPYING.txt
INSTALL.md
README.txt
YACReader.1
YACReader.desktop
YACReader.pro
YACReader.svg
YACReaderLibrary.1
YACReaderLibrary.desktop
YACReaderLibrary.svg
background.png
cleanOSX.sh
compileOSX.sh
config.pri
icon.icns
mktarball.sh
releaseOSX.sh
262 lines
5.1 KiB
C++
262 lines
5.1 KiB
C++
/**
|
|
@file
|
|
@author Stefan Frings
|
|
*/
|
|
|
|
#include "httpcookie.h"
|
|
|
|
HttpCookie::HttpCookie()
|
|
{
|
|
version=1;
|
|
maxAge=0;
|
|
secure=false;
|
|
}
|
|
|
|
HttpCookie::HttpCookie(const QByteArray name, const QByteArray value, const int maxAge, const QByteArray path, const QByteArray comment, const QByteArray domain, const bool secure, const bool httpOnly)
|
|
{
|
|
this->name=name;
|
|
this->value=value;
|
|
this->maxAge=maxAge;
|
|
this->path=path;
|
|
this->comment=comment;
|
|
this->domain=domain;
|
|
this->secure=secure;
|
|
this->httpOnly=httpOnly;
|
|
this->version=1;
|
|
}
|
|
|
|
HttpCookie::HttpCookie(const QByteArray source)
|
|
{
|
|
version=1;
|
|
maxAge=0;
|
|
secure=false;
|
|
QList<QByteArray> list=splitCSV(source);
|
|
foreach(QByteArray part, list)
|
|
{
|
|
|
|
// Split the part into name and value
|
|
QByteArray name;
|
|
QByteArray value;
|
|
int posi=part.indexOf('=');
|
|
if (posi)
|
|
{
|
|
name=part.left(posi).trimmed();
|
|
value=part.mid(posi+1).trimmed();
|
|
}
|
|
else
|
|
{
|
|
name=part.trimmed();
|
|
value="";
|
|
}
|
|
|
|
// Set fields
|
|
if (name=="Comment")
|
|
{
|
|
comment=value;
|
|
}
|
|
else if (name=="Domain")
|
|
{
|
|
domain=value;
|
|
}
|
|
else if (name=="Max-Age")
|
|
{
|
|
maxAge=value.toInt();
|
|
}
|
|
else if (name=="Path")
|
|
{
|
|
path=value;
|
|
}
|
|
else if (name=="Secure")
|
|
{
|
|
secure=true;
|
|
}
|
|
else if (name=="HttpOnly")
|
|
{
|
|
httpOnly=true;
|
|
}
|
|
else if (name=="Version")
|
|
{
|
|
version=value.toInt();
|
|
}
|
|
else {
|
|
if (this->name.isEmpty())
|
|
{
|
|
this->name=name;
|
|
this->value=value;
|
|
}
|
|
else
|
|
{
|
|
qWarning("HttpCookie: Ignoring unknown %s=%s",name.data(),value.data());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
QByteArray HttpCookie::toByteArray() const
|
|
{
|
|
QByteArray buffer(name);
|
|
buffer.append('=');
|
|
buffer.append(value);
|
|
if (!comment.isEmpty())
|
|
{
|
|
buffer.append("; Comment=");
|
|
buffer.append(comment);
|
|
}
|
|
if (!domain.isEmpty())
|
|
{
|
|
buffer.append("; Domain=");
|
|
buffer.append(domain);
|
|
}
|
|
if (maxAge!=0)
|
|
{
|
|
buffer.append("; Max-Age=");
|
|
buffer.append(QByteArray::number(maxAge));
|
|
}
|
|
if (!path.isEmpty())
|
|
{
|
|
buffer.append("; Path=");
|
|
buffer.append(path);
|
|
}
|
|
if (secure) {
|
|
buffer.append("; Secure");
|
|
}
|
|
if (httpOnly) {
|
|
buffer.append("; HttpOnly");
|
|
}
|
|
buffer.append("; Version=");
|
|
buffer.append(QByteArray::number(version));
|
|
return buffer;
|
|
}
|
|
|
|
void HttpCookie::setName(const QByteArray name)
|
|
{
|
|
this->name=name;
|
|
}
|
|
|
|
void HttpCookie::setValue(const QByteArray value)
|
|
{
|
|
this->value=value;
|
|
}
|
|
|
|
void HttpCookie::setComment(const QByteArray comment)
|
|
{
|
|
this->comment=comment;
|
|
}
|
|
|
|
void HttpCookie::setDomain(const QByteArray domain)
|
|
{
|
|
this->domain=domain;
|
|
}
|
|
|
|
void HttpCookie::setMaxAge(const int maxAge)
|
|
{
|
|
this->maxAge=maxAge;
|
|
}
|
|
|
|
void HttpCookie::setPath(const QByteArray path)
|
|
{
|
|
this->path=path;
|
|
}
|
|
|
|
void HttpCookie::setSecure(const bool secure)
|
|
{
|
|
this->secure=secure;
|
|
}
|
|
|
|
void HttpCookie::setHttpOnly(const bool httpOnly)
|
|
{
|
|
this->httpOnly=httpOnly;
|
|
}
|
|
|
|
QByteArray HttpCookie::getName() const
|
|
{
|
|
return name;
|
|
}
|
|
|
|
QByteArray HttpCookie::getValue() const
|
|
{
|
|
return value;
|
|
}
|
|
|
|
QByteArray HttpCookie::getComment() const
|
|
{
|
|
return comment;
|
|
}
|
|
|
|
QByteArray HttpCookie::getDomain() const
|
|
{
|
|
return domain;
|
|
}
|
|
|
|
int HttpCookie::getMaxAge() const
|
|
{
|
|
return maxAge;
|
|
}
|
|
|
|
QByteArray HttpCookie::getPath() const
|
|
{
|
|
return path;
|
|
}
|
|
|
|
bool HttpCookie::getSecure() const
|
|
{
|
|
return secure;
|
|
}
|
|
|
|
bool HttpCookie::getHttpOnly() const
|
|
{
|
|
return httpOnly;
|
|
}
|
|
|
|
int HttpCookie::getVersion() const
|
|
{
|
|
return version;
|
|
}
|
|
|
|
QList<QByteArray> HttpCookie::splitCSV(const QByteArray source)
|
|
{
|
|
bool inString=false;
|
|
QList<QByteArray> list;
|
|
QByteArray buffer;
|
|
for (int i=0; i<source.size(); ++i)
|
|
{
|
|
char c=source.at(i);
|
|
if (inString==false)
|
|
{
|
|
if (c=='\"')
|
|
{
|
|
inString=true;
|
|
}
|
|
else if (c==';')
|
|
{
|
|
QByteArray trimmed=buffer.trimmed();
|
|
if (!trimmed.isEmpty())
|
|
{
|
|
list.append(trimmed);
|
|
}
|
|
buffer.clear();
|
|
}
|
|
else
|
|
{
|
|
buffer.append(c);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (c=='\"')
|
|
{
|
|
inString=false;
|
|
}
|
|
else {
|
|
buffer.append(c);
|
|
}
|
|
}
|
|
}
|
|
QByteArray trimmed=buffer.trimmed();
|
|
if (!trimmed.isEmpty())
|
|
{
|
|
list.append(trimmed);
|
|
}
|
|
return list;
|
|
}
|