Handles a single HTTP connection. More...
#include <HTTPConnection.h>
Inherits QObject.
Inherited by HTTPSConnection.
Public Types | |
enum | ReasonCode |
WebSocket close status codes. | |
Public Member Functions | |
HTTPConnection (QTcpSocket *socket, HTTPManager *parentManager) | |
Initializes the connection. | |
virtual | ~HTTPConnection () |
Destroys the connection. | |
QTcpSocket * | socket () const |
Returns a pointer to the underlying socket, to which WebSocket message bodies should be written. | |
const QHostAddress & | peerAddress () const |
Returns the IP address on the other side of the connection. | |
QNetworkAccessManager::Operation | requestOperation () const |
Returns the request operation. | |
const QUrl & | requestUrl () const |
Returns a reference to the request URL. | |
QByteArray | requestHeader (const QString &key) const |
Returns a copy of the request header value. If it does not exist, it will return a default constructed QByteArray. | |
const QByteArray & | requestContent () const |
Returns a reference to the request content. | |
QList< FormData > | parseFormData () const |
Parses the request content as form data, returning a list of header/content pairs. | |
QHash< QString, QString > | parseUrlEncodedForm () |
void | respond (const char *code, const QByteArray &content=QByteArray(), const char *contentType=DefaultContentType, const Headers &headers=Headers()) |
Sends a response and closes the connection. | |
Protected Slots | |
void | readRequest () |
Reads the request line. | |
void | readHeaders () |
Reads the headers. | |
void | readContent () |
Reads the content. | |
Protected Attributes | |
HTTPManager * | _parentManager |
The parent HTTP manager. | |
QTcpSocket * | _socket |
The underlying socket. | |
QHostAddress | _address |
The stored address. | |
QNetworkAccessManager::Operation | _requestOperation |
The requested operation. | |
QUrl | _requestUrl |
The requested URL. | |
Headers | _requestHeaders |
The request headers. | |
QByteArray | _lastRequestHeader |
The last request header processed (used for continuations). | |
std::unique_ptr< Storage > | _requestContent |
The content of the request. | |
std::unique_ptr< QIODevice > | _responseDevice |
Response content. | |
Handles a single HTTP connection.
QHash< QString, QString > HTTPConnection::parseUrlEncodedForm | ( | ) |
Parses the request content as a url encoded form, returning a hash of key/value pairs. Duplicate keys are not supported.