The Q3HttpHeader class contains header information for HTTP. 更多...
| 头: | #include <Q3HttpHeader> |
| 继承者: | Q3HttpRequestHeader and Q3HttpResponseHeader |
| Q3HttpHeader () | |
| Q3HttpHeader (const Q3HttpHeader & header ) | |
| Q3HttpHeader (const QString & str ) | |
| virtual | ~Q3HttpHeader () |
| 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 |
| void | removeValue (const QString & key ) |
| void | setContentLength (int len ) |
| void | setContentType (const QString & type ) |
| void | setValue (const QString & key , const QString & value ) |
| virtual QString | toString () const |
| QString | value (const QString & key ) const |
| Q3HttpHeader & | operator= (const Q3HttpHeader & h ) |
The Q3HttpHeader class contains header information for HTTP.
In most cases you should use the more specialized derivatives of this class, Q3HttpResponseHeader and Q3HttpRequestHeader , rather than directly using Q3HttpHeader .
Q3HttpHeader 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 () 和 setValue (),如
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 () 和 setValue (),如 contentLength () 和 contentType (), setContentLength () 和 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.
另请参阅 Q3HttpRequestHeader and Q3HttpResponseHeader .
Constructs an empty HTTP header.
构造副本为 header .
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.
[虚拟]
Q3HttpHeader::
~Q3HttpHeader
()
析构函数。
Returns the value of the special HTTP header field
content-length
.
另请参阅 setContentLength () 和 hasContentLength ().
Returns the value of the special HTTP header field
content-type
.
另请参阅 setContentType () 和 hasContentType ().
Returns true if the header has an entry for the special HTTP header field
content-length
;否则返回 false。
另请参阅 contentLength () 和 setContentLength ().
Returns true if the header has an entry for the special HTTP header field
content-type
;否则返回 false。
另请参阅 contentType () 和 setContentType ().
Returns true if the HTTP header has an entry with the given key ;否则返回 false。
另请参阅 value (), setValue (),和 keys ().
Returns true if the HTTP header is valid; otherwise returns false.
A Q3HttpHeader is invalid if it was created by parsing a malformed string.
Returns a list of the keys in the HTTP header.
另请参阅 hasKey ().
[pure virtual]
int
Q3HttpHeader::
majorVersion
() const
Returns the major protocol-version of the HTTP header.
[pure virtual]
int
Q3HttpHeader::
minorVersion
() const
Returns the minor protocol-version of the HTTP header.
Removes the entry with the key key from the HTTP header.
Sets the value of the special HTTP header field
content-length
to
len
.
另请参阅 contentLength () 和 hasContentLength ().
Sets the value of the special HTTP header field
content-type
to
type
.
另请参阅 contentType () 和 hasContentType ().
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, its value is discarded and replaced with the given value .
另请参阅 value (), hasKey (),和 removeValue ().
[虚拟]
QString
Q3HttpHeader::
toString
() const
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".
Returns the value for the entry with the given key . If no entry has this key , an empty string is returned.
另请参阅 setValue (), removeValue (), hasKey (),和 keys ().
赋值 h and returns a reference to this http header.