This object represents a single HTTP request. More...
#include <httprequest.h>
Public Types | |
enum | RequestStatus { waitForRequest, waitForHeader, waitForBody, complete, abort } |
Values for getStatus(). | |
Public Member Functions | |
HttpRequest (QSettings *settings) | |
Constructor. | |
virtual | ~HttpRequest () |
Destructor. | |
void | readFromSocket (QTcpSocket &socket) |
Read the request from a socket. | |
RequestStatus | getStatus () const |
Get the status of this reqeust. | |
QByteArray | getMethod () const |
Get the method of the HTTP request (e.g. | |
QByteArray | getPath () const |
Get the decoded path of the HTPP request (e.g. | |
QByteArray | getVersion () const |
Get the version of the HTPP request (e.g. | |
QByteArray | getHeader (const QByteArray &name) const |
Get the value of a HTTP request header. | |
QList< QByteArray > | getHeaders (const QByteArray &name) const |
Get the values of a HTTP request header. | |
QMultiMap< QByteArray, QByteArray > | getHeaderMap () const |
Get all HTTP request headers. | |
QByteArray | getParameter (const QByteArray &name) const |
Get the value of a HTTP request parameter. | |
QList< QByteArray > | getParameters (const QByteArray &name) const |
Get the values of a HTTP request parameter. | |
QMultiMap< QByteArray, QByteArray > | getParameterMap () const |
Get all HTTP request parameters. | |
QByteArray | getBody () const |
Get the HTTP request body. | |
QTemporaryFile * | getUploadedFile (const QByteArray fieldName) |
Get an uploaded file. | |
QByteArray | getCookie (const QByteArray &name) const |
Get the value of a cookie. | |
QMap< QByteArray, QByteArray > & | getCookieMap () |
Get the map of cookies. | |
Static Public Member Functions | |
static QByteArray | urlDecode (const QByteArray source) |
Decode an URL parameter. | |
Friends | |
class | HttpSessionStore |
This object represents a single HTTP request.
It reads the request from a TCP socket and provides getters for the individual parts of the request.
The follwing config settings are required:
maxRequestSize=16000 maxMultiPartSize=1000000
MaxRequestSize is the maximum size of a HTTP request. In case of multipart/form-data requests (also known as file-upload), the maximum size of the body must not exceed maxMultiPartSize. The body is always a little larger than the file itself.
Definition at line 34 of file httprequest.h.
HttpRequest::HttpRequest | ( | QSettings * | settings | ) |
Constructor.
settings | Configuration settings |
Definition at line 11 of file httprequest.cpp.
QByteArray HttpRequest::getCookie | ( | const QByteArray & | name | ) | const |
Get the value of a cookie.
name | Name of the cookie |
Definition at line 427 of file httprequest.cpp.
QByteArray HttpRequest::getHeader | ( | const QByteArray & | name | ) | const |
Get the value of a HTTP request header.
name | Name of the header |
Definition at line 271 of file httprequest.cpp.
QList< QByteArray > HttpRequest::getHeaders | ( | const QByteArray & | name | ) | const |
Get the values of a HTTP request header.
name | Name of the header |
Definition at line 275 of file httprequest.cpp.
QByteArray HttpRequest::getMethod | ( | ) | const |
QByteArray HttpRequest::getParameter | ( | const QByteArray & | name | ) | const |
Get the value of a HTTP request parameter.
name | Name of the parameter |
Definition at line 283 of file httprequest.cpp.
QList< QByteArray > HttpRequest::getParameters | ( | const QByteArray & | name | ) | const |
Get the values of a HTTP request parameter.
name | Name of the parameter |
Definition at line 287 of file httprequest.cpp.
QByteArray HttpRequest::getPath | ( | ) | const |
Get the decoded path of the HTPP request (e.g.
"/index.html")
Definition at line 261 of file httprequest.cpp.
HttpRequest::RequestStatus HttpRequest::getStatus | ( | ) | const |
Get the status of this reqeust.
Definition at line 251 of file httprequest.cpp.
QTemporaryFile * HttpRequest::getUploadedFile | ( | const QByteArray | fieldName | ) |
Get an uploaded file.
The file is already open. It will be closed and deleted by the destructor of this HttpRequest object (after processing the request).
For uploaded files, the method getParameters() returns the original fileName as provided by the calling web browser.
Definition at line 423 of file httprequest.cpp.
QByteArray HttpRequest::getVersion | ( | ) | const |
Get the version of the HTPP request (e.g.
"HTTP/1.1")
Definition at line 266 of file httprequest.cpp.
void HttpRequest::readFromSocket | ( | QTcpSocket & | socket | ) |
Read the request from a socket.
This method must be called repeatedly until the status is RequestStatus::complete or RequestStatus::abort.
socket | Source of the data |
Definition at line 227 of file httprequest.cpp.
QByteArray HttpRequest::urlDecode | ( | const QByteArray | source | ) | [static] |
Decode an URL parameter.
E.g. replace "%23" by '#' and replace '+' by ' '
source | The url encoded string |
Definition at line 299 of file httprequest.cpp.