Stellarium 0.15.2
|
This object represents a single HTTP request. More...
#include <httprequest.h>
Public Types | |
enum | RequestStatus { waitForRequest, waitForHeader, waitForBody, complete, abort } |
Values for getStatus() More... | |
Public Member Functions | |
HttpRequest (const int maxRequestSize, const int maxMultiPartSize) | |
Constructor. More... | |
virtual | ~HttpRequest () |
Destructor. More... | |
void | readFromSocket (QTcpSocket *socket) |
Read the HTTP request from a socket. More... | |
RequestStatus | getStatus () const |
Get the status of this reqeust. More... | |
QByteArray | getMethod () const |
Get the method of the HTTP request (e.g. More... | |
QByteArray | getPath () const |
Get the decoded path of the HTPP request (e.g. More... | |
const QByteArray & | getRawPath () const |
Get the raw path of the HTTP request (e.g. More... | |
QByteArray | getVersion () const |
Get the version of the HTPP request (e.g. More... | |
QByteArray | getHeader (const QByteArray &name) const |
Get the value of a HTTP request header. More... | |
QList< QByteArray > | getHeaders (const QByteArray &name) const |
Get the values of a HTTP request header. More... | |
QMultiMap< QByteArray, QByteArray > | getHeaderMap () const |
Get all HTTP request headers. More... | |
QByteArray | getParameter (const QByteArray &name) const |
Get the value of a HTTP request parameter. More... | |
QList< QByteArray > | getParameters (const QByteArray &name) const |
Get the values of a HTTP request parameter. More... | |
QMultiMap< QByteArray, QByteArray > | getParameterMap () const |
Get all HTTP request parameters. More... | |
QByteArray | getBody () const |
Get the HTTP request body. More... | |
QTemporaryFile * | getUploadedFile (const QByteArray fieldName) const |
Get an uploaded file. More... | |
QByteArray | getCookie (const QByteArray &name) const |
Get the value of a cookie. More... | |
QMap< QByteArray, QByteArray > & | getCookieMap () |
Get all cookies. More... | |
QHostAddress | getPeerAddress () const |
Get the address of the connected client. More... | |
Static Public Member Functions | |
static QByteArray | urlDecode (const QByteArray source) |
Decode an URL parameter. More... | |
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 36 of file httprequest.h.
Values for getStatus()
Definition at line 43 of file httprequest.h.
HttpRequest::HttpRequest | ( | const int | maxRequestSize, |
const int | maxMultiPartSize | ||
) |
Constructor.
settings | Configuration settings |
|
virtual |
Destructor.
QByteArray HttpRequest::getBody | ( | ) | const |
Get the HTTP request body.
QByteArray HttpRequest::getCookie | ( | const QByteArray & | name | ) | const |
Get the value of a cookie.
name | Name of the cookie |
QMap<QByteArray,QByteArray>& HttpRequest::getCookieMap | ( | ) |
Get all cookies.
QByteArray HttpRequest::getHeader | ( | const QByteArray & | name | ) | const |
Get the value of a HTTP request header.
name | Name of the header |
QMultiMap<QByteArray,QByteArray> HttpRequest::getHeaderMap | ( | ) | const |
Get all HTTP request headers.
QList<QByteArray> HttpRequest::getHeaders | ( | const QByteArray & | name | ) | const |
Get the values of a HTTP request header.
name | Name of the header |
QByteArray HttpRequest::getMethod | ( | ) | const |
Get the method of the HTTP request (e.g.
"GET")
QByteArray HttpRequest::getParameter | ( | const QByteArray & | name | ) | const |
Get the value of a HTTP request parameter.
name | Name of the parameter |
QMultiMap<QByteArray,QByteArray> HttpRequest::getParameterMap | ( | ) | const |
Get all HTTP request parameters.
QList<QByteArray> HttpRequest::getParameters | ( | const QByteArray & | name | ) | const |
Get the values of a HTTP request parameter.
name | Name of the parameter |
QByteArray HttpRequest::getPath | ( | ) | const |
Get the decoded path of the HTPP request (e.g.
"/index.html")
QHostAddress HttpRequest::getPeerAddress | ( | ) | const |
Get the address of the connected client.
Note that multiple clients may have the same IP address, if they share an internet connection (which is very common).
const QByteArray& HttpRequest::getRawPath | ( | ) | const |
Get the raw path of the HTTP request (e.g.
"/file%20with%20spaces.html")
RequestStatus HttpRequest::getStatus | ( | ) | const |
Get the status of this reqeust.
QTemporaryFile* HttpRequest::getUploadedFile | ( | const QByteArray | fieldName | ) | const |
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.
QByteArray HttpRequest::getVersion | ( | ) | const |
Get the version of the HTPP request (e.g.
"HTTP/1.1")
void HttpRequest::readFromSocket | ( | QTcpSocket * | socket | ) |
Read the HTTP request from a socket.
This method is called by the connection handler repeatedly until the status is RequestStatus::complete or RequestStatus::abort.
socket | Source of the data |
|
static |
Decode an URL parameter.
E.g. replace "%23" by '#' and replace '+' by ' '.
source | The url encoded strings |