KVIrc
4.9.2
DeveloperAPIs
|
The QHttpHeader class contains header information for HTTP. More...
#include <qhttp.h>
Public Member Functions | |
void | addValue (const QString &key, const QString &value) |
QStringList | allValues (const QString &key) const |
uint | contentLength () const |
QString | contentType () const |
bool | hasContentLength () const |
bool | hasContentType () const |
bool | hasKey (const QString &key) const |
bool | isValid () const |
QStringList | keys () const |
virtual int | majorVersion () const =0 |
virtual int | minorVersion () const =0 |
QHttpHeader & | operator= (const QHttpHeader &h) |
QHttpHeader () | |
QHttpHeader (const QHttpHeader &header) | |
QHttpHeader (const QString &str) | |
void | removeAllValues (const QString &key) |
void | removeValue (const QString &key) |
void | setContentLength (int len) |
void | setContentType (const QString &type) |
void | setValue (const QString &key, const QString &value) |
void | setValues (const QList< QPair< QString, QString >> &values) |
virtual QString | toString () const |
QString | value (const QString &key) const |
QList< QPair< QString, QString > > | values () const |
virtual | ~QHttpHeader () |
Protected Member Functions | |
bool | parse (const QString &str) |
virtual bool | parseLine (const QString &line, int number) |
QHttpHeader (QHttpHeaderPrivate &dd, const QString &str=QString()) | |
QHttpHeader (QHttpHeaderPrivate &dd, const QHttpHeader &header) | |
void | setValid (bool) |
Protected Attributes | |
QScopedPointer < QHttpHeaderPrivate > | d_ptr |
The QHttpHeader class contains header information for HTTP.
QtNetwork
In most cases you should use the more specialized derivatives of this class, QHttpResponseHeader and QHttpRequestHeader, rather than directly using QHttpHeader.
QHttpHeader provides the HTTP header fields. A HTTP header field consists of a name followed by a colon, a single space, and the field value. (See RFC 1945.) Field names are case-insensitive. A typical header field looks like this:
In the API the header field name is called the "key" and the content is called the "value". You can get and set a header field's value by using its key with value() and setValue(), e.g.
Some fields are so common that getters and setters are provided for them as a convenient alternative to using value() and setValue(), e.g. contentLength() and contentType(), setContentLength() and setContentType().
Each header key has a single value associated with it. If you set the value for a key which already exists the previous value will be discarded.
QHttpHeader::QHttpHeader | ( | ) |
Constructs an empty HTTP header.
References d.
QHttpHeader::QHttpHeader | ( | const QHttpHeader & | header | ) |
QHttpHeader::QHttpHeader | ( | const QString & | str | ) |
|
virtualdefault |
Destructor.
|
protected |
|
protected |
void QHttpHeader::addValue | ( | const QString & | key, |
const QString & | value | ||
) |
QStringList QHttpHeader::allValues | ( | const QString & | key | ) | const |
Returns all the entries with the given key. If no entry has this key, an empty string list is returned.
References d.
uint QHttpHeader::contentLength | ( | ) | const |
Returns the value of the special HTTP header field content-length
.
References value().
Referenced by QHttpPrivate::_q_slotClosed(), and QHttpPrivate::_q_slotReadyRead().
QString QHttpHeader::contentType | ( | ) | const |
Returns the value of the special HTTP header field content-type
.
References KviRuntimeInfo::type(), and value().
bool QHttpHeader::hasContentLength | ( | ) | const |
Returns true if the header has an entry for the special HTTP header field content-length
; otherwise returns false.
References hasKey().
Referenced by QHttpPrivate::_q_slotReadyRead().
bool QHttpHeader::hasContentType | ( | ) | const |
Returns true if the header has an entry for the special HTTP header field content-type
; otherwise returns false.
References hasKey().
bool QHttpHeader::hasKey | ( | const QString & | key | ) | const |
Returns true if the HTTP header has an entry with the given key; otherwise returns false.
References d.
Referenced by QHttpPrivate::_q_slotClosed(), QHttpPrivate::_q_slotReadyRead(), hasContentLength(), and hasContentType().
bool QHttpHeader::isValid | ( | ) | const |
Returns true if the HTTP header is valid; otherwise returns false.
A QHttpHeader is invalid if it was created by parsing a malformed string.
References d.
Referenced by QHttpPrivate::_q_slotReadyRead(), and toString().
QStringList QHttpHeader::keys | ( | ) | const |
|
pure virtual |
Returns the major protocol-version of the HTTP header.
Implemented in QHttpRequestHeader, and QHttpResponseHeader.
|
pure virtual |
Returns the minor protocol-version of the HTTP header.
Implemented in QHttpRequestHeader, and QHttpResponseHeader.
QHttpHeader & QHttpHeader::operator= | ( | const QHttpHeader & | h | ) |
Assigns h and returns a reference to this http header.
Referenced by QHttpResponseHeader::operator=(), and QHttpRequestHeader::operator=().
|
protected |
References d, and parseLine().
Referenced by QHttpHeader(), QHttpRequestHeader::QHttpRequestHeader(), and QHttpResponseHeader::QHttpResponseHeader().
|
protectedvirtual |
Reimplemented in QHttpRequestHeader, and QHttpResponseHeader.
References addValue(), and i.
Referenced by parse(), QHttpResponseHeader::parseLine(), and QHttpRequestHeader::parseLine().
void QHttpHeader::removeAllValues | ( | const QString & | key | ) |
Removes all the entries with the key key from the HTTP header.
References d.
void QHttpHeader::removeValue | ( | const QString & | key | ) |
void QHttpHeader::setContentLength | ( | int | len | ) |
Sets the value of the special HTTP header field content-length
to len.
References setValue().
void QHttpHeader::setContentType | ( | const QString & | type | ) |
Sets the value of the special HTTP header field content-type
to type.
References setValue().
|
protected |
void QHttpHeader::setValue | ( | const QString & | key, |
const QString & | value | ||
) |
Sets the value of the entry with the key to value.
If no entry with key exists, a new entry with the given key and value is created. If an entry with the key already exists, the first value is discarded and replaced with the given value.
References addValue(), d, and value().
Referenced by QHttpPrivate::_q_slotSendRequest(), QHttp::get(), QHttp::head(), QHttp::post(), setContentLength(), setContentType(), and QHttpPGHRequest::start().
void QHttpHeader::setValues | ( | const QList< QPair< QString, QString >> & | values | ) |
|
virtual |
Returns a string representation of the HTTP header.
The string is suitable for use by the constructor that takes a QString. It consists of lines with the format: key, colon, space, value, "\r\n".
Reimplemented in QHttpRequestHeader, and QHttpResponseHeader.
Referenced by QHttpResponseHeader::toString(), and QHttpRequestHeader::toString().
QString QHttpHeader::value | ( | const QString & | key | ) | const |
Returns the first value for the entry with the given key. If no entry has this key, an empty string is returned.
References d.
Referenced by QHttpPrivate::_q_slotConnected(), QHttpPrivate::_q_slotReadyRead(), contentLength(), contentType(), KvsObject_http::redirect(), and setValue().
QList< QPair< QString, QString > > QHttpHeader::values | ( | ) | const |
Returns all the entries in the header.
References d.
Referenced by operator=(), QHttpAuthenticatorPrivate::parseHttpResponse(), QHttpHeader(), and setValues().
|
protected |