CopperSpice API  1.9.1
QHttpRequestHeader Class Reference

Contains request header information for HTTP. More...

Inherits QHttpHeader

Public Methods

 QHttpRequestHeader ()
 
 QHttpRequestHeader (const QHttpRequestHeader &other)
 
 QHttpRequestHeader (const QString &method, const QString &path, int majorVer=1, int minorVer=1)
 
 QHttpRequestHeader (const QString &str)
 
int majorVersion () const override
 
QString method () const
 
int minorVersion () const override
 
QHttpRequestHeader & operator= (const QHttpRequestHeader &other)
 
QString path () const
 
void setRequest (const QString &method, const QString &path, int majorVer=1, int minorVer=1)
 
QString toString () const override
 

Detailed Description

The QHttpRequestHeader class contains request header information for HTTP. HTTP requests have a method which describes the request's action. The most common requests are "GET" and "POST". In addition to the request method the header also includes a request-URI to specify the location for the method to use.

The HTTP method request-URI and protocol-version can be set using a constructor or later using setRequest(). The values can be obtained using method(), path(), majorVersion() and minorVersion().

The request-URI must be in the format expected by the HTTP server. All reserved characters must be encoded in HH (where HH are two hexadecimal digits). See QUrl::toPercentEncoding() for more information.

See also
QHttpResponseHeader

Constructor & Destructor Documentation

QHttpRequestHeader::QHttpRequestHeader ( )

Constructs an empty HTTP request header.

QHttpRequestHeader::QHttpRequestHeader ( const QString method,
const QString path,
int  majorVer = 1,
int  minorVer = 1 
)

Constructs an HTTP request header for the given method, the request URI path and the protocol version majorVer and minorVer. The path argument must be properly encoded for an HTTP request.

QHttpRequestHeader::QHttpRequestHeader ( const QHttpRequestHeader &  other)

Copy constructs from other.

QHttpRequestHeader::QHttpRequestHeader ( const QString str)

Constructs a HTTP request header from the string str. The string should consist of one or more lines separated by a carriage return or line feed.

The first line should be the request-line (format: method, space, request-URI, space HTTP-version) and each of the remaining lines should have the format key, colon, space, value.

Method Documentation

int QHttpRequestHeader::majorVersion ( ) const
override

Returns the major protocol-version of the HTTP request header.

See also
minorVersion(), method(), path(), setRequest()
QString QHttpRequestHeader::method ( ) const

Returns the method of the HTTP request header.

See also
path(), majorVersion(), minorVersion(), setRequest()
int QHttpRequestHeader::minorVersion ( ) const
override

Returns the minor protocol-version of the HTTP request header.

See also
majorVersion(), method(), path(), setRequest()
QHttpRequestHeader & QHttpRequestHeader::operator= ( const QHttpRequestHeader &  other)

Copy assigns from other and returns a reference to this object.

QString QHttpRequestHeader::path ( ) const

Returns the request-URI of the HTTP request header.

See also
method(), majorVersion(), minorVersion(), setRequest()
void QHttpRequestHeader::setRequest ( const QString method,
const QString path,
int  majorVer = 1,
int  minorVer = 1 
)

This method sets the request method to method, the request-URI to path and the protocol-version to majorVer and minorVer. The path argument must be properly encoded for an HTTP request.

See also
method(), path(), majorVersion(), minorVersion()
QString QHttpRequestHeader::toString ( ) const
override

Returns the HTTP response header as a string.