Inherited by: QHttpResponseHeader, QHttpRequestHeader
The PySide.QtNetwork.QHttpHeader class contains header information for HTTP.
In most cases you should use the more specialized derivatives of this class, PySide.QtNetwork.QHttpResponseHeader and PySide.QtNetwork.QHttpRequestHeader , rather than directly using PySide.QtNetwork.QHttpHeader .
PySide.QtNetwork.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/htmlIn 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 PySide.QtNetwork.QHttpHeader.value() and PySide.QtNetwork.QHttpHeader.setValue() , e.g.
header.setValue("content-type", "text/html") contentType = header.value("content-type")Some fields are so common that getters and setters are provided for them as a convenient alternative to using PySide.QtNetwork.QHttpHeader.value() and PySide.QtNetwork.QHttpHeader.setValue() , e.g. PySide.QtNetwork.QHttpHeader.contentLength() and PySide.QtNetwork.QHttpHeader.contentType() , PySide.QtNetwork.QHttpHeader.setContentLength() and PySide.QtNetwork.QHttpHeader.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.
Parameters: |
|
---|
Constructs an empty HTTP header.
Constructs a copy of 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 “rn” delimited lines; each of these lines should have the format key, colon, space, value.
Parameters: |
|
---|
Adds a new entry with the key and value .
Parameters: | key – unicode |
---|---|
Return type: | list of strings |
Returns all the entries with the given key . If no entry has this key , an empty string list is returned.
Return type: | PySide.QtCore.uint |
---|
Returns the value of the special HTTP header field content-length .
Return type: | unicode |
---|
Returns the value of the special HTTP header field content-type .
Return type: | PySide.QtCore.bool |
---|
Returns true if the header has an entry for the special HTTP header field content-length ; otherwise returns false.
Return type: | PySide.QtCore.bool |
---|
Returns true if the header has an entry for the special HTTP header field content-type ; otherwise returns false.
Parameters: | key – unicode |
---|---|
Return type: | PySide.QtCore.bool |
Returns true if the HTTP header has an entry with the given key ; otherwise returns false.
Return type: | PySide.QtCore.bool |
---|
Returns true if the HTTP header is valid; otherwise returns false.
A PySide.QtNetwork.QHttpHeader is invalid if it was created by parsing a malformed string.
Return type: | list of strings |
---|
Returns a list of the keys in the HTTP header.
Return type: | PySide.QtCore.int |
---|
Returns the major protocol-version of the HTTP header.
Return type: | PySide.QtCore.int |
---|
Returns the minor protocol-version of the HTTP header.
Parameters: | str – unicode |
---|---|
Return type: | PySide.QtCore.bool |
Parses the HTTP header string str for header fields and adds the keys/values it finds. If the string is not parsed successfully the PySide.QtNetwork.QHttpHeader becomes invalid .
Returns true if str was successfully parsed; otherwise returns false.
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
Parses the single HTTP header line line which has the format key, colon, space, value, and adds key/value to the headers. The linenumber is number . Returns true if the line was successfully parsed and the key/value added; otherwise returns false.
See also
Parameters: | key – unicode |
---|
Removes all the entries with the key key from the HTTP header.
Parameters: | key – unicode |
---|
Removes the entry with the key key from the HTTP header.
Parameters: | len – PySide.QtCore.int |
---|
Sets the value of the special HTTP header field content-length to len .
Parameters: | type – unicode |
---|
Sets the value of the special HTTP header field content-type to type .
Parameters: | arg__1 – PySide.QtCore.bool |
---|
Parameters: |
|
---|
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 .
Parameters: | values – |
---|
Return type: | unicode |
---|
Returns a string representation of the HTTP header.
The string is suitable for use by the constructor that takes a PySide.QtCore.QString . It consists of lines with the format: key, colon, space, value, “rn”.
Parameters: | key – unicode |
---|---|
Return type: | unicode |
Returns the first value for the entry with the given key . If no entry has this key , an empty string is returned.
Return type: |
---|
Returns all the entries in the header.