QHttpHeader

Inheritance diagram of QHttpHeader

Inherited by: QHttpResponseHeader, QHttpRequestHeader

Synopsis

Functions

Virtual functions

Detailed Description

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/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 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.

class PySide.QtNetwork.QHttpHeader
class PySide.QtNetwork.QHttpHeader(header)
class PySide.QtNetwork.QHttpHeader(str)
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.

PySide.QtNetwork.QHttpHeader.addValue(key, value)
Parameters:
  • key – unicode
  • value – unicode

Adds a new entry with the key and value .

PySide.QtNetwork.QHttpHeader.allValues(key)
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.

PySide.QtNetwork.QHttpHeader.contentLength()
Return type:PySide.QtCore.uint

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

PySide.QtNetwork.QHttpHeader.contentType()
Return type:unicode

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

PySide.QtNetwork.QHttpHeader.hasContentLength()
Return type:PySide.QtCore.bool

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

PySide.QtNetwork.QHttpHeader.hasContentType()
Return type:PySide.QtCore.bool

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

PySide.QtNetwork.QHttpHeader.hasKey(key)
Parameters:key – unicode
Return type:PySide.QtCore.bool

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

PySide.QtNetwork.QHttpHeader.isValid()
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.

PySide.QtNetwork.QHttpHeader.keys()
Return type:list of strings

Returns a list of the keys in the HTTP header.

PySide.QtNetwork.QHttpHeader.majorVersion()
Return type:PySide.QtCore.int

Returns the major protocol-version of the HTTP header.

PySide.QtNetwork.QHttpHeader.minorVersion()
Return type:PySide.QtCore.int

Returns the minor protocol-version of the HTTP header.

PySide.QtNetwork.QHttpHeader.parse(str)
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.

PySide.QtNetwork.QHttpHeader.parseLine(line, number)
Parameters:
  • line – unicode
  • numberPySide.QtCore.int
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.

PySide.QtNetwork.QHttpHeader.removeAllValues(key)
Parameters:key – unicode

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

PySide.QtNetwork.QHttpHeader.removeValue(key)
Parameters:key – unicode

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

PySide.QtNetwork.QHttpHeader.setContentLength(len)
Parameters:lenPySide.QtCore.int

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

PySide.QtNetwork.QHttpHeader.setContentType(type)
Parameters:type – unicode

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

PySide.QtNetwork.QHttpHeader.setValid(arg__1)
Parameters:arg__1PySide.QtCore.bool
PySide.QtNetwork.QHttpHeader.setValue(key, value)
Parameters:
  • key – unicode
  • value – unicode

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 .

PySide.QtNetwork.QHttpHeader.setValues(values)
Parameters:values
PySide.QtNetwork.QHttpHeader.toString()
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”.

PySide.QtNetwork.QHttpHeader.value(key)
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.

PySide.QtNetwork.QHttpHeader.values()
Return type:

Returns all the entries in the header.