BPS MDE request. More...
#include <bpsmderequest.h>
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=0) | |
| Constructor for the BpsMdeRequest objects. | |
| QByteArray | data () const |
| QString | endl () const |
| QString | host () const |
| QTextStream & | html () |
| 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. | |
| QString | path () const |
| QString | protocol () const |
| void | redirect (const QString &aPath=QString()) |
| A convenience function to make redirections on the current server. | |
| 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. | |
| void | setLocation (const QString &aLocation) |
| Set a redirection URL. | |
| void | setMaxAge (quint32 aSeconds) |
| Set the content cache seconds. | |
| void | setMimeType (MimeType aMimeType) |
| Set the MIME type for the reply. | |
| void | setMustClose () |
| Force connection close after reply. | |
| void | setSessionId (qlonglong aSessionId) |
| Set a new session ID. | |
| void | setStatus (Status aStatus) |
| Set the status for the reply. | |
| QTcpSocket * | socket () const |
| Status | status () const |
Static Public Member Functions | |
| static MimeType | getMimeType (const QString &aPath) |
| Get the MIME type from a file name. | |
| static QString | httpDate (const QDateTime &aUtcDateTime) |
| Format a UTC timestamp as HTTP date. | |
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.
Request methods.
Usually applications only need to handle GET and POST. The other requests are handled by the MDE server.
| BpsMdeRequest::BpsMdeRequest | ( | QTcpSocket * | aSocket, |
| QObject * | aParent = 0 |
||
| ) |
Constructor for the BpsMdeRequest objects.
| aSocket | Socket having request lines ready to get read. |
| aParent | Pointer to an optional parent object. |
| QByteArray BpsMdeRequest::data | ( | ) | const |
| QString BpsMdeRequest::endl | ( | ) | const |
| static MimeType BpsMdeRequest::getMimeType | ( | const QString & | aPath | ) | [static] |
Get the MIME type from a file name.
| [in] | aPath | The file name or path. |
| QString BpsMdeRequest::host | ( | ) | const |
| QTextStream& BpsMdeRequest::html | ( | ) |
| static QString BpsMdeRequest::httpDate | ( | const QDateTime & | aUtcDateTime | ) | [static] |
Format a UTC timestamp as HTTP date.
| [in] | aUtcDateTime | The date/time to format. |
| QString BpsMdeRequest::location | ( | ) | const |
| Method BpsMdeRequest::method | ( | ) | const |
| QString BpsMdeRequest::methodAsText | ( | ) | const |
| MimeType BpsMdeRequest::mimeType | ( | ) | const |
| bool BpsMdeRequest::mustClose | ( | ) | const |
| 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.
| QString BpsMdeRequest::path | ( | ) | const |
| QString BpsMdeRequest::protocol | ( | ) | const |
| 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.
| [in] | aPath | The path to redirect to. |
| qlonglong BpsMdeRequest::sessionId | ( | ) | const |
| 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.
| [in] | aData | The data posted back to the client. |
| void BpsMdeRequest::setLocation | ( | const QString & | aLocation | ) |
Set a redirection URL.
Also set status to S_SeeOther when doing this.
| [in] | aLocation | The redirection URL. |
| void BpsMdeRequest::setMaxAge | ( | quint32 | aSeconds | ) |
Set the content cache seconds.
The default is 0, which means no caching.
| [in] | aSeconds | Seconds to allow caching. |
| void BpsMdeRequest::setMimeType | ( | MimeType | aMimeType | ) |
Set the MIME type for the reply.
| [in] | aMimeType | The new MIME type. |
| 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.
| [in] | aSessionId | The new session ID. |
| void BpsMdeRequest::setStatus | ( | Status | aStatus | ) |
Set the status for the reply.
| [in] | aStatus | The new status to set. |
| QTcpSocket* BpsMdeRequest::socket | ( | ) | const |
| Status BpsMdeRequest::status | ( | ) | const |