TreeFrogFramework  2.8
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, TActionContext *context)
 
 THttpRequest (const QByteArray &header, const QString &filePath, const QHostAddress &clientAddress, TActionContext *context)
 
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
 
QStringList queryItemList (const QString &key) const
 
QVariantList queryItemVariantList (const QString &key) const
 
QVariantMap queryItems (const QString &key) 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
 
QHostAddress originatingClientAddress () const
 
QIODevice * rawBody ()
 
bool hasJson () const
 
const QJsonDocument & jsonData () const
 

Static Public Member Functions

static QList< THttpRequestgenerate (QByteArray &byteArray, const QHostAddress &address, TActionContext *context)
 
static QList< QPair< QString, QString > > fromQuery (const QString &query)
 

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() [1/4]

THttpRequest::THttpRequest ( )

Constructor.

◆ THttpRequest() [2/4]

THttpRequest::THttpRequest ( const THttpRequest other)

Copy constructor.

◆ THttpRequest() [3/4]

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

Constructor with the header header and the body body.

◆ THttpRequest() [4/4]

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

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

◆ ~THttpRequest()

THttpRequest::~THttpRequest ( )
virtual

Destructor.

Member Function Documentation

◆ allFormItemValues()

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

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

See also
QStringList formItemList()

◆ allItemValues()

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

◆ allParameters()

QVariantMap THttpRequest::allParameters ( ) const

Returns a map of all form data.

◆ allQueryItemValues()

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

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

See also
QStringList queryItemList()

◆ boundary()

QByteArray THttpRequest::boundary ( ) const
protected

Returns the boundary of multipart/form-data.

◆ clientAddress()

QHostAddress THttpRequest::clientAddress ( ) const
inline

Returns the address of the client host.

◆ cookie()

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

Returns the cookie associated with the name.

◆ cookies()

QList< TCookie > THttpRequest::cookies ( ) const

Returns the all cookies.

◆ formItemList()

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.

See also
QStringList allFormItemValues()

◆ formItems() [1/2]

QVariantMap THttpRequest::formItems ( ) const

Returns the map of all form data.

◆ formItems() [2/2]

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

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

◆ formItemValue() [1/2]

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

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

◆ formItemValue() [2/2]

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.

◆ formItemVariantList()

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.

◆ fromQuery()

QList< QPair< QString, QString > > THttpRequest::fromQuery ( const QString &  query)
static

◆ generate()

QList< THttpRequest > THttpRequest::generate ( QByteArray &  byteArray,
const QHostAddress &  address,
TActionContext *  context 
)
static

◆ getHttpMethodOverride()

Tf::HttpMethod THttpRequest::getHttpMethodOverride ( ) const

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

◆ hasForm()

bool THttpRequest::hasForm ( ) const
inline

Returns true if the request contains form data.

◆ hasFormItem()

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.

◆ hasItem()

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

◆ hasJson()

bool THttpRequest::hasJson ( ) const
inline

Returns true if the request contains JSON data.

◆ hasQuery()

bool THttpRequest::hasQuery ( ) const
inline

Returns true if the URL contains a Query.

◆ hasQueryItem()

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.

◆ header()

const THttpRequestHeader & THttpRequest::header ( ) const
inline

Returns the HTTP header of the request.

◆ itemMap() [1/2]

QVariantMap THttpRequest::itemMap ( const QList< QPair< QString, QString >> &  items)
staticprotected

◆ itemMap() [2/2]

QVariantMap THttpRequest::itemMap ( const QString &  key,
const QList< QPair< QString, QString >> &  items 
)
staticprotected

◆ itemValue()

QString THttpRequest::itemValue ( const QString &  name,
const QString &  defaultValue,
const QList< QPair< QString, QString >> &  items 
)
staticprotected

◆ itemVariantList()

QVariantList THttpRequest::itemVariantList ( const QString &  key,
const QList< QPair< QString, QString >> &  items 
)
staticprotected

◆ jsonData()

const QJsonDocument & THttpRequest::jsonData ( ) const
inline

Return the JSON data contained in the request.

◆ method()

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

◆ multipartFormData()

TMultipartFormData & THttpRequest::multipartFormData ( )
inline

Returns a object of multipart/form-data.

◆ operator=()

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

Assignment operator.

◆ originatingClientAddress()

QHostAddress THttpRequest::originatingClientAddress ( ) const

Returns a originating IP address of the client by parsing the 'X-Forwarded-For' header of the request.

To enable this feature, edit application.ini and set the 'EnableForwardedForHeader' parameter to true and the 'TrustedProxyServers' parameter to IP addresses of the proxy servers.

◆ parameter()

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

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

◆ queryItemList()

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

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

See also
QStringList THttpRequest::allQueryItemValues()

◆ queryItemMethod()

Tf::HttpMethod THttpRequest::queryItemMethod ( ) const

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

◆ queryItems() [1/2]

QVariantMap THttpRequest::queryItems ( ) const

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

◆ queryItems() [2/2]

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

Returns the map of query value whose key is equal to key from the URL.

◆ queryItemValue() [1/2]

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

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

◆ queryItemValue() [2/2]

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.

◆ queryItemVariantList()

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

Returns the list of query value whose key is equal to key, such as "foo[]", from the URL.

◆ rawBody()

QIODevice * THttpRequest::rawBody ( )

◆ realMethod()

Tf::HttpMethod THttpRequest::realMethod ( ) const

Returns the real method of an HTTP request.

See also
THttpRequest::method()

Friends And Related Function Documentation

◆ TMultipartFormData

friend class TMultipartFormData
friend

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