#include <Header.h> [code]
Inherited by Gnutella::Handshaking::RequestHeader, Gnutella::Handshaking::ResponseHeader, Http::RequestHeader, and Http::ResponseHeader.
Inheritance diagram for Http::Header:


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.
Definition at line 71 of file Header.h.
Public Member Functions | |
| Header () | |
| Header (const Header &header) | |
| Header (const QString &str) | |
| virtual | ~Header () |
| Header & | operator= (const Header &h) |
| bool | operator== (const Header &other) const |
| bool | operator!= (const Header &other) const |
| QString | fieldValue (const QString &fieldName) const |
| QStringList | fieldValues (const QString &fieldName) const |
| void | setFieldValue (const QString &fieldName, const QString &fieldValue) |
| void | addFieldValue (const QString &fieldName, const QString &fieldValue) |
| void | addFieldValues (const QString &fieldName, const QStringList &fieldValues) |
| void | removeField (const QString &fieldName) |
| QStringList | fields () const |
| bool | hasField (const QString &key) const |
| bool | parse (const QString &str) |
| virtual QString | toString () const |
| bool | isValid () const |
Protected Member Functions | |
| virtual bool | parseLine (const QString &line, int number) |
| void | setValid (bool) |
Private Member Functions | |
| bool | parseAllLines (const QStringList &lines) |
Static Private Member Functions | |
| static QStringList | splitStringIntoLines (const QString &str) |
Private Attributes | |
| HeaderPrivate * | d |
|
|
Constructs an empty HTTP header. Definition at line 57 of file Header.cpp. |
|
|
Constructs a copy of header. Definition at line 66 of file Header.cpp. |
|
|
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. Definition at line 82 of file Header.cpp. |
|
|
Destructor. Definition at line 91 of file Header.cpp. |
|
||||||||||||
|
Adds a new field value fieldValue to the field with name fieldName. If the field does not exist, it will be created.
Definition at line 280 of file Header.cpp. |
|
||||||||||||
|
Adds the list of field values to the field with name fieldName. If the field does not exist, it will be created.
Definition at line 298 of file Header.cpp. |
|
|
Returns a list with the names of the header fields names (in lower case) contained in the HTTP header.
Definition at line 235 of file Header.cpp. |
|
|
Returns the field value for the header field with name fieldName. If no header field has this fieldName, an empty string is returned. If multiple field values are available, they are returned as comma-separated list in a single string.
Definition at line 220 of file Header.cpp. |
|
|
Returns the list of field values for the field with name fieldName. If no field with name fieldName exists, and empty list is returned.
Definition at line 312 of file Header.cpp. |
|
|
Returns true if the HTTP header contains a field with name fieldName; otherwise returns false.
Definition at line 247 of file Header.cpp. |
|
|
Returns true if the HTTP header is valid; otherwise returns false. A Header is invalid if it was created by parsing a malformed string. Definition at line 130 of file Header.cpp. |
|
|
Inequality comparison. Returns true, if the selected other header object is not equal to this object. Definition at line 120 of file Header.cpp. |
|
|
Assigns h and returns a reference to this HTTP header. Definition at line 99 of file Header.cpp. |
|
|
Equality comparison. Returns true, if the selected other header object is equal to this object. Definition at line 111 of file Header.cpp. |
|
|
Parses the HTTP header string str for header fields and adds the names/values it finds. All previous fields are discarded. If the string is not parsed successfully the Header becomes invalid. Returns true if str was successfully parsed; otherwise returns false.
Definition at line 188 of file Header.cpp. |
|
|
Definition at line 166 of file Header.cpp. |
|
||||||||||||
|
For internal use only. Parses the single HTTP header line line which has the format field-name: field-values and adds fields to the headers. The linenumber is number. Returns true if the line was successfully parsed and the field was added; otherwise returns false.
Reimplemented in Gnutella::Handshaking::RequestHeader, Gnutella::Handshaking::ResponseHeader, Http::RequestHeader, and Http::ResponseHeader. Definition at line 343 of file Header.cpp. |
|
|
Removes the field with name fieldName from the HTTP header.
Definition at line 326 of file Header.cpp. |
|
||||||||||||
|
Sets the value of the field with name fieldName to value. If no field with fieldName exists, a new field with the given fieldName and fieldValue is created. If a field with the fieldName already exists, its values are discarded and replaced with the given fieldValue. If the fieldValue is a comma-separated string, it is split in sub values and they are all associated with the header field.
Definition at line 264 of file Header.cpp. |
|
|
For internal use only.
Definition at line 206 of file Header.cpp. |
|
|
Definition at line 154 of file Header.cpp. |
|
|
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 Gnutella::Handshaking::RequestHeader, Gnutella::Handshaking::ResponseHeader, Http::RequestHeader, and Http::ResponseHeader. Definition at line 361 of file Header.cpp. |
|
|
Reimplemented in Http::RequestHeader, and Http::ResponseHeader. |