Cutelyst  2.13.0
Signals | Public Member Functions | Properties | List of all members
CWSGI::WSGI Class Reference

Implements a WSGI server. More...

#include <Cutelyst/WSGI>

Inheritance diagram for CWSGI::WSGI:
Inheritance graph
[legend]

Signals

void changed ()
 
void ready ()
 
void stopped ()
 

Public Member Functions

 WSGI (QObject *parent=nullptr)
 
QString application () const
 
bool autoReload () const
 
int bufferSize () const
 
QString chdir () const
 
QString chdir2 () const
 
QString chownSocket () const
 
int cpuAffinity () const
 
int exec (Cutelyst::Application *app=nullptr)
 
QStringList fastcgiSocket () const
 
QString gid () const
 
quint32 http2HeaderTableSize () const
 
QStringList http2Socket () const
 
bool httpsH2 () const
 
QStringList httpSocket () const
 
QStringList httpsSocket () const
 
QStringList ini () const
 
QStringList json () const
 
bool lazy () const
 
int listenQueue () const
 
bool master () const
 
bool noInitgroups () const
 
void parseCommandLine (const QStringList &args)
 
QString pidfile () const
 
QString pidfile2 () const
 
qint64 postBuffering () const
 
qint64 postBufferingBufsize () const
 
QString processes () const
 
bool reusePort () const
 
void setApplication (const QString &application)
 
void setAutoReload (bool enable)
 
void setBufferSize (int size)
 
void setChdir (const QString &chdir)
 
void setChdir2 (const QString &chdir2)
 
void setChownSocket (const QString &chownSocket)
 
void setCpuAffinity (int value)
 
void setFastcgiSocket (const QStringList &fastcgiSocket)
 
void setGid (const QString &gid)
 
void setHttp2HeaderTableSize (quint32 headerTableSize)
 
void setHttp2Socket (const QStringList &http2Socket)
 
void setHttpsH2 (bool enable)
 
void setHttpSocket (const QStringList &httpSocket)
 
void setHttpsSocket (const QStringList &httpsSocket)
 
void setIni (const QStringList &files)
 
void setJson (const QStringList &files)
 
void setLazy (bool enable)
 
void setListenQueue (int size)
 
void setMaster (bool enable)
 
void setNoInitgroups (bool enable)
 
void setPidfile (const QString &file)
 
void setPidfile2 (const QString &file)
 
void setPostBuffering (qint64 size)
 
void setPostBufferingBufsize (qint64 size)
 
void setProcesses (const QString &process)
 
void setReusePort (bool enable)
 
void setSocketAccess (const QString &socketAccess)
 
void setSocketRcvbuf (int value)
 
void setSocketSndbuf (int value)
 
void setSocketTimeout (int timeout)
 
void setSoKeepalive (bool enable)
 
void setStaticMap (const QStringList &staticMap)
 
void setStaticMap2 (const QStringList &staticMap)
 
void setTcpNodelay (bool enable)
 
void setThreads (const QString &threads)
 
void setTouchReload (const QStringList &files)
 
void setUid (const QString &uid)
 
void setUmask (const QString &value)
 
void setUpgradeH2c (bool enable)
 
void setUsingFrontendProxy (bool enable)
 
void setWebsocketMaxSize (int value)
 
QString socketAccess () const
 
int socketRcvbuf () const
 
int socketSndbuf () const
 
int socketTimeout () const
 
bool soKeepalive () const
 
bool start (Cutelyst::Application *app=nullptr)
 This function will start the WSGI server in user application mode. More...
 
QStringList staticMap () const
 
QStringList staticMap2 () const
 
void stop ()
 Terminates the server execution, when started with start(), it does nothing when started by exec().
 
bool tcpNodelay () const
 
QString threads () const
 
QStringList touchReload () const
 
QString uid () const
 
QString umask () const
 
bool upgradeH2c () const
 
bool usingFrontendProxy () const
 
int websocketMaxSize () const
 

Properties

QString application
 
bool auto_reload
 
int buffer_size
 
QString chdir
 
QString chdir2
 
