BPS C++ API  2.24.4
BpsMdeRequest Class Reference

BPS MDE request. More...

#include <bpsmderequest.h>

+ Inheritance diagram for BpsMdeRequest:

Public Types

enum  Method { GET , POST , HEAD , PUT , DELETE , TRACE , OPTIONS , CONNECT }
 Request methods. More...
 
enum  MimeType { M_html , M_css , M_js , M_htc , M_ico , M_png , M_gif , M_jpg }
 MIME types used by BPS MDE server. More...
 
enum  Status { S_OK = 200 , S_SeeOther = 303 , S_Forbidden = 403 , S_NotFound = 404 , S_NotAllowed = 405 , S_ServerError = 500 }
 HTML status codes. More...
 

Public Member Functions

 BpsMdeRequest (QTcpSocket *aSocket, QObject *aParent=nullptr)
 Constructor for the BpsMdeRequest objects. More...
 
QByteArray data () const
 
QString endl () const
 
QString host () const
 
QTextStreamhtml ()
 
QString location () const
 
Method method () const
 
QString methodAsText () const
 
MimeType mimeType () const
 
bool mustClose () const
 
QVariantMap params () const
 For GET/POST parameter names ending with [], the values are stored as QStringList and the [] is removed from the name. More...
 
QString path () const
 
QString protocol () const
 
void redirect (const QString &aPath=QString())
 A convenience function to make redirections on the current server. More...
 
void sendReply ()
 Send the reply back to the client after setting the necessary status, text etc.
 
qlonglong sessionId () const
 
void setData (const QByteArray &aData)
 Put file contents to reply with in this. More...
 
void setLocation (const QString &aLocation)
 Set a redirection URL. More...
 
void setMaxAge (quint32 aSeconds)
 Set the content cache seconds. More...
 
void setMimeType (MimeType aMimeType)
 Set the MIME type for the reply. More...
 
void setMustClose ()
 Force connection close after reply.
 
void setSessionId (qlonglong aSessionId)
 Set a new session ID. More...
 
void setStatus (Status aStatus)
 Set the status for the reply. More...
 
QTcpSocketsocket () const
 
Status status () const
 
- Public Member Functions inherited from QObject
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
 QObject (QObject *parent)
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static MimeType getMimeType (const QString &aPath)
 Get the MIME type from a file name. More...
 
static QString httpDate (const QDateTime &aUtcDateTime)
 Format a UTC timestamp as HTTP date. More...
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

BPS MDE request.

This is basically a data container where the information of the parsed client request are first filled in by the MDE server. The request is then passed to the appropriate applications request handler to get the reply information added. Finally the MDE server takes the reply information and sends the reply back to the client.

Member Enumeration Documentation

◆ Method

Request methods.

Usually applications only need to handle GET and POST. The other requests are handled by the MDE server.

Enumerator
GET 

Request a resource from server.

POST 

Send data to server.

HEAD 

Like GET, but no body data sent.

PUT 

Upload a resource to server.

DELETE 

Delete a resource from server.

TRACE 

Loopback the request.

OPTIONS 

Query options supported by server.

CONNECT 

Server with proxy capability redirection.

◆ MimeType

MIME types used by BPS MDE server.

Enumerator
M_html 

Hypertext markup.

M_css 

Cascaded style sheet.

M_js 

Javascript.

M_htc 

HTML component.

M_ico 

Microsoft format icon.

M_png 

Portable network graphics.

M_gif 

Graphics interchange format.

M_jpg 

JPEG graphics.

◆ Status

HTML status codes.

Enumerator
S_OK 

Request succeeded.

S_SeeOther 

Request normal result is a redirection.

S_Forbidden 

Not authorized access.

S_NotFound 

Requested resource not found.

S_NotAllowed 

Client error, not allowed.

S_ServerError 

General server error.

Constructor & Destructor Documentation

◆ BpsMdeRequest()

BpsMdeRequest::BpsMdeRequest ( QTcpSocket aSocket,
QObject aParent = nullptr 
)

Constructor for the BpsMdeRequest objects.

Parameters
aSocketSocket having request lines ready to get read.
aParentPointer to an optional parent object.

Member Function Documentation

◆ data()

