SDRAngel
4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
|
#include <httpsessionstore.h>
Inherits QObject.
Public Member Functions | |
HttpSessionStore (QSettings *settings, QObject *parent=NULL) | |
HttpSessionStore (const HttpSessionsSettings &settings, QObject *parent=NULL) | |
virtual | ~HttpSessionStore () |
QByteArray | getSessionId (HttpRequest &request, HttpResponse &response) |
HttpSession | getSession (HttpRequest &request, HttpResponse &response, bool allowCreate=true) |
HttpSession | getSession (const QByteArray id) |
void | removeSession (HttpSession session) |
HttpSessionsSettings | getListenerSettings () const |
void | setListenerSettings (const HttpSessionsSettings &settings) |
Protected Attributes | |
QMap< QByteArray, HttpSession > | sessions |
Private Slots | |
void | sessionTimerEvent () |
Private Attributes | |
QSettings * | settings |
HttpSessionsSettings | sessionsSettings |
QTimer | cleanupTimer |
QByteArray | cookieName |
int | expirationTime |
QMutex | mutex |
bool | useQtSettings |
Stores HTTP sessions and deletes them when they have expired. The following configuration settings are required in the config file:
expirationTime=3600000 cookieName=sessionid
The following additional configurations settings are optionally:
cookiePath=/ cookieComment=Session ID ;cookieDomain=stefanfrings.de
Definition at line 38 of file httpsessionstore.h.
HttpSessionStore::HttpSessionStore | ( | QSettings * | settings, |
QObject * | parent = NULL |
||
) |
Constructor with Qt settings.
Definition at line 13 of file httpsessionstore.cpp.
References cleanupTimer, cookieName, expirationTime, sessionTimerEvent(), and settings.
HttpSessionStore::HttpSessionStore | ( | const HttpSessionsSettings & | settings, |
QObject * | parent = NULL |
||
) |
Constructor with settings structure.
Definition at line 24 of file httpsessionstore.cpp.
References cleanupTimer, qtwebapp::HttpSessionsSettings::cookieName, cookieName, qtwebapp::HttpSessionsSettings::expirationTime, expirationTime, sessionsSettings, sessionTimerEvent(), and settings.
|
virtual |
|
inline |
Get a sessions settings copy
Definition at line 91 of file httpsessionstore.h.
HttpSession HttpSessionStore::getSession | ( | HttpRequest & | request, |
HttpResponse & | response, | ||
bool | allowCreate = true |
||
) |
Get the session of a HTTP request, eventually create a new one. This method is thread safe. New sessions can only be created before the first byte has been written to the HTTP response.
request | Used to get the session cookie |
response | Used to get and set the new session cookie |
allowCreate | can be set to false, to disable the automatic creation of a new session. |
Definition at line 64 of file httpsessionstore.cpp.
References qtwebapp::HttpSessionsSettings::cookieComment, qtwebapp::HttpSessionsSettings::cookieDomain, qtwebapp::HttpSessionsSettings::cookieName, cookieName, qtwebapp::HttpSessionsSettings::cookiePath, expirationTime, qtwebapp::HttpSession::getId(), getSessionId(), qtwebapp::HttpSession::isNull(), mutex, sessions, sessionsSettings, qtwebapp::HttpResponse::setCookie(), qtwebapp::HttpSession::setLastAccess(), settings, and useQtSettings.
HttpSession HttpSessionStore::getSession | ( | const QByteArray | id | ) |
Get a HTTP session by it's ID number. This method is thread safe.
id | ID number of the session |
Definition at line 103 of file httpsessionstore.cpp.
References mutex, sessions, and qtwebapp::HttpSession::setLastAccess().
QByteArray HttpSessionStore::getSessionId | ( | HttpRequest & | request, |
HttpResponse & | response | ||
) |
Get the ID of the current HTTP session, if it is valid. This method is thread safe.
request | Used to get the session cookie |
response | Used to get and set the new session cookie |
Definition at line 40 of file httpsessionstore.cpp.
References cookieName, qtwebapp::HttpRequest::getCookie(), qtwebapp::HttpResponse::getCookies(), mutex, and sessions.
Referenced by getSession().
void HttpSessionStore::removeSession | ( | HttpSession | session | ) |
Delete a session
Definition at line 134 of file httpsessionstore.cpp.
References qtwebapp::HttpSession::getId(), mutex, and sessions.
|
privateslot |
Called every minute to cleanup expired sessions.
Definition at line 112 of file httpsessionstore.cpp.
References expirationTime, qtwebapp::HttpSession::getId(), qtwebapp::HttpSession::getLastAccess(), i, mutex, and sessions.
Referenced by HttpSessionStore().
|
inline |
Set new sessions settings data
sessions | settings to replace current data |
Definition at line 97 of file httpsessionstore.h.
|
private |
Timer to remove expired sessions
Definition at line 112 of file httpsessionstore.h.
Referenced by HttpSessionStore(), and ~HttpSessionStore().
|
private |
Name of the session cookie
Definition at line 115 of file httpsessionstore.h.
Referenced by getSession(), getSessionId(), and HttpSessionStore().
|
private |
Time when sessions expire (in ms)
Definition at line 118 of file httpsessionstore.h.
Referenced by getSession(), HttpSessionStore(), and sessionTimerEvent().
|
private |
Used to synchronize threads
Definition at line 121 of file httpsessionstore.h.
Referenced by getSession(), getSessionId(), removeSession(), and sessionTimerEvent().
|
protected |
Storage for the sessions
Definition at line 101 of file httpsessionstore.h.
Referenced by getSession(), getSessionId(), removeSession(), and sessionTimerEvent().
|
private |
Configuration settings as a structure
Definition at line 109 of file httpsessionstore.h.
Referenced by getSession(), and HttpSessionStore().
|
private |
Configuration settings as Qt settings
Definition at line 106 of file httpsessionstore.h.
Referenced by getSession(), and HttpSessionStore().
|
private |