tufao
1.3.0
An asynchronous web framework for C++ built on top of Qt
|
The Tufao::HttpServer represents a HTTP request received by Tufao::HttpServer. More...
Signals | |
void | ready () |
This signal is emitted when most of the data about the request is available. More... | |
void | data () |
This signal is emitted each time a piece of the message body is received. More... | |
void | end () |
This signal is emitted exactly once for each request. More... | |
void | close () |
This signal is emitted when the underlaying connection is closed (also caused by invalid requests). More... | |
void | upgrade () |
This signal is emitted when a http upgrade is requested. More... | |
Public Member Functions | |
HttpServerRequest (QAbstractSocket &socket, QObject *parent=0) | |
Constructs a Tufao::HttpServerRequest object. More... | |
~HttpServerRequest () | |
Destroys the object. | |
QByteArray | method () const |
The request method. More... | |
void | setUrl (const QUrl &url) |
Sets the request URL. More... | |
QUrl | url () const |
The request URL. More... | |
Headers | headers () const |
The HTTP headers sent by the client. More... | |
Headers & | headers () |
The HTTP headers sent by the client. More... | |
Headers | trailers () const |
The HTTP trailers (if present). More... | |
HttpVersion | httpVersion () const |
Returns the HTTP protocol version used in the request. | |
QByteArray | readBody () |
Read the request's body. More... | |
QAbstractSocket & | socket () const |
The QAbstractSocket object associated with the connection. More... | |
void | setTimeout (int msecs=0) |
Sets the timeout of new connections to msecs miliseconds. More... | |
int | timeout () const |
Returns the current set timeout. | |
Tufao::HttpServerResponse::Options | responseOptions () const |
Returns the options obje that should be passed to the Tufao::HttpServerResponse constructor. More... | |
QVariant | customData () const |
Returns the user data as set in setCustomData. More... | |
void | setCustomData (const QVariant &data) |
Sets the custom data to data . More... | |
Friends | |
struct | Tufao::HttpServerRequest::Priv |
The Tufao::HttpServer represents a HTTP request received by Tufao::HttpServer.
|
explicit |
Constructs a Tufao::HttpServerRequest object.
parent
is passed to the QObject constructor.
socket | The connection used by Tufao::HttpServerRequest to receive HTTP messages. If you pass NULL, the object will be useless. |
|
signal |
This signal is emitted when the underlaying connection is closed (also caused by invalid requests).
Just like Tufao::HttpServerRequest::end, this signal is emitted only once per request, and no more data signals will fire afterwards.
QVariant Tufao::HttpServerRequest::customData | ( | ) | const |
Returns the user data as set in setCustomData.
|
signal |
This signal is emitted each time a piece of the message body is received.
Use readBody() to consume the data.
|
signal |
This signal is emitted exactly once for each request.
Use readBody() to access the request's body and trailers() to access the headers sent after the body.
After that, no more data signals will be emitted for this session. A new session (if any) will be only initiated after you respond the request.
Headers Tufao::HttpServerRequest::headers | ( | ) | const |
The HTTP headers sent by the client.
These headers are fully populated when the signal Tufao::HttpServerRequest::ready signal is emitted.
Headers& Tufao::HttpServerRequest::headers | ( | ) |
The HTTP headers sent by the client.
These headers are fully populated when the signal Tufao::HttpServerRequest::ready signal is emitted.
QByteArray Tufao::HttpServerRequest::method | ( | ) | const |
The request method.
It can assume the following values:
QByteArray Tufao::HttpServerRequest::readBody | ( | ) |
Read the request's body.
|
signal |
This signal is emitted when most of the data about the request is available.
After this signal is emitted, you can safely interpret the request and the only missing parts may be (if any) the message body and the trailers.
Tufao::HttpServerResponse::Options Tufao::HttpServerRequest::responseOptions | ( | ) | const |
Returns the options obje that should be passed to the Tufao::HttpServerResponse constructor.
void Tufao::HttpServerRequest::setCustomData | ( | const QVariant & | data | ) |
Sets the custom data to data
.
The custom data is a convenience method to allow users of HttpServerRequest to store some data in some requests. It's used in Tufao::HttpServerRequestRouter to pass the list of captured texts in the url to the subsequent handlers.
void Tufao::HttpServerRequest::setTimeout | ( | int | msecs = 0 | ) |
Sets the timeout of new connections to msecs
miliseconds.
The connection will be closed when no bytes are received during msecs
miliseconds.
If you set the timeout to 0, then timeout feature will be disabled.
By default, there is no timeout.
You can call this function at any time.
void Tufao::HttpServerRequest::setUrl | ( | const QUrl & | url | ) |
QAbstractSocket& Tufao::HttpServerRequest::socket | ( | ) | const |
The QAbstractSocket object associated with the connection.
This will be a QTcpSocket object if created by Tufao::HttpServer and a QSslSocket if created by Tufao::HttpsServer.
Headers Tufao::HttpServerRequest::trailers | ( | ) | const |
The HTTP trailers (if present).
Only populated after the Tufao::HttpServerRequest::end signal.
Trailers are headers sent after the body. Some headers can't be computed before the full body is generated. The solution to decrease the network latency is send the body before the associated metadata using the trailers technique.
|
signal |
This signal is emitted when a http upgrade is requested.
The body is set to the initial bytes from the new connection session (under the new protocol).
QUrl Tufao::HttpServerRequest::url | ( | ) | const |
The request URL.
This contains only the URL that is present in the actual HTTP request. If the request is:
GET /login?username=tux HTTP/1.1\r\n Accept: text/plain\r\n \r\n
Then Tufao::HttpServerRequest::url() will be constructed with "/login?username=tux".