Skip to content

Commit

Permalink
update to 1.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
sladage committed Aug 6, 2015
1 parent 985aa08 commit e31f936
Show file tree
Hide file tree
Showing 31 changed files with 282 additions and 168 deletions.
2 changes: 1 addition & 1 deletion examples/Demo1/etc/Demo1.ini
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
[logging]
fileName=../logs/demo1.log
minLevel=1
minLevel=0
bufferSize=100
maxSize=1000000
maxBackups=2
Expand Down
2 changes: 1 addition & 1 deletion examples/Demo1/etc/docroot/index.html
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
<html><body>
<img src="Schmetterling klein.png">
Try one of the following examples:
<p>
<p>
<ul>
<li><a href="/dump">Dump HTTP request</a>
<li><a href="/template">Dynamic website using a template engine</a>
Expand Down
89 changes: 69 additions & 20 deletions examples/Demo1/logs/demo1.log
Original file line number Diff line number Diff line change
@@ -1,22 1,71 @@
03.04.2015 21:33:43.961 0 DEBUG 3040504128 QtWebAppLib has version 1.5.0
03.04.2015 21:33:43.961 0 DEBUG 3040504128 TemplateLoader: path=/home/stefan/Programmierung/QtWebApp/Demo1/etc/templates, codec=UTF-8
03.04.2015 21:33:43.961 0 DEBUG 3040504128 TemplateCache: timeout=60000, size=1000000
03.04.2015 21:33:43.961 0 DEBUG 3040504128 HttpSessionStore: Sessions expire after 3600000 milliseconds
03.04.2015 21:33:43.962 0 DEBUG 3040504128 StaticFileController: docroot=/home/stefan/Programmierung/QtWebApp/Demo1/etc/docroot, encoding=UTF-8, maxAge=60000
03.04.2015 21:33:43.962 0 DEBUG 3040504128 StaticFileController: cache timeout=60000, size=1000000
03.04.2015 21:33:43.962 0 DEBUG 3040504128 ServiceHelper: Starting service
03.04.2015 21:33:43.962 0 DEBUG 3040504128 HttpListener: Listening on port 8080
03.04.2015 21:33:43.963 0 DEBUG 3040504128 You see these debug messages because the logging buffer is enabled
03.04.2015 21:33:43.963 1 WARNING 3040504128 Application has started
26.07.2015 08:15:13.630 0 DEBUG 139932081915712 TemplateLoader: path=/home/stefan/Programmierung/QtWebApp/Demo1/etc/templates, codec=UTF-8
26.07.2015 08:15:13.631 0 DEBUG 139932081915712 TemplateCache: timeout=60000, size=1000000
26.07.2015 08:15:13.631 0 DEBUG 139932081915712 HttpSessionStore: Sessions expire after 3600000 milliseconds
26.07.2015 08:15:13.631 0 DEBUG 139932081915712 StaticFileController: docroot=/home/stefan/Programmierung/QtWebApp/Demo1/etc/docroot, encoding=UTF-8, maxAge=60000
26.07.2015 08:15:13.631 0 DEBUG 139932081915712 StaticFileController: cache timeout=60000, size=1000000
26.07.2015 08:15:13.631 0 DEBUG 139932081915712 RequestMapper: created
26.07.2015 08:15:13.631 0 DEBUG 139932081915712 HttpListener: Listening on port 8080
26.07.2015 08:15:13.631 1 WARNING 139932081915712 MyApplication: started
26.07.2015 08:15:16.840 0 DEBUG 139932081915712 HttpListener: New connection
26.07.2015 08:15:16.840 0 DEBUG 139932081915712 HttpConnectionHandler (0x1c7da00): constructed
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpConnectionHandler (0x1c7da00): thread started
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpConnectionHandler (0x1c7da00): handle new connection
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpConnectionHandler (0x1c7da00): read input
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpRequest: read request
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpRequest: received header Host: localhost:8080
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpRequest: received header User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpRequest: received header Accept: text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpRequest: received header Accept-Language: de,en-US;q=0.7,en;q=0.3
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.841 0 DEBUG 139932001220352 HttpRequest: received header Accept-Encoding: gzip, deflate
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 HttpRequest: received header Connection: keep-alive
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 HttpRequest: received header Cache-Control: max-age=0
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 HttpRequest: headers completed
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 HttpRequest: expect no body
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 HttpRequest: extract and decode request parameters
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 HttpRequest: extract cookies
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 HttpConnectionHandler (0x1c7da00): received request
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 RequestMapper: path=/
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 StaticFileController: Cache miss for /
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 StaticFileController: Open file /home/stefan/Programmierung/QtWebApp/Demo1/etc/docroot//index.html
26.07.2015 08:15:16.842 0 DEBUG 139932001220352 RequestMapper: finished request
26.07.2015 08:15:16.843 0 DEBUG 139932001220352 HttpConnectionHandler (0x1c7da00): finished request
26.07.2015 08:15:16.947 0 DEBUG 139932001220352 HttpConnectionHandler (0x1c7da00): read input
26.07.2015 08:15:16.947 0 DEBUG 139932001220352 HttpRequest: read request
26.07.2015 08:15:16.947 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.947 0 DEBUG 139932001220352 HttpRequest: received header Host: localhost:8080
26.07.2015 08:15:16.947 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.947 0 DEBUG 139932001220352 HttpRequest: received header User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0
26.07.2015 08:15:16.947 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: received header Accept: image/png,image/*;q=0.8,*/*;q=0.5
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: received header Accept-Language: de,en-US;q=0.7,en;q=0.3
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: received header Accept-Encoding: gzip, deflate
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: received header Referer: http://localhost:8080/
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: received header Connection: keep-alive
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: received header Cache-Control: max-age=0
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: read header
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: headers completed
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: expect no body
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: extract and decode request parameters
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpRequest: extract cookies
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 HttpConnectionHandler (0x1c7da00): received request
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 RequestMapper: path=/Schmetterling klein.png
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 StaticFileController: Cache miss for /Schmetterling klein.png
26.07.2015 08:15:16.948 0 DEBUG 139932001220352 StaticFileController: Open file /home/stefan/Programmierung/QtWebApp/Demo1/etc/docroot/Schmetterling klein.png
26.07.2015 08:15:16.949 0 DEBUG 139932001220352 RequestMapper: finished request
26.07.2015 08:15:16.949 0 DEBUG 139932001220352 HttpConnectionHandler (0x1c7da00): finished request

