QNetworkRequestclass holds a request to be sent withQNetworkAccessManager. 更多 …
def
__eq__
(other)
def
__ne__
(other)
def
attribute
(code[, defaultValue=None])
def
hasRawHeader
(headerName)
def
header
(header)
def
maximumRedirectsAllowed
()
def
originatingObject
()
def
peerVerifyName
()
def
priority
()
def
rawHeader
(headerName)
def
rawHeaderList
()
def
setAttribute
(code, value)
def
setHeader
(header, value)
def
setMaximumRedirectsAllowed
(maximumRedirectsAllowed)
def
setOriginatingObject
(object)
def
setPeerVerifyName
(peerName)
def
setPriority
(priority)
def
setRawHeader
(headerName, value)
def
setSslConfiguration
(configuration)
def
setTransferTimeout
([timeout=DefaultTransferTimeoutConstant])
def
setUrl
(url)
def
sslConfiguration
()
def
swap
(other)
def
transferTimeout
()
def
url
()
QNetworkRequestis 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.
QNetworkRequest
¶
QNetworkRequest(other)
QNetworkRequest(url)
- param url
QUrl- param other
构造
QNetworkRequest
object with no URL to be requested. Use
setUrl()
to set one.
PySide2.QtNetwork.QNetworkRequest.
KnownHeaders
¶
已知头类型列表
QNetworkRequest
剖析。每个已知头也以其完整 HTTP 名称按原生形式表示。
|
常量 |
描述 |
|---|---|
|
QNetworkRequest.ContentDispositionHeader |
相当于 HTTP Content-Disposition 头且包含包含处置类型 (例如:附件) 及参数 (例如:文件名) 的字符串。 |
|
QNetworkRequest.ContentTypeHeader |
相当于 HTTP Content-Type 头且包含包含媒体 MIME 类型及任何辅助数据 (例如:字符集) 的字符串。 |
|
QNetworkRequest.ContentLengthHeader |
相当于 HTTP Content-Length 头且包含以字节为单位的传输数据长度。 |
|
QNetworkRequest.LocationHeader |
相当于 HTTP Location 头且包含表示数据实际位置的 URL,包括重定向情况下的目的地 URL。 |
|
QNetworkRequest.LastModifiedHeader |
对应于 HTTP Last-Modified 头,并包含
|
|
QNetworkRequest.IfModifiedSinceHeader |
相当于 HTTP If-Modified-Since 头且包含
|
|
QNetworkRequest.ETagHeader |
相当于 HTTP ETag 头且包含
|
|
QNetworkRequest.IfMatchHeader |
相当于 HTTP If-Match 头且包含
|
|
QNetworkRequest.IfNoneMatchHeader |
相当于 HTTP If-None-Match 头且包含
|
|
QNetworkRequest.CookieHeader |
相当于 HTTP Cookie 头且包含
|
|
QNetworkRequest.SetCookieHeader |
相当于 HTTP Set-Cookie 头且包含
|
|
QNetworkRequest.UserAgentHeader |
由 HTTP 客户端发送的 User-Agent 头。 |
|
QNetworkRequest.ServerHeader |
由 HTTP 客户端收到的服务器 Header 头。 |
PySide2.QtNetwork.QNetworkRequest.
属性
¶
属性代码,用于
QNetworkRequest
and
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
QVariant
types associated, the default value if said attribute is missing and whether it’s used in requests or replies.
|
常量 |
描述 |
|---|---|
|
QNetworkRequest.HttpStatusCodeAttribute |
仅回复,类型:
|
|
QNetworkRequest.HttpReasonPhraseAttribute |
仅回复,类型:
|
|
QNetworkRequest.RedirectionTargetAttribute |
仅回复,类型:
|
|
QNetworkRequest.ConnectionEncryptedAttribute |
仅回复,类型:
|
|
QNetworkRequest.CacheLoadControlAttribute |
仅请求,类型:
|
|
QNetworkRequest.CacheSaveControlAttribute |
仅请求,类型:
|
|
QNetworkRequest.SourceIsFromCacheAttribute |
仅回复,类型:
|
|
QNetworkRequest.DoNotBufferUploadDataAttribute |
仅请求,类型:
|
|
QNetworkRequest.HttpPipeliningAllowedAttribute |
仅请求,类型:
|
|
QNetworkRequest.HttpPipeliningWasUsedAttribute |
仅回复,类型:
|
|
QNetworkRequest.CustomVerbAttribute |
仅请求,类型:
|
|
QNetworkRequest.CookieLoadControlAttribute |
仅请求,类型:
|
|
QNetworkRequest.CookieSaveControlAttribute |
仅请求,类型:
|
|
QNetworkRequest.AuthenticationReuseAttribute |
仅请求,类型:
|
|
QNetworkRequest.BackgroundRequestAttribute |
类型:
|
|
QNetworkRequest.SpdyAllowedAttribute |
仅请求,类型:
|
|
QNetworkRequest.SpdyWasUsedAttribute |
仅回复,类型:
|
|
QNetworkRequest.Http2AllowedAttribute |
仅请求,类型:
|
|
QNetworkRequest.Http2WasUsedAttribute |
仅回复,类型:
|
|
QNetworkRequest.HTTP2AllowedAttribute |
Obsolete alias for . |
|
QNetworkRequest.HTTP2WasUsedAttribute |
Obsolete alias for . |
|
QNetworkRequest.EmitAllUploadProgressSignalsAttribute |
仅请求,类型:
|
|
QNetworkRequest.FollowRedirectsAttribute |
仅请求,类型:
|
|
QNetworkRequest.OriginalContentLengthAttribute |
仅回复,类型
|
|
QNetworkRequest.RedirectPolicyAttribute |
仅请求,类型:
|
|
QNetworkRequest.Http2DirectAttribute |
仅请求,类型:
|
|
QNetworkRequest.AutoDeleteReplyOnFinishAttribute |
仅请求,类型:
|
|
QNetworkRequest.User |
Special type. Additional information can be passed in QVariants with types ranging from User to . 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
|
|
QNetworkRequest.UserMax |
特殊类型。见 User。 |
PySide2.QtNetwork.QNetworkRequest.
CacheLoadControl
¶
控制缓存机制为
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); in addition, force intermediate caches to re-validate. |
|
QNetworkRequest.PreferNetwork |
default value; load from the network if the cached entry is older than the network entry. This will never return stale data from the cache, but revalidate resources that have become stale. |
|
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 |
仅从缓存加载,指示出错若项未缓存 (即:离线模式) |
PySide2.QtNetwork.QNetworkRequest.
LoadControl
¶
Indicates if an aspect of the request’s loading mechanism has been manually overridden, e.g. by Qt WebKit.
|
常量 |
描述 |
|---|---|
|
QNetworkRequest.Automatic |
默认值:指示默认行为。 |
|
QNetworkRequest.Manual |
指示行为已被手动覆盖。 |
New in version 4.7.
PySide2.QtNetwork.QNetworkRequest.
Priority
¶
此枚举列表可能的网络请求优先级。
|
常量 |
描述 |
|---|---|
|
QNetworkRequest.HighPriority |
高优先级 |
|
QNetworkRequest.NormalPriority |
正常优先级 |
|
QNetworkRequest.LowPriority |
低优先级 |
New in version 4.7.
PySide2.QtNetwork.QNetworkRequest.
RedirectPolicy
¶
指示网络访问 API 是否应该自动遵循 HTTP 重定向响应。
|
常量 |
描述 |
|---|---|
|
QNetworkRequest.ManualRedirectPolicy |
默认值:不遵循任何重定向。 |
|
QNetworkRequest.NoLessSafeRedirectPolicy |
Only “http”->”http”, “http” -> “https” or “https” -> “https” redirects are allowed. Equivalent to setting the old
|
|
QNetworkRequest.SameOriginRedirectPolicy |
Require the same protocol, host and port. Note, http://example.com and http://example.com:80 will fail with this policy (implicit/explicit ports are considered to be a mismatch). |
|
QNetworkRequest.UserVerifiedRedirectPolicy |
客户端决定是否遵循每个重定向通过处理 redirected() 信号,发射 redirectAllowed() 当
|
New in version 5.9.
PySide2.QtNetwork.QNetworkRequest.
TransferTimeoutConstant
¶
可以被用于启用带预置值的传输超时的常量。
|
常量 |
描述 |
|---|---|
|
QNetworkRequest.DefaultTransferTimeoutConstant |
传输超时 (以毫秒为单位)。使用,若不带自变量调用 setTimeout()。 |
New in version 5.15.
PySide2.QtNetwork.QNetworkRequest.
attribute
(
code
[
,
defaultValue=None
]
)
¶
code
–
属性
defaultValue – object
object
返回的属性关联代码
code
. If the attribute has not been set, it returns
defaultValue
.
注意
此函数不应用默认,列出于
属性
.
另请参阅
PySide2.QtNetwork.QNetworkRequest.
hasRawHeader
(
headerName
)
¶
headerName
–
QByteArray
bool
返回
true
若原生头
headerName
呈现在此网络请求中。
PySide2.QtNetwork.QNetworkRequest.
header
(
header
)
¶
header
–
KnownHeaders
object
返回已知网络 Header 头的值为
header
若它呈现在此请求中。若不存在,返回 QVariant() (即:无效变体)。
另请参阅
KnownHeaders
rawHeader()
setHeader()
PySide2.QtNetwork.QNetworkRequest.
maximumRedirectsAllowed
(
)
¶
int
Returns the maximum number of redirects allowed to be followed for this request.
PySide2.QtNetwork.QNetworkRequest.
__ne__
(
other
)
¶
other
–
QNetworkRequest
bool
返回
false
if this object is not the same as
other
.
另请参阅
operator==()
PySide2.QtNetwork.QNetworkRequest.
__eq__
(
other
)
¶
other
–
QNetworkRequest
bool
返回
true
if this object is the same as
other
(i.e., if they have the same URL, same headers and same meta-data settings).
另请参阅
operator!=()
PySide2.QtNetwork.QNetworkRequest.
originatingObject
(
)
¶
QObject
Returns a reference to the object that initiated this network request; returns
None
if not set or the object has been destroyed.
PySide2.QtNetwork.QNetworkRequest.
peerVerifyName
(
)
¶
unicode
Returns the host name set for the certificate validation, as set by
setPeerVerifyName
. By default this returns a null string.
另请参阅
PySide2.QtNetwork.QNetworkRequest.
priority
(
)
¶
返回此请求的优先级。
另请参阅
PySide2.QtNetwork.QNetworkRequest.
rawHeader
(
headerName
)
¶
headerName
–
QByteArray
QByteArray
返回 Header 头的原生形式为
headerName
。若不存在这种 Header 头,空
QByteArray
被返回,可能难以区分存在但没有内容的 Header 头 (使用
hasRawHeader()
to find out if the header exists or not).
原生 Header 头可以被设置采用
setRawHeader()
or with
setHeader()
.
另请参阅
PySide2.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.
PySide2.QtNetwork.QNetworkRequest.
setAttribute
(
code
,
value
)
¶
code
–
属性
value – object
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
是无效
QVariant
, the attribute is unset.
另请参阅
attribute()
属性
PySide2.QtNetwork.QNetworkRequest.
setHeader
(
header
,
value
)
¶
header
–
KnownHeaders
value – object
Sets the value of the known header
header
to be
value
,覆盖任何先前设置的 Header 头。此操作还设置等效原生 HTTP 头。
另请参阅
KnownHeaders
setRawHeader()
header()
PySide2.QtNetwork.QNetworkRequest.
setMaximumRedirectsAllowed
(
maximumRedirectsAllowed
)
¶
maximumRedirectsAllowed
–
int
Sets the maximum number of redirects allowed to be followed for this request to
maxRedirectsAllowed
.
PySide2.QtNetwork.QNetworkRequest.
setOriginatingObject
(
object
)
¶
object
–
QObject
Allows setting a reference to the
object
initiating the request.
For example Qt WebKit sets the originating object to the QWebFrame that initiated the request.
另请参阅
PySide2.QtNetwork.QNetworkRequest.
setPeerVerifyName
(
peerName
)
¶
peerName – unicode
集
peerName
as host name for the certificate validation, instead of the one used for the TCP connection.
另请参阅
PySide2.QtNetwork.QNetworkRequest.
setPriority
(
priority
)
¶
priority
–
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.
另请参阅
PySide2.QtNetwork.QNetworkRequest.
setRawHeader
(
headerName
,
value
)
¶
headerName
–
QByteArray
value
–
QByteArray
设置 Header 头
headerName
到值
headerValue
。若
headerName
对应已知 Header 头 (见
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
QDateTime
剖析日期对象。
注意
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.
另请参阅
KnownHeaders
setHeader()
hasRawHeader()
rawHeader()
PySide2.QtNetwork.QNetworkRequest.
setSslConfiguration
(
configuration
)
¶
configuration
–
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.0 where applicable), the CA certificates and the ciphers that the SSL backend is allowed to use.
PySide2.QtNetwork.QNetworkRequest.
setTransferTimeout
(
[
timeout=DefaultTransferTimeoutConstant
]
)
¶
timeout
–
int
集
timeout
作为传输超时 (以毫秒为单位)。
Transfers are aborted if no bytes are transferred before the timeout expires. Zero means no timer is set. If no argument is provided, the timeout is
DefaultTransferTimeoutConstant
. If this function is not called, the timeout is disabled and has the value zero.
另请参阅
PySide2.QtNetwork.QNetworkRequest.
setUrl
(
url
)
¶
url
–
QUrl
Sets the URL this network request is referring to be
url
.
另请参阅
PySide2.QtNetwork.QNetworkRequest.
sslConfiguration
(
)
¶
Returns this network request’s SSL configuration. By default this is the same as
defaultConfiguration()
.
PySide2.QtNetwork.QNetworkRequest.
swap
(
other
)
¶
other
–
QNetworkRequest
Swaps this network request with
other
。此函数非常快,且从不失败。
PySide2.QtNetwork.QNetworkRequest.
transferTimeout
(
)
¶
int
返回用于传输的超时 (以毫秒为单位)。
此超时为 0 若
setTransferTimeout
hasn’t been called, which means that the timeout is not used.
另请参阅