QString chown_socket
 
int cpu_affinity
 
QStringList fastcgi_socket
 
QString gid
 
quint32 http2_header_table_size
 
QStringList http2_socket
 
QStringList http_socket
 
bool https_h2
 
QStringList https_socket
 
QStringList ini
 
QStringList json
 
bool lazy
 
int listen
 
bool master
 
bool no_initgroups
 
QString pidfile
 
QString pidfile2
 
qint64 post_buffering
 
qint64 post_buffering_bufsize
 
QString processes
 
bool reuse_port
 
bool so_keepalive
 
QString socket_access
 
int socket_rcvbuf
 
int socket_sndbuf
 
int socket_timeout
 
QStringList static_map
 
QStringList static_map2
 
bool tcp_nodelay
 
QString threads
 
QStringList touch_reload
 
QString uid
 
QString umask
 
bool upgrade_h2c
 
bool using_frontend_proxy
 
int websocket_max_size
 

Detailed Description

Definition at line 38 of file wsgi.h.

Member Function Documentation

◆ exec()

int CWSGI::WSGI::exec ( Cutelyst::Application app = nullptr)

This function will start the WSGI server.

If an application is provided it will ignore the value of setApplication and/or the Application configuration in case Ini is set, meaning it won't dynamically load an Application but use this to create new instances (if the app constructor is marked as Q_INVOKABLE).

It will return 0 in case of sucess.

Note
This method calls QCoreApplication::exec() internally, this is needed because when creating or recreating child process the event loop must not be running otherwise we get undefined behavior. So exit main after this function.

◆ ready

void CWSGI::WSGI::ready ( )
signal

It is emitted once the server is ready.

◆ start()

bool CWSGI::WSGI::start ( Cutelyst::Application app = nullptr)

Use this when you would like to embed the server in an application that is able to start/stop the server at will, for example with a push button.

This method does not support forking which includes master, lazy or processes properties.

Currentl

◆ stopped

void CWSGI::WSGI::stopped ( )
signal

It is emitted once the server shutdown is completed.

Property Documentation

◆ application

QString CWSGI::WSGI::application
readwrite

Defines application file path to be loaded, an alternative is to provide the Cutelyst::Application pointer to exec()

Accessors:\n application(), setApplication()

Definition at line 91 of file wsgi.h.

◆ auto_reload

bool CWSGI::WSGI::auto_reload
readwrite

Reload application if the application file is modified or touched

Accessors:\n autoReload(), setAutoReload()

Definition at line 247 of file wsgi.h.

◆ buffer_size

int CWSGI::WSGI::buffer_size
readwrite

Defines the buffer size used when parsing requests

Accessors:\n bufferSize(), setBufferSize()

Definition at line 273 of file wsgi.h.

◆ chdir

QString CWSGI::WSGI::chdir
readwrite

Defines directory to chdir to before application loading

Accessors:\n chdir(), setChdir()

Definition at line 116 of file wsgi.h.

◆ chdir2

QString CWSGI::WSGI::chdir2
readwrite

Defines directory to chdir to after application loading

Accessors:\n chdir2(), setChdir2()

Definition at line 198 of file wsgi.h.

◆ chown_socket

QString CWSGI::WSGI::chown_socket
readwrite

Defines owner of UNIX sockets.

Accessors:\n chownSocket(), setChownSocket()
Note
UNIX only

Definition at line 382 of file wsgi.h.

◆ cpu_affinity

int CWSGI::WSGI::cpu_affinity
readwrite

Defines CPU affinity

Accessors:\n cpuAffinity(), setCpuAffinity()
Note
UNIX only

Definition at line 400 of file wsgi.h.

◆ fastcgi_socket

QStringList CWSGI::WSGI::fastcgi_socket
readwrite

Defines how an FastCGI socket should be binded

Accessors:\n fastcgiSocket(), setFastcgiSocket()

Definition at line 174 of file wsgi.h.

◆ gid

QString CWSGI::WSGI::gid
readwrite

Defines group id of the process.

Accessors:\n gid(), setGid()
Note
UNIX only

Definition at line 364 of file wsgi.h.

◆ http2_header_table_size

quint32 CWSGI::WSGI::http2_header_table_size
readwrite

Defines the HTTP2 header table size (SETTINGS_HEADER_TABLE_SIZE) default value: 4096

Accessors:\n http2Socket(), setHttp2Socket()

Definition at line 140 of file wsgi.h.

◆ http2_socket

QStringList CWSGI::WSGI::http2_socket
readwrite

Defines how an HTTP2 socket should be binded

Accessors:\n http2Socket(), setHttp2Socket()

Definition at line 132 of file wsgi.h.

◆ http_socket

QStringList CWSGI::WSGI::http_socket
readwrite

Defines how an HTTP socket should be binded

Accessors:\n httpSocket(), setHttpSocket()

Definition at line 124 of file wsgi.h.

◆ https_h2

bool CWSGI::WSGI::https_h2
readwrite

Defines if HTTPS sockect should use ALPN to negotiate HTTP/2 Defaults to false

Accessors:\n http2Socket(), setHttp2Socket()

Definition at line 158 of file wsgi.h.

◆ https_socket

QStringList CWSGI::WSGI::https_socket
readwrite

Defines how an HTTPS socket should be binded

Accessors:\n httpsSocket(), setHttpsSocket()

Definition at line 166 of file wsgi.h.

◆ ini

QStringList CWSGI::WSGI::ini
readwrite

Load config from ini file

Accessors:\n ini(), setIni()

Definition at line 206 of file wsgi.h.

◆ json

QStringList CWSGI::WSGI::json
readwrite

Load config from JSON file

Accessors:\n json(), setJson()

Definition at line 214 of file wsgi.h.

◆ lazy

bool CWSGI::WSGI::lazy
readwrite

Defines is the Application should be lazy loaded.

Accessors:\n lazy(), setLazy()

Definition at line 417 of file wsgi.h.

◆ listen

int CWSGI::WSGI::listen
readwrite

Defines the socket listen queue size. This setting currently works only on Linux for TCP sockets.

Accessors:\n listenQueue(), setListenQueue()

Definition at line 265 of file wsgi.h.

◆ master

bool CWSGI::WSGI::master
readwrite

Defines if a master process should be created to watch for it's child processes

Accessors:\n master(), setMaster()

Definition at line 239 of file wsgi.h.

◆ no_initgroups

bool CWSGI::WSGI::no_initgroups
readwrite

Disable additional groups set via initgroups()

Accessors:\n noInitgroups(), setNoInitgroups()
Note
UNIX only

Definition at line 373 of file wsgi.h.

◆ pidfile

QString CWSGI::WSGI::pidfile
readwrite

Defines the pid file to be written before privileges drop

Accessors:\n pidfile(), setPidfile()

Definition at line 338 of file wsgi.h.

◆ pidfile2

QString CWSGI::WSGI::pidfile2
readwrite

Defines the pid file to be written before privileges drop

Accessors:\n pidfile(), setPidfile()

Definition at line 346 of file wsgi.h.

◆ post_buffering

qint64 CWSGI::WSGI::post_buffering
readwrite

Defines the maximum buffer size of POST request, if a request has a content length that is bigger than the post buffer size a temporary file is created instead

Accessors:\n postBuffering(), setPostBuffering()

Definition at line 282 of file wsgi.h.

◆ post_buffering_bufsize

qint64 CWSGI::WSGI::post_buffering_bufsize
readwrite

Defines the buffer size when reading a POST request

Accessors:\n postBufferingBufsize(), setPostBufferingBufsize()

Definition at line 290 of file wsgi.h.

◆ processes

QString CWSGI::WSGI::processes
readwrite

Defines the number of processes to use, if set to "auto" the ideal processes count is used

Accessors:\n threads(), setThreads()
Note
UNIX only

Definition at line 108 of file wsgi.h.

◆ reuse_port

bool CWSGI::WSGI::reuse_port
readwrite

Enable SO_REUSEPORT for the sockets

Accessors:\n reusePort(), setReusePort()
Note
Linux only

