TreeFrogFramework  1.18
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
THttpRequest Class Reference

#include <thttprequest.h>

Public Member Functions

 THttpRequest ()
 
 THttpRequest (const THttpRequest &other)
 
 THttpRequest (const THttpRequestHeader &header, const QByteArray &body, const QHostAddress &clientAddress)
 
 THttpRequest (const QByteArray &header, const QString &filePath, const QHostAddress &clientAddress)
 
virtual ~THttpRequest ()
 
THttpRequestoperator= (const THttpRequest &other)
 
const THttpRequestHeaderheader () const
 
Tf::HttpMethod method () const
 
Tf::HttpMethod realMethod () const
 
Tf::HttpMethod getHttpMethodOverride () const
 
Tf::HttpMethod queryItemMethod () const
 
QString parameter (const QString &name) const
 
QVariantMap allParameters () const
 
bool hasQuery () const
 
bool hasQueryItem (const QString &name) const
 
QString queryItemValue (const QString &name) const
 
QString queryItemValue (const QString &name, const QString &defaultValue) const
 
QStringList allQueryItemValues (const QString &name) const
 
QVariantMap queryItems () const
 
bool hasForm () const
 
bool hasFormItem (const QString &name) const
 
QString formItemValue (const QString &name) const
 
QString formItemValue (const QString &name, const QString &defaultValue) const
 
QStringList allFormItemValues (const QString &name) const
 
QStringList formItemList (const QString &key) const
 
QVariantList formItemVariantList (const QString &key) const
 
QVariantMap formItems (const QString &key) const
 
QVariantMap formItems () const
 
TMultipartFormDatamultipartFormData ()
 
QByteArray cookie (const QString &name) const
 
QList< TCookiecookies () const
 
QHostAddress clientAddress () const
 
bool hasJson () const
 
const QJsonDocument & jsonData () const
 

Static Public Member Functions

static QList< THttpRequestgenerate (const QByteArray &byteArray, const QHostAddress &address)
 

Protected Member Functions

QByteArray boundary () const
 

Static Protected Member Functions

static bool hasItem (const QString &name, const QList< QPair< QString, QString >> &items)
 
static QString itemValue (const QString &name, const QString &defaultValue, const QList< QPair< QString, QString >> &items)
 
static QStringList allItemValues (const QString &name, const QList< QPair< QString, QString >> &items)
 
static QVariantList itemVariantList (const QString &key, const QList< QPair< QString, QString >> &items)
 
static QVariantMap itemMap (const QList< QPair< QString, QString >> &items)
 
static QVariantMap itemMap (const QString &key, const QList< QPair< QString, QString >> &items)
 

Friends

class TMultipartFormData
 

Detailed Description

The THttpRequest class contains request information for HTTP.

Constructor & Destructor Documentation

THttpRequest::THttpRequest ( )

Constructor.

THttpRequest::THttpRequest ( const THttpRequest other)

Copy constructor.

THttpRequest::THttpRequest ( const THttpRequestHeader header,
const QByteArray &  body,
const QHostAddress &  clientAddress 
)

Constructor with the header header and the body body.

THttpRequest::THttpRequest ( const QByteArray &  header,
const QString &  filePath,
const QHostAddress &  clientAddress 
)

Constructor with the header header and a body generated by reading the file filePath.

THttpRequest::~THttpRequest ( )
virtual

Destructor.

Member Function Documentation

QStringList THttpRequest::allFormItemValues ( const QString &  name) const

Returns the list of string value whose name is equal to name from the form data.

QStringList THttpRequest::allItemValues ( const QString &  name,
const QList< QPair< QString, QString >> &  items 
)
staticprotected
QVariantMap THttpRequest::allParameters ( ) const

Returns a map of all form data.

QStringList THttpRequest::allQueryItemValues ( const QString &  name) const

Returns the list of query string values whose name is equal to name from the URL.

QByteArray THttpRequest::boundary ( ) const
protected

Returns the boundary of multipart/form-data.

QHostAddress THttpRequest::clientAddress ( ) const
inline

Returns the address of the client host.

QByteArray THttpRequest::cookie ( const QString &  name) const

