Qt:Документация 4.3.2/qhttpheader

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QHttpHeader Class Reference
[модуль QtNetwork ]

The QHttpHeader class contains header information for HTTP. Далее...

 #include <QHttpHeader>

Inherited by QHttpRequestHeader and QHttpResponseHeader.

[править] Открытые функции


[править] Подробное описание

The QHttpHeader class contains header information for HTTP.

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:

 content-type: text/html

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.

 header.setValue("content-type", "text/html");
 QString contentType = header.value("content-type");

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.

See also QHttpRequestHeader and QHttpResponseHeader.


[править] Описание функций-членов

[править]
QHttpHeader::QHttpHeader ()

Constructs an empty HTTP header.

[править]
QHttpHeader::QHttpHeader ( const QHttpHeader & header )

Constructs a copy of header.

[править]
QHttpHeader::QHttpHeader ( const QString & str )

Constructs a HTTP header for str.

This constructor parses the string str for header fields and adds this information. The str should consist of one or more "\r\n" delimited lines; each of these lines should have the format key, colon, space, value.

[править]
QHttpHeader::~QHttpHeader () [virtual]

Деструктор.

[править]
void QHttpHeader::addValue ( const QString & key, const QString & value )

Adds a new entry with the key and 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.

[править]
uint QHttpHeader::contentLength () const

Returns the value of the special HTTP header field content-length.

See also setContentLength() and hasContentLength().

[править]
QString QHttpHeader::contentType () const

Returns the value of the special HTTP header field content-type.

See also setContentType() and hasContentType().

[править]
bool QHttpHeader::hasContentLength () const

Returns true if the header has an entry for the special HTTP header field content-length; otherwise returns false.

See also contentLength() and setContentLength().

[править]
bool QHttpHeader::hasContentType () const

Returns true if the header has an entry for the the special HTTP header field content-type; otherwise returns false.

See also contentType() and setContentType().

[править]
bool QHttpHeader::hasKey ( const QString & key ) const

Returns true if the HTTP header has an entry with the given key; otherwise returns false.

See also value(), setValue(), and keys().

[править]
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.

[править]
QStringList QHttpHeader::keys () const

Returns a list of the keys in the HTTP header.

See also hasKey().

[править]
int QHttpHeader::majorVersion () const [pure virtual]

Returns the major protocol-version of the HTTP header.

[править]
int QHttpHeader::minorVersion () const [pure virtual]

Returns the minor protocol-version of the HTTP header.

[править]
void QHttpHeader::removeAllValues ( const QString & key )

Removes all the entries with the key key from the HTTP header.

[править]
void QHttpHeader::removeValue ( const QString & key )

Removes the entry with the key key from the HTTP header.

See also value() and setValue().

[править]
void QHttpHeader::setContentLength ( int len )

Sets the value of the special HTTP header field content-length to len.

See also contentLength() and hasContentLength().

[править]
void QHttpHeader::setContentType ( const QString & type )

Sets the value of the special HTTP header field content-type to type.

See also contentType() and hasContentType().

[править]
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.

See also value(), hasKey(), and removeValue().

[править]
void QHttpHeader::setValues ( const QList< QPair< QString, QString> > & values )

Sets the header entries to be the list of key value pairs in values.

See also values().

[править]
QString QHttpHeader::toString () const [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".

[править]
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.

See also setValue(), removeValue(), hasKey(), and keys().

[править]
QList< QPair< QString, QString> > QHttpHeader::values () const

Returns all the entries in the header.

See also setValues().

[править]
QHttpHeader & QHttpHeader::operator= ( const QHttpHeader & h )

Assigns h and returns a reference to this http header.



Copyright © 2007 Trolltech Trademarks
Qt 4.3.2