Note: If you don't see new messages here, then the logger might be commented out in main.cpp.

22.06.2015 17:46:21.566 0 DEBUG 140562905347904 QtWebAppLib has version 1.5.5
22.06.2015 17:46:21.567 0 DEBUG 140562905347904 TemplateLoader: path=/home/stefan/Programmierung/QtWebApp/Demo1/etc/templates, codec=UTF-8
22.06.2015 17:46:21.567 0 DEBUG 140562905347904 TemplateCache: timeout=60000, size=1000000
22.06.2015 17:46:21.568 0 DEBUG 140562905347904 HttpSessionStore: Sessions expire after 3600000 milliseconds
22.06.2015 17:46:21.568 0 DEBUG 140562905347904 StaticFileController: docroot=/home/stefan/Programmierung/QtWebApp/Demo1/etc/docroot, encoding=UTF-8, maxAge=60000
22.06.2015 17:46:21.568 0 DEBUG 140562905347904 StaticFileController: cache timeout=60000, size=1000000
22.06.2015 17:46:21.568 0 DEBUG 140562905347904 ServiceHelper: Starting service
22.06.2015 17:46:21.583 0 DEBUG 140562905347904 HttpListener: Listening on port 8080
22.06.2015 17:46:21.583 0 DEBUG 140562905347904 You see these debug messages because the logging buffer is enabled
22.06.2015 17:46:21.583 1 WARNING 140562905347904 Application has started
2 changes: 1 addition & 1 deletion examples/Demo1/src/controller/sessioncontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 3,9 @@
@author Stefan Frings
*/

#include <QDateTime>
#include "sessioncontroller.h"
#include "httpsessionstore.h"
#include <QDateTime>

/** Storage for session cookies */
extern HttpSessionStore* sessionStore;
Expand Down
14 changes: 7 additions & 7 deletions examples/Demo1/src/controller/templatecontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 17,14 @@

class TemplateController : public HttpRequestHandler {
Q_OBJECT
Q_DISABLE_COPY(TemplateController)
public:
Q_DISABLE_COPY(TemplateController)
public:

/** Constructor */
TemplateController();
/** Constructor */
TemplateController();

/** Generates the response */
void service(HttpRequest& request, HttpResponse& response);
};
/** Generates the response */
void service(HttpRequest& request, HttpResponse& response);
};

#endif // TEMPLATECONTROLLER_H
57 changes: 22 additions & 35 deletions examples/Demo1/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 5,13 @@

