Hobrasoft httpd server
Embedded HTTP server for Qt and C++
Public Member Functions | Private Member Functions | List of all members
HobrasoftHttpd::HttpSettings Class Reference

Configuration of the http server instance. More...

#include <httpsettings.h>

Inheritance diagram for HobrasoftHttpd::HttpSettings:

Public Member Functions

 HttpSettings (QObject *parent)
 Constructor reads default QSettings file section [httpd].
 
 HttpSettings (const QSettings *, QObject *parent)
 Constructor reads settings from parameters, uses default section [httpd].
 
 HttpSettings (const QSettings *, const QString &section, QObject *parent)
 Constructor reads settings from parameters, uses custom section name. More...
 
const QHostAddress & address () const
 Returns the bind address.
 
void setAddress (const QHostAddress &x)
 Sets the bind address.
 
void setDefaultAddress (const QHostAddress &x)
 Sets the defailt bind address.
 
int port () const
 Returns the port number.
 
void setPort (int x)
 Sets the port number.
 
void setDefaultPort (int x)
 Sets the default port number.
 
int timeout () const
 Returns timeout for opened connection from clients.
 
void setTimeout (int x)
 Sets timeout for opened connection from clients.
 
void setDefaultTimeout (int x)
 Sets default timeout for opened connection from clients.
 
int maxAge () const
 Returns the max age for cacheing proxy objects.
 
void setMaxAge (int x)
 Sets the max age cacheing proxy objects.
 
void setDefaultMaxAge (int x)
 Sets the default max age cacheing proxy objects.
 
const QString & encoding () const
 Returns the encoding in COntent-type header.
 
void setEncoding (const QString &x)
 Sets the encoding in COntent-type header.
 
void setDefaultEncoding (const QString &x)
 Sets the default encoding in COntent-type header.
 
const QString & docroot () const
 Returns path to document root.
 
void setDocroot (const QString &x)
 Sets path to document root.
 
void setDefaultDocroot (const QString &x)
 Sets default path to document root.
 
const QString & indexFile () const
 Returns name of index file in directory (index.html)
 
void setIndexFile (const QString &x)
 Sets name of index file in directory (index.html)
 
void setDefaultIndexFile (const QString &x)
 Sets default name of index file in directory (index.html)
 
int sessionExpirationTime () const
 Returns maximum expiration time for the session.
 
void setExpirationTime (int x)
 Sets maximum expiration time for the session.
 
void setDefaultExpirationTime (int x)
 Sets default maximum expiration time for the session.
 
const QString & sessionCookieName () const
 Returns session cookie name.
 
void setSessionCookieName (const QString &x)
 Sets default session cookie name.
 
void setDefaultSessionCookieName (const QString &x)
 Sets session cookie name.
 
int maxRequestSize () const
 Returns maximum request size.
 
void setMaxRequestSize (int x)
 Sets maximum request size.
 
void setDefaultMaxRequestSize (int x)
 Sets default maximum request size.
 
int maxMultiPartSize () const
 Returns maximum request size in multipart requests.
 
void setMaxMultiPartSize (int x)
 Sets maximum request size in multipart requests.
 
void setDefaultMaxMultiPartSize (int x)
 Sets default maximum request size in multipart requests.
 
const QString & tempDir () const
 Returns path to temporary directory.
 
void setTempDir (const QString &x)
 Sets path to temporary directory.
 
void setDefaultTempDir (const QString &x)
 Sets default path to temporary directory.
 
bool useSSL () const
 Returns status of SSL connections.
 
void setUseSSL (bool x)
 Set status of SSL connections.
 
void setDefaultUseSSL (bool x)
 Set default status of SSL connections.
 
bool threads () const
 Returns true if server starts new thread for each connection.
 
void setThreads (bool x)
 Set starting new thread for each connection.
 
void setDefaultThreads (bool x)
 Set default value for starting new thread for each connection.
 
bool gzip () const
 Returns true if server can use gzip compression.
 
void setGzip (bool x)
 Enable gzip compression.
 
void setDefaultGzip (bool x)
 Set default value for gzip compression.
 
const QString & sslKey () const
 Returns SSL key.
 
void setSslKey (const QString &x)
 Set SSL key.
 
void setDefaultSslKey (const QString &x)
 Set default SSL key.
 
const QString & sslCrt () const
 Returns SSL certificate.
 
void setSslCrt (const QString &x)
 Set SSL certificate.
 
void setDefaultSslCrt (const QString &x)
 Set default SSL certificate.
 
const QString & sslCaCrt () const
 Returns SSL CA certificate.
 
void setSslCaCrt (const QString &x)
 Set SSL CA certificate.
 
void setDefaultSslCaCrt (const QString &x)
 Set default SSL CA certificate.
 
bool ignoreSslError (QSslError error) const
 Returns true if the error should be ignored, default true.
 
void readSettings (const QSettings *settings, const QString &section, const QString &section2)
 Read settings from configuration file. More...
 
void readSettings (const QSettings *settings, const QString &section)
 Read settings from configuration file.
 
void setSection2 (const QString &section)
 Sets the name for the second section. More...
 

Private Member Functions

void setDefaultValues ()
 

Detailed Description

Configuration of the http server instance.

Default configuration is read from current QSettings. Before you start your HttpServer you have to set the organization name, domain name and application name. In the configuration the group [httpd] is found and configuration parameters from this section is used. Configuration file (when using ini format) can looks like this:

[httpd]
address = 0.0.0.0
port = 8086
root = /home/tycho/SRC/mdcv04ip/htdocs
cacheMaxAge = 600000
indexFile = index.html
encoding = UTF-8
timeout = 60000

Definition at line 39 of file httpsettings.h.

Constructor & Destructor Documentation

◆ HttpSettings()

HttpSettings::HttpSettings ( const QSettings *  settings,
const QString &  section,
QObject *  parent 
)

Constructor reads settings from parameters, uses custom section name.

When the parameter could not be read in the section, alternate section name is used [http]

Definition at line 206 of file httpsettings.cpp.

Member Function Documentation

◆ readSettings()

void HttpSettings::readSettings ( const QSettings *  settings,
const QString &  section,
const QString &  section2 
)

Read settings from configuration file.

First are read values from first section (second parameter), then from section2 (third parameter). From the second section are read values which were not read from first section. You can have set your configuration file like this:

[httpd]
port = 8086
root = /usr/share/appdata/htdocs
user = admin
password = admin
[httpds]
port = 8087
sslKey = /etc/ssl/private/server.hobrasoft.eu.key.pem
sslCrt = /etc/ssl/private/server.hobrasoft.eu.crt.pem
useSSL = true

Definition at line 117 of file httpsettings.cpp.

◆ setSection2()

void HobrasoftHttpd::HttpSettings::setSection2 ( const QString &  section)
inline

Sets the name for the second section.

From the second section are read values which were not read from first section.

Definition at line 171 of file httpsettings.h.


The documentation for this class was generated from the following files: