• PySide 模块
  • PySide.QtNetwork
  • 内容表

    上一话题

    QSslCipher

    下一话题

    QHttpRequestHeader

    QHttpHeader

    继承者: QHttpRequestHeader , QHttpResponseHeader

    概要

    函数

    虚函数

    详细描述

    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() ,如

    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() ,如 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 )
    参数:

    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 “rn” delimited lines; each of these lines should have the format key, colon, space, value.

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

    Adds a new entry with the key and value .

    PySide.QtNetwork.QHttpHeader. allValues ( key )
    参数: key – unicode
    返回类型: 字符串列表

    Returns all the entries with the given key . If no entry has this key , an empty string list is returned.

    PySide.QtNetwork.QHttpHeader. contentLength ( )
    返回类型: PySide.QtCore.uint

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

    PySide.QtNetwork.QHttpHeader. contentType ( )
    返回类型: unicode

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

    PySide.QtNetwork.QHttpHeader. hasContentLength ( )
    返回类型: PySide.QtCore.bool

    Returns true if the header has an entry for the special HTTP header field content-length ;否则返回 false。

    PySide.QtNetwork.QHttpHeader. hasContentType ( )
    返回类型: PySide.QtCore.bool

    Returns true if the header has an entry for the special HTTP header field content-type ;否则返回 false。

    PySide.QtNetwork.QHttpHeader. hasKey ( key )
    参数: key – unicode
    返回类型: PySide.QtCore.bool

    Returns true if the HTTP header has an entry with the given key ;否则返回 false。

    PySide.QtNetwork.QHttpHeader. isValid ( )
    返回类型: 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 ( )
    返回类型: 字符串列表

    Returns a list of the keys in the HTTP header.

    PySide.QtNetwork.QHttpHeader. majorVersion ( )
    返回类型: PySide.QtCore.int

    Returns the major protocol-version of the HTTP header.

    PySide.QtNetwork.QHttpHeader. minorVersion ( )
    返回类型: PySide.QtCore.int

    Returns the minor protocol-version of the HTTP header.

    PySide.QtNetwork.QHttpHeader. parse ( str )
    参数: str – unicode
    返回类型: 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 .

    返回 true 若 str was successfully parsed; otherwise returns false.

    PySide.QtNetwork.QHttpHeader. parseLine ( line , number )
    参数:
    • line – unicode
    • number PySide.QtCore.int
    返回类型:

    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 )
    参数: key – unicode

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

    PySide.QtNetwork.QHttpHeader. removeValue ( key )
    参数: key – unicode

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

    PySide.QtNetwork.QHttpHeader. setContentLength ( len )
    参数: len PySide.QtCore.int

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

    PySide.QtNetwork.QHttpHeader. setContentType ( type )
    参数: type – unicode

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

    PySide.QtNetwork.QHttpHeader. setValid ( arg__1 )
    参数: arg__1 PySide.QtCore.bool
    PySide.QtNetwork.QHttpHeader. setValue ( key , value )
    参数:
    • 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 )
    参数: values
    PySide.QtNetwork.QHttpHeader. toString ( )
    返回类型: 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 )
    参数: key – unicode
    返回类型: 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 ( )
    返回类型:

    Returns all the entries in the header.