#include <QCoreApplication>
#include <QDir>
#include <QFile>
#include "httplistener.h"
#include "templatecache.h"
#include "httpsessionstore.h"
#include "staticfilecontroller.h"
#include "filelogger.h"
#include "requestmapper.h"

/** Name of this application */
#define APPNAME "Demo1"

/** Publisher of this application */
#define ORGANISATION "Butterfly"


/** The HTTP listener of the application */
HttpListener* listener;

/** Cache for template files */
TemplateCache* templateCache;

Expand All @@ -32,9 21,10 @@ HttpSessionStore* sessionStore;
/** Controller for static files */
StaticFileController* staticFileController;

/** Logger class */
/** Redirects log messages to a file */
FileLogger* logger;


/** Search the configuration file */
QString searchConfigFile() {
QString binDir=QCoreApplication::applicationDirPath();
Expand Down Expand Up @@ -72,53 62,50 @@ QString searchConfigFile() {
return 0;
}


/**
Entry point of the program.
*/
int main(int argc, char *argv[]) {
QCoreApplication app(argc,argv);

// Initialize the core application
QCoreApplication* app=new QCoreApplication(argc, argv);
app->setApplicationName(APPNAME);
app->setOrganizationName(ORGANISATION);
app.setApplicationName("Demo1");
app.setOrganizationName("Butterfly");

// Find the configuration file
QString configFileName=searchConfigFile();

// Configure logging
QSettings* logSettings=new QSettings(configFileName,QSettings::IniFormat,app);
// Configure logging into a file
/*
QSettings* logSettings=new QSettings(configFileName,QSettings::IniFormat,&app);
logSettings->beginGroup("logging");
logger=new FileLogger(logSettings,10000,app);
FileLogger* logger=new FileLogger(logSettings,10000,&app);
logger->installMsgHandler();

// Log the library version
qDebug("QtWebAppLib has version %s",getQtWebAppLibVersion());
*/

// Configure template loader and cache
QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,app);
QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,&app);
templateSettings->beginGroup("templates");
templateCache=new TemplateCache(templateSettings,app);
templateCache=new TemplateCache(templateSettings,&app);

// Configure session store
QSettings* sessionSettings=new QSettings(configFileName,QSettings::IniFormat,app);
QSettings* sessionSettings=new QSettings(configFileName,QSettings::IniFormat,&app);
sessionSettings->beginGroup("sessions");
sessionStore=new HttpSessionStore(sessionSettings,app);
sessionStore=new HttpSessionStore(sessionSettings,&app);

// Configure static file controller
QSettings* fileSettings=new QSettings(configFileName,QSettings::IniFormat,app);
QSettings* fileSettings=new QSettings(configFileName,QSettings::IniFormat,&app);
fileSettings->beginGroup("docroot");
staticFileController=new StaticFileController(fileSettings,app);
staticFileController=new StaticFileController(fileSettings,&app);

// Configure and start the TCP listener
qDebug("ServiceHelper: Starting service");
QSettings* listenerSettings=new QSettings(configFileName,QSettings::IniFormat,app);
QSettings* listenerSettings=new QSettings(configFileName,QSettings::IniFormat,&app);
listenerSettings->beginGroup("listener");
listener=new HttpListener(listenerSettings,new RequestMapper(app),app);
new HttpListener(listenerSettings,new RequestMapper(&app),&app);

if (logSettings->value("bufferSize",0).toInt()>0 && logSettings->value("minLevel",0).toInt()>0) {
qDebug("You see these debug messages because the logging buffer is enabled");
}
qWarning("Application has started");

return app->exec();
app.exec();

qWarning("Application has stopped");
}
29 changes: 23 additions & 6 deletions examples/Demo1/src/requestmapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 3,39 @@
@author Stefan Frings
*/

#include <QCoreApplication>
#include "requestmapper.h"
#include "staticfilecontroller.h"
#include "filelogger.h"
#include "staticfilecontroller.h"
#include "controller/dumpcontroller.h"
#include "controller/templatecontroller.h"
#include "controller/formcontroller.h"
#include "controller/fileuploadcontroller.h"
#include "controller/sessioncontroller.h"

/** Redirects log messages to a file */
extern FileLogger* logger;

/** Controller for static files */
extern StaticFileController* staticFileController;

/** Logger class */
extern FileLogger* logger;

RequestMapper::RequestMapper(QObject* parent)
:HttpRequestHandler(parent) {}
:HttpRequestHandler(parent) {
qDebug("RequestMapper: created");
}


RequestMapper::~RequestMapper() {
qDebug("RequestMapper: deleted");
}


void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
QByteArray path=request.getPath();
qDebug("RequestMapper: path=%s",path.data());

// For the following pathes, each request gets its own new instance of the related controller.

if (path.startsWith("/dump")) {
DumpController().service(request, response);
}
Expand All @@ -46,9 57,15 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
}

// All other pathes are mapped to the static file controller.
// In this case, a single instance is used for multiple requests.
else {
staticFileController->service(request, response);
}

qDebug("RequestMapper: finished request");
logger->clear();

// Clear the log buffer
if (logger) {
logger->clear();
}
}
7 changes: 6 additions & 1 deletion examples/Demo1/src/requestmapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 25,12 @@ class RequestMapper : public HttpRequestHandler {
RequestMapper(QObject* parent=0);

/**
Dispatch a request to a controller.
Destructor.
*/
~RequestMapper();

/**
Dispatch incoming HTTP requests to different controllers depending on the URL.
@param request The received HTTP request
@param response Must be used to return the response
*/
Expand Down
8 changes: 4 additions & 4 deletions examples/Demo2/Demo2.pro
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 29,16 @@ INCLUDEPATH = $$PWD/../QtWebApp

# Directory where the release version of the shared library (*.dll or *.so) is stored, and base name of the file.
CONFIG(release, debug|release) {
win32: LIBS = -L$$PWD/../build-QtWebApp-Desktop_Qt_5_4_1_MinGW_32bit-Release/release/ -lQtWebApp1
win32: LIBS = -L$$PWD/../build-QtWebApp-Desktop_Qt_5_4_2_MinGW_32bit-Release/release/ -lQtWebApp1
mac: LIBS = -L$$PWD/../build-QtWebApp-Desktop_Qt_5_4_clang_64bit-Release/ -lQtWebApp
unix:!mac: LIBS = -L$$PWD/../build-QtWebApp-Desktop_Qt_5_4_1_GCC_32bit-Release/ -lQtWebApp
unix:!mac: LIBS = -L$$PWD/../build-QtWebApp-Desktop_Qt_5_4_2_GCC_64bit-Release/ -lQtWebApp
}

# Directory where the debug version of the shared library (*.dll or *.so) is stored, and base name of the file.
CONFIG(debug, debug|release) {
win32: LIBS = -L$$PWD/../build-QtWebApp-Desktop_Qt_5_4_1_MinGW_32bit-Debug/debug/ -lQtWebAppd1
win32: LIBS = -L$$PWD/../build-QtWebApp-Desktop_Qt_5_4_2_MinGW_32bit-Debug/debug/ -lQtWebAppd1
mac: LIBS = -L$$PWD/../build-QtWebApp-Desktop_Qt_5_4_clang_64bit-Debug/ -lQtWebApp_debug
unix:!mac: LIBS = -L$$PWD/../build-QtWebApp-Desktop_Qt_5_4_1_GCC_32bit-Debug/ -lQtWebAppd
unix:!mac: LIBS = -L$$PWD/../build-QtWebApp-Desktop_Qt_5_4_2_GCC_64bit-Debug/ -lQtWebAppd
}

win32 {
Expand Down
11 changes: 5 additions & 6 deletions examples/Demo2/logs/demo2.log
Original file line number Diff line number Diff line change
@@ -1,8 1,7 @@
04.04.2015 08:03:06.069 0 DEBUG 3039762176 QtWebAppLib has version 1.5.0
04.04.2015 08:03:06.069 0 DEBUG 3039762176 ServiceHelper: Starting service
04.04.2015 08:03:06.095 0 DEBUG 3039762176 HttpListener: Listening on port 8080
04.04.2015 08:03:06.095 0 DEBUG 3039762176 You see these debug messages because the logging buffer is enabled
04.04.2015 08:03:06.095 1 WARNING 3039762176 Application has started

26.07.2015 07:42:58.159 1 WARNING 139659983566656 Application has started
26.07.2015 07:44:21.411 0 DEBUG 140113252636480 RequestHandler: created
26.07.2015 07:44:21.411 0 DEBUG 140113252636480 HttpListener: Listening on port 8080
26.07.2015 07:44:21.411 1 WARNING 140113252636480 Application has started

Note: If you don't see new messages here, then the logger might be commented out in main.cpp.

Loading

0 comments on commit e31f936

Please sign in to comment.