QByteArray BpsMdeRequest::data ( ) const
Returns
The data to send back to the client in the reply. Filled directly by the request handler for images and files, or indirectly the html stream for dynamic html content.

◆ endl()

QString BpsMdeRequest::endl ( ) const
Returns
Endline character(s) depending on the operating system (cr lf, or only lf). Use this to optionally break the html stream in lines for better human readability.

◆ getMimeType()

static MimeType BpsMdeRequest::getMimeType ( const QString aPath)
static

Get the MIME type from a file name.

Parameters
aPathThe file name or path.
Returns
The MIME type.

◆ host()

QString BpsMdeRequest::host ( ) const
Returns
The host URL found in the clients request.

◆ html()

QTextStream& BpsMdeRequest::html ( )
Returns
A text stream open already for convenience, operating on the data byte array. The stream has AutoDetectUnicode set to true.

◆ httpDate()

static QString BpsMdeRequest::httpDate ( const QDateTime aUtcDateTime)
static

Format a UTC timestamp as HTTP date.

Parameters
aUtcDateTimeThe date/time to format.
Returns
The formatted date

◆ location()

QString BpsMdeRequest::location ( ) const
Returns
Redirect location.

◆ method()

Method BpsMdeRequest::method ( ) const
Returns
The method of the request.

◆ methodAsText()

QString BpsMdeRequest::methodAsText ( ) const
Returns
The method as text.

◆ mimeType()

MimeType BpsMdeRequest::mimeType ( ) const
Returns
Mime type of the reply. Initialized to M_html, change by request handler as needed.

◆ mustClose()

bool BpsMdeRequest::mustClose ( ) const
Returns
True if the MDE server must close the connection after reply.

◆ params()

QVariantMap BpsMdeRequest::params ( ) const

For GET/POST parameter names ending with [], the values are stored as QStringList and the [] is removed from the name.

For other names the values are stored as QString; multiple values with same name are joined by comma in case.

Returns
The GET/POST parameters received in the clients request.

◆ path()

QString BpsMdeRequest::path ( ) const
Returns
The requested path (URL), without the GET parameters.

◆ protocol()

QString BpsMdeRequest::protocol ( ) const
Returns
The protocol used in the clients request, either HTTP/1.0 or HTTP/1.1.

◆ redirect()

void BpsMdeRequest::redirect ( const QString aPath = QString())

A convenience function to make redirections on the current server.

Status is set to S_SeeOther, the URL is created in the location field using the host name from the clients request, and HTML with a redirection link is added. sendReply() is called at the end, so there is no need to it after this function.

Parameters
aPathThe path to redirect to.

◆ sessionId()

qlonglong BpsMdeRequest::sessionId ( ) const
Returns
The current session ID. Initially this is highest session number found in the cookies of the request header, or -1 if none found.

◆ setData()

void BpsMdeRequest::setData ( const QByteArray aData)

Put file contents to reply with in this.

Use the html stream instead to fill with dynamic html code.

Parameters
aDataThe data posted back to the client.

◆ setLocation()

void BpsMdeRequest::setLocation ( const QString aLocation)

Set a redirection URL.

Also set status to S_SeeOther when doing this.

Parameters
aLocationThe redirection URL.

◆ setMaxAge()

void BpsMdeRequest::setMaxAge ( quint32  aSeconds)

Set the content cache seconds.

The default is 0, which means no caching.

Parameters
aSecondsSeconds to allow caching.

◆ setMimeType()

void BpsMdeRequest::setMimeType ( MimeType  aMimeType)

Set the MIME type for the reply.

Parameters
aMimeTypeThe new MIME type.

◆ setSessionId()

void BpsMdeRequest::setSessionId ( qlonglong  aSessionId)

Set a new session ID.

If the new session ID differs from the one received in the clients request, it will create a new session cookie upon reply.

Parameters
aSessionIdThe new session ID.

◆ setStatus()

void BpsMdeRequest::setStatus ( Status  aStatus)

Set the status for the reply.

Parameters
aStatusThe new status to set.

◆ socket()

QTcpSocket* BpsMdeRequest::socket ( ) const
Returns
The TCP/IP socket.

◆ status()

Status BpsMdeRequest::status ( ) const
Returns
The status for the reply. Initialized to S_OK, change by request handler as needed.

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