Class sh::ui::web::WebServerEngineRequest

class sh::ui::web::WebServerEngineRequest

A web request in a WebServerEngine.

Override this together with WebServerEngine.

Public Functions

WebServerEngineRequest(QString url, QString clientHost)
QUrl url()

Returns the requested url.

Note: The url should be considered as opaque, since the exact structure depends on the engine implementation.

QString clientHost()

Returns the client host address.

QString path()

Returns the path part of the requested url.

Note: The url should be considered as opaque, since the exact structure depends on the engine implementation.

QString data(QString key)

Returns data passed as parameter along with the request by key.

int responseCode()

Returns the answered (http) response code.

QString responseMimeType()

Returns the mimetype of the answer content.

QByteArray response()

Returns the answer content.

bool responseSet()

Returns if a response was set.

void setResponse(QByteArray response, QString mimetype, int responseCode = HTTP_OK)

Sets the response.

void setResponse(QJsonArray response, int responseCode = HTTP_OK)
void setResponse(QJsonObject response, int responseCode = HTTP_OK)
QString headerData(QString key) = 0

Returns an http header value by key. .

QString getCookie(QString key) = 0

Returns an http cookie stored on browser side.

Note: This only works on dispatcher level and not in usual WebModule commands.

void setCookie(QString key, QString value, int maxAgeSecs = -1) = 0

Sets an http cookie to be returned to the browser side.

Note: This only works on dispatcher level and not in usual WebModule commands.

Public Static Attributes

const int HTTP_OK = 200
const int HTTP_SEE_OTHER = 303
const int HTTP_NOT_FOUND = 404
const int HTTP_INTERNAL_SERVER_ERROR = 500
const int HTTP_BAD_GATEWAY = 502

Private Members

QUrl _url
QString _clientHost
QString _path
QMap<QString, QString> _getdata
int _responseCode = HTTP_NOT_FOUND
QString _responseMimeType = "application/octet-stream"
QByteArray _response
bool _responseSet = false