Returns the cookie associated with the name.

QList< TCookie > THttpRequest::cookies ( ) const

Returns the all cookies.

QStringList THttpRequest::formItemList ( const QString &  key) const

Returns the list of string value whose key is equal to key, such as "foo[]", from the form data.

QVariantMap THttpRequest::formItems ( const QString &  key) const

Returns the map of variant value whose key is equal to key from the form data.

QVariantMap THttpRequest::formItems ( ) const

Returns the map of all form data.

QString THttpRequest::formItemValue ( const QString &  name) const

Returns the string value whose name is equal to name from the form data.

QString THttpRequest::formItemValue ( const QString &  name,
const QString &  defaultValue 
) const

This is an overloaded function.

Returns the string value whose name is equal to name from the form data. If the form data contains no item with the given name, the function returns defaultValue.

QVariantList THttpRequest::formItemVariantList ( const QString &  key) const

Returns the list of QVariant value whose key is equal to key, such as "foo[]", from the form data.

QList< THttpRequest > THttpRequest::generate ( const QByteArray &  byteArray,
const QHostAddress &  address 
)
static
Tf::HttpMethod THttpRequest::getHttpMethodOverride ( ) const

Returns a method value of X-HTTP methods override for REST API.

bool THttpRequest::hasForm ( ) const
inline

Returns true if the request contains form data.

bool THttpRequest::hasFormItem ( const QString &  name) const

Returns true if there is a string pair whose name is equal to name from the form data.

bool THttpRequest::hasItem ( const QString &  name,
const QList< QPair< QString, QString >> &  items 
)
staticprotected
bool THttpRequest::hasJson ( ) const
inline

Returns true if the request contains JSON data.

bool THttpRequest::hasQuery ( ) const
inline

Returns true if the URL contains a Query.

bool THttpRequest::hasQueryItem ( const QString &  name) const

Returns true if there is a query string pair whose name is equal to name from the URL.

const THttpRequestHeader & THttpRequest::header ( ) const
inline

Returns the HTTP header of the request.

QVariantMap THttpRequest::itemMap ( const QList< QPair< QString, QString >> &  items)
staticprotected
QVariantMap THttpRequest::itemMap ( const QString &  key,
const QList< QPair< QString, QString >> &  items 
)
staticprotected
QString THttpRequest::itemValue ( const QString &  name,
const QString &  defaultValue,
const QList< QPair< QString, QString >> &  items 
)
staticprotected
QVariantList THttpRequest::itemVariantList ( const QString &  key,
const QList< QPair< QString, QString >> &  items 
)
staticprotected
const QJsonDocument & THttpRequest::jsonData ( ) const
inline

Return the JSON data contained in the request.

Tf::HttpMethod THttpRequest::method ( ) const

Returns the method of an HTTP request, which can be overridden by another value, a query parameter named '_method' or X-HTTP-Method-Override header, etc.

See also
THttpRequest::realMethod()
EnableHttpMethodOverride of application.ini
TMultipartFormData & THttpRequest::multipartFormData ( )
inline

Returns a object of multipart/form-data.

THttpRequest & THttpRequest::operator= ( const THttpRequest other)

Assignment operator.

QString THttpRequest::parameter ( const QString &  name) const

Returns the string value whose name is equal to name from the URL or the form data.

Tf::HttpMethod THttpRequest::queryItemMethod ( ) const

Returns a method value as a query parameter named '_method' for REST API.

QVariantMap THttpRequest::queryItems ( ) const

Returns the query string of the URL, as a map of keys and values.

QString THttpRequest::queryItemValue ( const QString &  name) const

Returns the query string value whose name is equal to name from the URL.

QString THttpRequest::queryItemValue ( const QString &  name,
const QString &  defaultValue 
) const

This is an overloaded function.

Returns the query string value whose name is equal to name from the URL. If the query string contains no item with the given name, the function returns defaultValue.

Tf::HttpMethod THttpRequest::realMethod ( ) const

Returns the real method of an HTTP request.

See also
THttpRequest::method()

Friends And Related Function Documentation

friend class TMultipartFormData
friend

The documentation for this class was generated from the following files: