-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
98 changed files
with
9,160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,11 @@ | ||
This program and its source is distributed under the Lesser General Public License. | ||
http://www.gnu.org/licenses/lgpl.html | ||
|
||
When you modify the library, you have to publish your modified version for free under LGPL license. | ||
|
||
Author and Copyright owner: Stefan Frings | ||
[email protected] | ||
http://www.stefanfrings.de | ||
|
||
The qtservice module had been published by Trolltech/Nokia under the LGPL license. | ||
https://qt.gitorious.org/qt-solutions/qt-solutions/source/qtservice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,34 @@ | ||
# This project demonstrates how to use QtWebAppLib by including the | ||
# sources into this project. | ||
|
||
TARGET = Demo1 | ||
TEMPLATE = app | ||
QT = core network | ||
CONFIG = console | ||
|
||
HEADERS = \ | ||
src/requestmapper.h \ | ||
src/controller/dumpcontroller.h \ | ||
src/controller/templatecontroller.h \ | ||
src/controller/formcontroller.h \ | ||
src/controller/fileuploadcontroller.h \ | ||
src/controller/sessioncontroller.h | ||
|
||
SOURCES = src/main.cpp \ | ||
src/requestmapper.cpp \ | ||
src/controller/dumpcontroller.cpp \ | ||
src/controller/templatecontroller.cpp \ | ||
src/controller/formcontroller.cpp \ | ||
src/controller/fileuploadcontroller.cpp \ | ||
src/controller/sessioncontroller.cpp | ||
|
||
OTHER_FILES = etc/* etc/docroot/* etc/templates/* etc/ssl/* logs/* ../readme.txt | ||
|
||
#--------------------------------------------------------------------------------------- | ||
# The following lines include the sources of the QtWebAppLib library | ||
#--------------------------------------------------------------------------------------- | ||
|
||
include(../QtWebApp/logging/logging.pri) | ||
include(../QtWebApp/httpserver/httpserver.pri) | ||
include(../QtWebApp/templateengine/templateengine.pri) | ||
# Not used: include(../QtWebApp/qtservice/qtservice.pri) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,44 @@ | ||
[logging] | ||
fileName=../logs/demo1.log | ||
minLevel=1 | ||
bufferSize=100 | ||
maxSize=1000000 | ||
maxBackups=2 | ||
timestampFormat=dd.MM.yyyy hh:mm:ss.zzz | ||
msgFormat={timestamp} {typeNr} {type} {thread} {msg} | ||
; QT5 supports: msgFormat={timestamp} {typeNr} {type} {thread} {msg}\n in {file} line {line} function {function} | ||
|
||
[listener] | ||
;host=192.168.0.100 | ||
port=8080 | ||
minThreads=1 | ||
maxThreads=100 | ||
cleanupInterval=1000 | ||
readTimeout=60000 | ||
;sslKeyFile=ssl/my.key | ||
;sslCertFile=ssl/my.cert | ||
maxRequestSize=16000 | ||
maxMultiPartSize=10000000 | ||
|
||
[templates] | ||
path=templates | ||
suffix=.tpl | ||
encoding=UTF-8 | ||
cacheSize=1000000 | ||
cacheTime=60000 | ||
|
||
[docroot] | ||
path=docroot | ||
encoding=UTF-8 | ||
maxAge=60000 | ||
cacheTime=60000 | ||
cacheSize=1000000 | ||
maxCachedFileSize=65536 | ||
|
||
[sessions] | ||
expirationTime=3600000 | ||
cookieName=sessionid | ||
cookiePath=/ | ||
cookieComment=Identifies the user | ||
;cookieDomain=stefanfrings.de | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,12 @@ | ||
<html><body> | ||
<img src="Schmetterling klein.png"> | ||
Try one of the following examples: | ||
<p> | ||
<ul> | ||
<li><a href="/dump">Dump HTTP request</a> | ||
<li><a href="/template">Dynamic website using a template engine</a> | ||
<li><a href="/form">HTML form</a> | ||
<li><a href="/file">File upload form</a> | ||
<li><a href="/session">Session demo</a> | ||
</ul> | ||
</body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,21 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDhTCCAm2gAwIBAgIJALk6oIpWZQI9MA0GCSqGSIb3DQEBCwUAMFkxCzAJBgNV | ||
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX | ||
aWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0xNTA0MDMxOTU1 | ||
NTJaFw0xNjA0MDIxOTU1NTJaMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21l | ||
LVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNV | ||
BAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM9s | ||
4rNgfasL/dTCQZVv6mtjsa7siGrmwsfZ8LNb JG0SVfHWHTmE/Gm BayNoupDpbv | ||
R3gaD6VjSZdzNqClt 7LGhjBYr4wHyDcbnzkgd03ARfN IFKQp9yYEUbO7SvKrD | ||
rg0HLP96fsDPDAWVBrZ9tTpa cU H1Ea7BKmmcGuZbY6K3uMG7BDKqbEXOpuxdJ3 | ||
TbaGgDtH5qPpJXEPUQgkwRkPoDyU1GYvOw FFpAGP9MmyxofH3/CyaKfvrowcJW0 | ||
tRAojfNXIxM9HTZCtuhB3icCY0895/X0KQCUGRWoS01ZatAV08TfwemWJ43EC6e5 | ||
8nPlwsjIxoYmUIFZm2cCAwEAAaNQME4wHQYDVR0OBBYEFMEJGRIr2QHEV2LThyxt | ||
x9Lh6GfIMB8GA1UdIwQYMBaAFMEJGRIr2QHEV2LThyxtx9Lh6GfIMAwGA1UdEwQF | ||
MAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFslVIHPxQ5Fxw/gLZpeOaO7T6nV 87B | ||
tSCxfFlrDzivu1ZBd12yK0BNtwVLG9lvyQ66gRInFXrsEi4pWEGWn0pmufPlEuSQ | ||
OVjvPJi/ejdnFwQFY4PhHLbuXtZkBX8TCpq4wlNJWe xdXdDnBM chGrSp1KJW0J | ||
nr lHw7oK0kG6ohZYz2i1qEoBU7NNuU5GrkVt7QMg23xFbLb/la eXMGX9XPAGRb | ||
Dx32QWQDwDFdjQMVLeKtSWFGXT2LiPyry1CXo7beE5Ur617cbjeHW5ecyZ1yo3bJ | ||
F/jO238OjTAxnaY7PGtpKUMrIkyLaMxtGa8/DTaTkSdlgYRK8znVLes= | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDPbOKzYH2rC/3U | ||
wkGVb prY7Gu7Ihq5sLH2fCzW/iRtElXx1h05hPxpvgWsjaLqQ6W70d4Gg lY0mX | ||
czagpbfuyxoYwWK MB8g3G585IHdNwEXzfiBSkKfcmBFGzu0ryqw/q4NByz/en7A | ||
zwwFlQa2fbU6WvnFPh9RGuwSppnBrmW2Oit7jBuwQyqmxFzqbsXSd022hoA7R aj | ||
6SVxD1EIJMEZD6A8lNRmLzsPhRaQBj/TJssaHx9/wsmin766MHCVtLUQKI3zVyMT | ||
P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eGLYELAcK/wmRMlCWNuohaQnoq2/EfmsaKSV5e3m0Ynix7DgjbTtN31uc | ||
EtFbpfTC CpjsRsgzG8kl63DmqV7FocEqqRcGXn5AoGBANLtQUtIZbVIH2Uxz3Fq | ||
SWHvkMmU5hOJj3adYNhiQ9b/J4Znonp vGHMf31A F7glCXMfo9k4 LyfjJplTNh | ||
K4YSDJQxhaXOLNdql/3tYEjR5PFyNdQU9MVePOAwq4sxnv39MHm3Mb6fAZFurh6c | ||
1GAHkUPZFGPAiXzX2Hbg39sD | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,12 @@ | ||
<html><body> | ||
|
||
Hallo,<br> | ||
du hast folgenden Pfad angefordert: {path} | ||
<p> | ||
Und dein Web Browser hat folgende Kopfzeilen geliefert: | ||
<p> | ||
{loop header} | ||
<b>{header.name}:</b> {header.value}<br> | ||
{end header} | ||
|
||
</html></body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,12 @@ | ||
<html><body> | ||
|
||
Hello,<br> | ||
you requested the path: {path} | ||
<p> | ||
And your web browser provided the following headers: | ||
<p> | ||
{loop header} | ||
<b>{header.name}:</b> {header.value}<br> | ||
{end header} | ||
|
||
</html></body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,22 @@ | ||
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 | ||
|
||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,62 @@ | ||
/** | ||
@file | ||
@author Stefan Frings | ||
*/ | ||
|
||
#include "dumpcontroller.h" | ||
#include <QVariant> | ||
#include <QDateTime> | ||
|
||
DumpController::DumpController(){} | ||
|
||
void DumpController::service(HttpRequest& request, HttpResponse& response) { | ||
|
||
response.setHeader("Content-Type", "text/html; charset=ISO-8859-1"); | ||
response.setCookie(HttpCookie("firstCookie","hello",600)); | ||
response.setCookie(HttpCookie("secondCookie","world",600)); | ||
|
||
QByteArray body("<html><body>"); | ||
body.append("<b>Request:</b>"); | ||
body.append("<br>Method: "); | ||
body.append(request.getMethod()); | ||
body.append("<br>Path: "); | ||
body.append(request.getPath()); | ||
body.append("<br>Version: "); | ||
body.append(request.getVersion()); | ||
|
||
body.append("<p><b>Headers:</b>"); | ||
QMapIterator<QByteArray,QByteArray> i(request.getHeaderMap()); | ||
while (i.hasNext()) { | ||
i.next(); | ||
body.append("<br>"); | ||
body.append(i.key()); | ||
body.append("="); | ||
body.append(i.value()); | ||
} | ||
|
||
body.append("<p><b>Parameters:</b>"); | ||
i=QMapIterator<QByteArray,QByteArray>(request.getParameterMap()); | ||
while (i.hasNext()) { | ||
i.next(); | ||
body.append("<br>"); | ||
body.append(i.key()); | ||
body.append("="); | ||
body.append(i.value()); | ||
} | ||
|
||
body.append("<p><b>Cookies:</b>"); | ||
i=QMapIterator<QByteArray,QByteArray>(request.getCookieMap()); | ||
while (i.hasNext()) { | ||
i.next(); | ||
body.append("<br>"); | ||
body.append(i.key()); | ||
body.append("="); | ||
body.append(i.value()); | ||
} | ||
|
||
body.append("<p><b>Body:</b><br>"); | ||
body.append(request.getBody()); | ||
|
||
body.append("</body></html>"); | ||
response.write(body,true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,29 @@ | ||
/** | ||
@file | ||
@author Stefan Frings | ||
*/ | ||
|
||
#ifndef DUMPCONTROLLER_H | ||
#define DUMPCONTROLLER_H | ||
|
||
#include "httprequest.h" | ||
#include "httpresponse.h" | ||
#include "httprequesthandler.h" | ||
|
||
/** | ||
This controller dumps the received HTTP request in the response. | ||
*/ | ||
|
||
class DumpController : public HttpRequestHandler { | ||
Q_OBJECT | ||
Q_DISABLE_COPY(DumpController) | ||
public: | ||
|
||
/** Constructor */ | ||
DumpController(); | ||
|
||
/** Generates the response */ | ||
void service(HttpRequest& request, HttpResponse& response); | ||
}; | ||
|
||
#endif // DUMPCONTROLLER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,38 @@ | ||
/** | ||
@file | ||
@author Stefan Frings | ||
*/ | ||
|
||
#include "fileuploadcontroller.h" | ||
|
||
FileUploadController::FileUploadController() {} | ||
|
||
void FileUploadController::service(HttpRequest& request, HttpResponse& response) { | ||
|
||
if (request.getParameter("action")=="show") { | ||
response.setHeader("Content-Type", "image/jpeg"); | ||
QTemporaryFile* file=request.getUploadedFile("file1"); | ||
if (file) { | ||
while (!file->atEnd() && !file->error()) { | ||
QByteArray buffer=file->read(65536); | ||
response.write(buffer); | ||
} | ||
} | ||
else { | ||
response.write("upload failed"); | ||
} | ||
} | ||
|
||
else { | ||
response.setHeader("Content-Type", "text/html; charset=ISO-8859-1"); | ||
response.write("<html><body>"); | ||
response.write("Upload a JPEG image file<p>"); | ||
response.write("<form method=\"post\" enctype=\"multipart/form-data\">"); | ||
response.write(" <input type=\"hidden\" name=\"action\" value=\"show\">"); | ||
response.write(" File: <input type=\"file\" name=\"file1\"><br>"); | ||
response.write(" <input type=\"submit\">"); | ||
response.write("</form>"); | ||
response.write("</body></html>",true); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,30 @@ | ||
/** | ||
@file | ||
@author Stefan Frings | ||
*/ | ||
|
||
#ifndef FILEUPLOADCONTROLLER_H | ||
#define FILEUPLOADCONTROLLER_H | ||
|
||
#include "httprequest.h" | ||
#include "httpresponse.h" | ||
#include "httprequesthandler.h" | ||
|
||
/** | ||
This controller displays a HTML form for file upload and recieved the file. | ||
*/ | ||
|
||
|
||
class FileUploadController : public HttpRequestHandler { | ||
Q_OBJECT | ||
Q_DISABLE_COPY(FileUploadController) | ||
public: | ||
|
||
/** Constructor */ | ||
FileUploadController(); | ||
|
||
/** Generates the response */ | ||
void service(HttpRequest& request, HttpResponse& response); | ||
}; | ||
|
||
#endif // FILEUPLOADCONTROLLER_H |
Oops, something went wrong.