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

    上一话题

    QNetworkCookie

    下一话题

    QSslKey

    QNetworkRequest

    概要

    函数

    详细描述

    PySide.QtNetwork.QNetworkRequest class holds a request to be sent with PySide.QtNetwork.QNetworkAccessManager .

    PySide.QtNetwork.QNetworkRequest is part of the Network Access API and is the class holding the information necessary to send a request over the network. It contains a URL and some ancillary information that can be used to modify the request.

    class PySide.QtNetwork. QNetworkRequest ( other )
    class PySide.QtNetwork. QNetworkRequest ( [ url=QUrl() ] )
    参数:

    Creates a copy of other .

    构造 PySide.QtNetwork.QNetworkRequest object with url 作为要请求的 URL。

    PySide.QtNetwork.QNetworkRequest. CacheLoadControl

    控制缓存机制为 PySide.QtNetwork.QNetworkAccessManager .

    常量 描述
    QNetworkRequest.AlwaysNetwork always load from network and do not check if the cache has a valid entry (similar to the “Reload” feature in browsers)
    QNetworkRequest.PreferNetwork default value; load from the network if the cached entry is older than the network entry
    QNetworkRequest.PreferCache load from cache if available, otherwise load from network. Note that this can return possibly stale (but not expired) items from cache.
    QNetworkRequest.AlwaysCache 仅从缓存加载,指示出错若项未缓存 (即:离线模式)
    PySide.QtNetwork.QNetworkRequest. KnownHeaders

    已知头类型列表 PySide.QtNetwork.QNetworkRequest 剖析。每个已知头也以其完整 HTTP 名称按原生形式表示。

    常量 描述
    QNetworkRequest.ContentTypeHeader corresponds to the HTTP Content-Type header and contains a string containing the media (MIME) type and any auxiliary data (for instance, charset)
    QNetworkRequest.ContentLengthHeader corresponds to the HTTP Content-Length header and contains the length in bytes of the data transmitted.
    QNetworkRequest.LocationHeader corresponds to the HTTP Location header and contains a URL representing the actual location of the data, including the destination URL in case of redirections.
    QNetworkRequest.LastModifiedHeader corresponds to the HTTP Last-Modified header and contains a PySide.QtCore.QDateTime representing the last modification date of the contents
    QNetworkRequest.CookieHeader corresponds to the HTTP Cookie header and contains a QList < PySide.QtNetwork.QNetworkCookie > representing the cookies to be sent back to the server
    QNetworkRequest.SetCookieHeader corresponds to the HTTP Set-Cookie header and contains a QList < PySide.QtNetwork.QNetworkCookie > representing the cookies sent by the server to be stored locally
    PySide.QtNetwork.QNetworkRequest. Priority

    此枚举列表可能的网络请求优先级。

    常量 描述
    QNetworkRequest.HighPriority 高优先级
    QNetworkRequest.NormalPriority 正常优先级
    QNetworkRequest.LowPriority 低优先级

    注意

    This enum was introduced or modified in Qt 4.7

    PySide.QtNetwork.QNetworkRequest. 属性

    属性代码,用于 PySide.QtNetwork.QNetworkRequest and PySide.QtNetwork.QNetworkReply .

    Attributes are extra meta-data that are used to control the behavior of the request and to pass further information from the reply back to the application. Attributes are also extensible, allowing custom implementations to pass custom values.

    The following table explains what the default attribute codes are, the PySide.QtCore.QVariant types associated, the default value if said attribute is missing and whether it's used in requests or replies.

    常量 描述
    QNetworkRequest.HttpStatusCodeAttribute 仅回复,类型: QVariant.Int (no default) Indicates the HTTP status code received from the HTTP server (like 200, 304, 404, 401, etc.). If the connection was not HTTP-based, this attribute will not be present.
    QNetworkRequest.HttpReasonPhraseAttribute 仅回复,类型: QVariant.ByteArray (no default) Indicates the HTTP reason phrase as received from the HTTP server (like “Ok”, “Found”, “Not Found”, “Access Denied”, etc.) This is the human-readable representation of the status code (see above). If the connection was not HTTP-based, this attribute will not be present.
    QNetworkRequest.RedirectionTargetAttribute 仅回复,类型: QVariant.Url (no default) If present, it indicates that the server is redirecting the request to a different URL. The Network Access API does not by default follow redirections: it's up to the application to determine if the requested redirection should be allowed, according to its security policies. The returned URL might be relative. Use QUrl.resolved() to create an absolute URL out of it.
    QNetworkRequest.ConnectionEncryptedAttribute 仅回复,类型: QVariant.Bool (default: false) Indicates whether the data was obtained through an encrypted (secure) connection.
    QNetworkRequest.CacheLoadControlAttribute 仅请求,类型: QVariant.Int (default: QNetworkRequest.PreferNetwork ) Controls how the cache should be accessed. The possible values are those of QNetworkRequest.CacheLoadControl . Note that the default PySide.QtNetwork.QNetworkAccessManager implementation does not support caching. However, this attribute may be used by certain backends to modify their requests (for example, for caching proxies).
    QNetworkRequest.CacheSaveControlAttribute 仅请求,类型: QVariant.Bool (default: true) Controls if the data obtained should be saved to cache for future uses. If the value is false, the data obtained will not be automatically cached. If true, data may be cached, provided it is cacheable (what is cacheable depends on the protocol being used).
    QNetworkRequest.SourceIsFromCacheAttribute 仅回复,类型: QVariant.Bool (default: false) Indicates whether the data was obtained from cache or not.
    QNetworkRequest.DoNotBufferUploadDataAttribute 仅请求,类型: QVariant.Bool (default: false) Indicates whether the PySide.QtNetwork.QNetworkAccessManager code is allowed to buffer the upload data, e.g. when doing a HTTP POST. When using this flag with sequential upload data, the ContentLengthHeader header must be set.
    QNetworkRequest.HttpPipeliningAllowedAttribute 仅请求,类型: QVariant.Bool (default: false) Indicates whether the PySide.QtNetwork.QNetworkAccessManager code is allowed to use HTTP pipelining with this request.
    QNetworkRequest.HttpPipeliningWasUsedAttribute 仅回复,类型: QVariant.Bool Indicates whether the HTTP pipelining was used for receiving this reply.
    QNetworkRequest.CustomVerbAttribute 仅请求,类型: QVariant.ByteArray Holds the value for the custom HTTP verb to send (destined for usage of other verbs than GET, POST, PUT and DELETE). This verb is set when calling QNetworkAccessManager.sendCustomRequest() .
    QNetworkRequest.CookieLoadControlAttribute 仅请求,类型: QVariant.Int (default: QNetworkRequest.Automatic ) Indicates whether to send ‘Cookie' headers in the request. This attribute is set to false by QtWebKit when creating a cross-origin XMLHttpRequest where withCredentials has not been set explicitly to true by the Javascript that created the request. See here for more information. (This value was introduced in 4.7.)
    QNetworkRequest.CookieSaveControlAttribute 仅请求,类型: QVariant.Int (default: QNetworkRequest.Automatic ) Indicates whether to save ‘Cookie' headers received from the server in reply to the request. This attribute is set to false by QtWebKit when creating a cross-origin XMLHttpRequest where withCredentials has not been set explicitly to true by the Javascript that created the request. See here for more information. (This value was introduced in 4.7.)
    QNetworkRequest.AuthenticationReuseAttribute 仅请求,类型: QVariant.Int (default: QNetworkRequest.Automatic ) Indicates whether to use cached authorization credentials in the request, if available. If this is set to QNetworkRequest.Manual and the authentication mechanism is ‘Basic' or ‘Digest', Qt will not send an an ‘Authorization' HTTP header with any cached credentials it may have for the request's URL. This attribute is set to QNetworkRequest.Manual by QtWebKit when creating a cross-origin XMLHttpRequest where withCredentials has not been set explicitly to true by the Javascript that created the request. See here for more information. (This value was introduced in 4.7.)
    QNetworkRequest.User Special type. Additional information can be passed in QVariants with types ranging from User to UserMax . The default implementation of Network Access will ignore any request attributes in this range and it will not produce any attributes in this range in replies. The range is reserved for extensions of PySide.QtNetwork.QNetworkAccessManager .
    QNetworkRequest.UserMax 特殊类型。见 User。
    PySide.QtNetwork.QNetworkRequest. LoadControl

    Indicates if an aspect of the request's loading mechanism has been manually overridden, e.g. by QtWebKit .

    常量 描述
    QNetworkRequest.Automatic 默认值:指示默认行为。
    QNetworkRequest.Manual 指示行为已被手动覆盖。

    注意

    This enum was introduced or modified in Qt 4.7

    PySide.QtNetwork.QNetworkRequest. attribute ( code [ , defaultValue=None ] )
    参数:
    返回类型:

    object

    返回的属性关联代码 code . If the attribute has not been set, it returns defaultValue .

    Note: this function does not apply the defaults listed in QNetworkRequest.Attribute .

    另请参阅

    PySide.QtNetwork.QNetworkRequest.setAttribute() QNetworkRequest.Attribute

    PySide.QtNetwork.QNetworkRequest. hasRawHeader ( headerName )
    参数: headerName PySide.QtCore.QByteArray
    返回类型: PySide.QtCore.bool

    Returns true if the raw header headerName 呈现在此网络请求中。

    PySide.QtNetwork.QNetworkRequest. header ( header )
    参数: header PySide.QtNetwork.QNetworkRequest.KnownHeaders
    返回类型: object

    返回已知网络 Header 头的值为 header if it is present in this request. If it is not present, returns QVariant() (i.e., an invalid variant).

    PySide.QtNetwork.QNetworkRequest. __ne__ ( other )
    参数: other PySide.QtNetwork.QNetworkRequest
    返回类型: PySide.QtCore.bool

    Returns false if this object is not the same as other .

    另请参阅

    PySide.QtNetwork.QNetworkRequest.operator==()

    PySide.QtNetwork.QNetworkRequest. __eq__ ( other )
    参数: other PySide.QtNetwork.QNetworkRequest
    返回类型: PySide.QtCore.bool

    Returns true if this object is the same as other (i.e., if they have the same URL, same headers and same meta-data settings).

    另请参阅

    PySide.QtNetwork.QNetworkRequest.operator!=()

    PySide.QtNetwork.QNetworkRequest. originatingObject ( )
    返回类型: PySide.QtCore.QObject

    Returns a reference to the object that initiated this network request; returns 0 if not set or the object has been destroyed.

    PySide.QtNetwork.QNetworkRequest. priority ( )
    返回类型: PySide.QtNetwork.QNetworkRequest.Priority

    返回此请求的优先级。

    PySide.QtNetwork.QNetworkRequest. rawHeader ( headerName )
    参数: headerName PySide.QtCore.QByteArray
    返回类型: PySide.QtCore.QByteArray

    返回 Header 头的原生形式为 headerName 。若不存在这种 Header 头,空 PySide.QtCore.QByteArray 被返回,可能难以区分存在但没有内容的 Header 头 (使用 PySide.QtNetwork.QNetworkRequest.hasRawHeader() to find out if the header exists or not).

    原生 Header 头可以被设置采用 PySide.QtNetwork.QNetworkRequest.setRawHeader() or with PySide.QtNetwork.QNetworkRequest.setHeader() .

    PySide.QtNetwork.QNetworkRequest. rawHeaderList ( )
    返回类型:

    Returns a list of all raw headers that are set in this network request. The list is in the order that the headers were set.

    PySide.QtNetwork.QNetworkRequest. setAttribute ( code , value )
    参数:

    Sets the attribute associated with code code to be value value . If the attribute is already set, the previous value is discarded. In special, if value 是无效 PySide.QtCore.QVariant , the attribute is unset.

    另请参阅

    PySide.QtNetwork.QNetworkRequest.attribute() QNetworkRequest.Attribute

    PySide.QtNetwork.QNetworkRequest. setHeader ( header , value )
    参数:

    Sets the value of the known header header to be value ,覆盖任何先前设置的 Header 头。此操作还设置等效原生 HTTP 头。

    PySide.QtNetwork.QNetworkRequest. setOriginatingObject ( object )
    参数: object PySide.QtCore.QObject

    Allows setting a reference to the object initiating the request.

    例如 QtWebKit sets the originating object to the PySide.QtWebKit.QWebFrame that initiated the request.

    PySide.QtNetwork.QNetworkRequest. setPriority ( priority )
    参数: priority PySide.QtNetwork.QNetworkRequest.Priority

    把此请求的优先级设为 priority .

    注意

    priority is only a hint to the network access manager. It can use it or not. Currently it is used for HTTP to decide which request should be sent first to a server.

    PySide.QtNetwork.QNetworkRequest. setRawHeader ( headerName , value )
    参数:

    设置 Header 头 headerName 到值 headerValue 。若 headerName 对应已知 Header 头 (见 QNetworkRequest.KnownHeaders ), the raw format will be parsed and the corresponding “cooked” header will be set as well.

    例如:

    request.setRawHeader("Last-Modified", "Sun, 06 Nov 1994 08:49:37 GMT")
    											

    还将设置已知 Header LastModifiedHeader to be the PySide.QtCore.QDateTime 剖析日期对象。

    Note: setting the same header twice overrides the previous setting. To accomplish the behaviour of multiple HTTP headers of the same name, you should concatenate the two values, separating them with a comma (”,”) and set one single raw header.

    PySide.QtNetwork.QNetworkRequest. setSslConfiguration ( configuration )
    参数: configuration PySide.QtNetwork.QSslConfiguration

    Sets this network request's SSL configuration to be config . The settings that apply are the private key, the local certificate, the SSL protocol (SSLv2, SSLv3, TLSv1 where applicable), the CA certificates and the ciphers that the SSL backend is allowed to use.

    By default, no SSL configuration is set, which allows the backends to choose freely what configuration is best for them.

    PySide.QtNetwork.QNetworkRequest. setUrl ( url )
    参数: url PySide.QtCore.QUrl

    Sets the URL this network request is referring to to be url .

    PySide.QtNetwork.QNetworkRequest. sslConfiguration ( )
    返回类型: PySide.QtNetwork.QSslConfiguration

    Returns this network request's SSL configuration. By default, no SSL settings are specified.

    PySide.QtNetwork.QNetworkRequest. url ( )
    返回类型: PySide.QtCore.QUrl

    返回此网络请求所引用的 URL。