Definition at line 409 of file wsgi.h.

◆ so_keepalive

bool CWSGI::WSGI::so_keepalive
readwrite

Enable SO_KEEPALIVE for the sockets

Accessors:\n soKeepalive(), setSoKeepalive()

Definition at line 306 of file wsgi.h.

◆ socket_access

QString CWSGI::WSGI::socket_access
readwrite

Defines the file permissions of a local socket, u = user, g = group, o = others

Accessors:\n socketAccess(), setSocketAccess()

Definition at line 182 of file wsgi.h.

◆ socket_rcvbuf

int CWSGI::WSGI::socket_rcvbuf
readwrite

Sets the socket receive buffer size in bytes at the OS level. This maps to the SO_RCVBUF socket option

Accessors:\n socketRcvbuf(), setSocketRcvbuf()

Definition at line 322 of file wsgi.h.

◆ socket_sndbuf

int CWSGI::WSGI::socket_sndbuf
readwrite

Sets the socket send buffer size in bytes at the OS level. This maps to the SO_SNDBUF socket option

Accessors:\n socketSndbuf(), setSocketSndbuf()

Definition at line 314 of file wsgi.h.

◆ socket_timeout

int CWSGI::WSGI::socket_timeout
readwrite

Defines set internal socket timeout

Accessors:\n socketTimeout(), setSocketTimeout()

Definition at line 190 of file wsgi.h.

◆ static_map

QStringList CWSGI::WSGI::static_map
readwrite

Map the mountpoint to static directory (or file)

Accessors:\n staticMap(), setStaticMap()

Definition at line 222 of file wsgi.h.

◆ static_map2

QStringList CWSGI::WSGI::static_map2
readwrite

Map the mountpoint to static directory (or file), completely appending the requested resource to the docroot

Accessors:\n staticMap2(), setStaticMap2()

Definition at line 230 of file wsgi.h.

◆ tcp_nodelay

bool CWSGI::WSGI::tcp_nodelay
readwrite

Enable TCP NODELAY on each request

Accessors:\n tcpNodelay(), setTcpNodelay()

Definition at line 298 of file wsgi.h.

◆ threads

QString CWSGI::WSGI::threads
readwrite

Defines the number of threads to use, if set to "auto" the ideal thread count is used

Accessors:\n threads(), setThreads()

Definition at line 99 of file wsgi.h.

◆ touch_reload

QStringList CWSGI::WSGI::touch_reload
readwrite

Reload application if the specified file is modified or touched

Accessors:\n touchReload(), setTouchReload()

Definition at line 255 of file wsgi.h.

◆ uid

QString CWSGI::WSGI::uid
readwrite

Defines user id of the process.

Accessors:\n uid(), setUid()
Note
UNIX only

Definition at line 355 of file wsgi.h.

◆ umask

QString CWSGI::WSGI::umask
readwrite

Defines file mode creation mask

Accessors:\n umask(), setUmask()
Note
UNIX only

Definition at line 391 of file wsgi.h.

◆ upgrade_h2c

bool CWSGI::WSGI::upgrade_h2c
readwrite

Defines if an HTTP/1 connection can be upgraded to H2C (HTTP 2 Clear Text) Defaults to false

Accessors:\n http2Socket(), setHttp2Socket()

Definition at line 149 of file wsgi.h.

◆ using_frontend_proxy

bool CWSGI::WSGI::using_frontend_proxy
readwrite

Defines if a reverse proxy operates in front of this application server. If enabled, parses the http headers X-Forwarded-For, X-Forwarded-Host and X-Forwarded-Proto and uses this info to update Cutelyst::EngineRequest

Accessors:\n usingFrontendProxy(), setUsingFrontendProxy()

Definition at line 427 of file wsgi.h.

◆ websocket_max_size

int CWSGI::WSGI::websocket_max_size
readwrite

Sets the maximum allowed size of websocket messages (in Kbytes, default 1024)

Accessors:\n websocketMaxSize(), setWebsocketMaxSize()

Definition at line 330 of file wsgi.h.