QHttpHeaders is a class for holding HTTP headers. 更多...
| 頭: |
#include <QHttpHeaders>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
|
| qmake: |
QT += network
|
| Since: | Qt 6.7 |
| 枚舉類 | WellKnownHeader { AIM, Accept, AcceptAdditions, AcceptCH, AcceptDatetime, …, ProtocolQuery } |
| QHttpHeaders () | |
| QHttpHeaders (const QHttpHeaders & other ) | |
| QHttpHeaders (QHttpHeaders && other ) | |
| ~QHttpHeaders () | |
| bool | append (QAnyStringView name , QAnyStringView value ) |
| bool | append (QHttpHeaders::WellKnownHeader name , QAnyStringView value ) |
| void | clear () |
| QByteArray | combinedValue (QAnyStringView name ) const |
| QByteArray | combinedValue (QHttpHeaders::WellKnownHeader name ) const |
| bool | contains (QAnyStringView name ) const |
| bool | contains (QHttpHeaders::WellKnownHeader name ) const |
(從 6.10 起)
std::optional<QDateTime>
|
dateTimeValue (QAnyStringView name ) const |
(從 6.10 起)
std::optional<QDateTime>
|
dateTimeValue (QHttpHeaders::WellKnownHeader name ) const |
(從 6.10 起)
std::optional<QDateTime>
|
dateTimeValueAt (qsizetype i ) const |
(從 6.10 起)
std::optional<QList<QDateTime>>
|
dateTimeValues (QAnyStringView name ) const |
(從 6.10 起)
std::optional<QList<QDateTime>>
|
dateTimeValues (QHttpHeaders::WellKnownHeader name ) const |
| bool | insert (qsizetype i , QAnyStringView name , QAnyStringView value ) |
| bool | insert (qsizetype i , QHttpHeaders::WellKnownHeader name , QAnyStringView value ) |
(從 6.10 起)
std::optional<qint64>
|
intValue (QAnyStringView name ) const |
(從 6.10 起)
std::optional<qint64>
|
intValue (QHttpHeaders::WellKnownHeader name ) const |
(從 6.10 起)
std::optional<qint64>
|
intValueAt (qsizetype i ) const |
(從 6.10 起)
std::optional<QList<qint64>>
|
intValues (QAnyStringView name ) const |
(從 6.10 起)
std::optional<QList<qint64>>
|
intValues (QHttpHeaders::WellKnownHeader name ) const |
| bool | isEmpty () const |
| QLatin1StringView | nameAt (qsizetype i ) const |
| void | removeAll (QAnyStringView name ) |
| void | removeAll (QHttpHeaders::WellKnownHeader name ) |
| void | removeAt (qsizetype i ) |
| bool | replace (qsizetype i , QAnyStringView name , QAnyStringView newValue ) |
| bool | replace (qsizetype i , QHttpHeaders::WellKnownHeader name , QAnyStringView newValue ) |
(從 6.8 起)
bool
|
replaceOrAppend (QHttpHeaders::WellKnownHeader name , QAnyStringView newValue ) |
| bool | replaceOrAppend (QAnyStringView name , QAnyStringView newValue ) |
| void | reserve (qsizetype size ) |
(從 6.10 起)
void
|
setDateTimeValue (QAnyStringView name , const QDateTime & dateTime ) |
(從 6.10 起)
void
|
setDateTimeValue (QHttpHeaders::WellKnownHeader name , const QDateTime & dateTime ) |
| qsizetype | size () const |
| void | swap (QHttpHeaders & other ) |
| QList<std::pair<QByteArray, QByteArray>> | toListOfPairs () const |
| QMultiHash<QByteArray, QByteArray> | toMultiHash () const |
| QMultiMap<QByteArray, QByteArray> | toMultiMap () const |
| QByteArrayView | value (QAnyStringView name , QByteArrayView defaultValue = {}) const |
| QByteArrayView | value (QHttpHeaders::WellKnownHeader name , QByteArrayView defaultValue = {}) const |
| QByteArrayView | valueAt (qsizetype i ) const |
| QList<QByteArray> | 值 (QAnyStringView name ) const |
| QList<QByteArray> | 值 (QHttpHeaders::WellKnownHeader name ) const |
| QHttpHeaders & | operator= (QHttpHeaders && other ) |
| QHttpHeaders & | operator= (const QHttpHeaders & other ) |
| QHttpHeaders | fromListOfPairs (const QList<std::pair<QByteArray, QByteArray>> & headers ) |
| QHttpHeaders | fromMultiHash (const QMultiHash<QByteArray, QByteArray> & headers ) |
| QHttpHeaders | fromMultiMap (const QMultiMap<QByteArray, QByteArray> & headers ) |
| QByteArrayView | wellKnownHeaderName (QHttpHeaders::WellKnownHeader name ) |
| QDebug | operator<< (QDebug debug , const QHttpHeaders & headers ) |
The class is an interface type for Qt networking APIs that use or consume such headers.
An HTTP header consists of name and value . When setting these, QHttpHeaders validates name and value to only contain characters allowed by the HTTP RFCs. For detailed information see RFC 9110 Chapters 5.1 and 5.5 .
In all, this means:
name
must consist of visible ASCII characters, and must not be empty
value
may consist of arbitrary bytes, as long as header and use case specific encoding rules are adhered to.
value
may be empty
The setters of this class automatically remove any leading or trailing whitespaces from value , as they must be ignored during the value processing.
Most HTTP header values can be combined with a single comma
','
plus an optional whitespace, and the semantic meaning is preserved. As an example, these two should be semantically similar:
// Values as separate header entries myheadername: myheadervalue1 myheadername: myheadervalue2 // Combined value myheadername: myheadervalue1, myheadervalue2
However, there is a notable exception to this rule: Set-Cookie . Due to this and the possibility of custom use cases, QHttpHeaders does not automatically combine the values.
Most QHttpHeaders functions provide both QHttpHeaders::WellKnownHeader and QAnyStringView overloads. From a memory-usage and computation point of view it is recommended to use the QHttpHeaders::WellKnownHeader overloads.
List of well known headers as per IANA registry .
| 常量 | 值 |
|---|---|
QHttpHeaders::WellKnownHeader::AIM
|
0
|
QHttpHeaders::WellKnownHeader::Accept
|
1
|
QHttpHeaders::WellKnownHeader::AcceptAdditions
|
2
|
QHttpHeaders::WellKnownHeader::AcceptCH
|
3
|
QHttpHeaders::WellKnownHeader::AcceptDatetime
|
4
|
QHttpHeaders::WellKnownHeader::AcceptEncoding
|
5
|
QHttpHeaders::WellKnownHeader::AcceptFeatures
|
6
|
QHttpHeaders::WellKnownHeader::AcceptLanguage
|
7
|
QHttpHeaders::WellKnownHeader::AcceptPatch
|
8
|
QHttpHeaders::WellKnownHeader::AcceptPost
|
9
|
QHttpHeaders::WellKnownHeader::AcceptRanges
|
10
|
QHttpHeaders::WellKnownHeader::AcceptSignature
|
11
|
QHttpHeaders::WellKnownHeader::AccessControlAllowCredentials
|
12
|
QHttpHeaders::WellKnownHeader::AccessControlAllowHeaders
|
13
|
QHttpHeaders::WellKnownHeader::AccessControlAllowMethods
|
14
|
QHttpHeaders::WellKnownHeader::AccessControlAllowOrigin
|
15
|
QHttpHeaders::WellKnownHeader::AccessControlExposeHeaders
|
16
|
QHttpHeaders::WellKnownHeader::AccessControlMaxAge
|
17
|
QHttpHeaders::WellKnownHeader::AccessControlRequestHeaders
|
18
|
QHttpHeaders::WellKnownHeader::AccessControlRequestMethod
|
19
|
QHttpHeaders::WellKnownHeader::Age
|
20
|
QHttpHeaders::WellKnownHeader::Allow
|
21
|
QHttpHeaders::WellKnownHeader::ALPN
|
22
|
QHttpHeaders::WellKnownHeader::AltSvc
|
23
|
QHttpHeaders::WellKnownHeader::AltUsed
|
24
|
QHttpHeaders::WellKnownHeader::Alternates
|
25
|
QHttpHeaders::WellKnownHeader::ApplyToRedirectRef
|
26
|
QHttpHeaders::WellKnownHeader::AuthenticationControl
|
27
|
QHttpHeaders::WellKnownHeader::AuthenticationInfo
|
28
|
QHttpHeaders::WellKnownHeader::Authorization
|
29
|
QHttpHeaders::WellKnownHeader::CacheControl
|
30
|
QHttpHeaders::WellKnownHeader::CacheStatus
|
31
|
QHttpHeaders::WellKnownHeader::CalManagedID
|
32
|
QHttpHeaders::WellKnownHeader::CalDAVTimezones
|
33
|
QHttpHeaders::WellKnownHeader::CapsuleProtocol
|
34
|
QHttpHeaders::WellKnownHeader::CDNCacheControl
|
35
|
QHttpHeaders::WellKnownHeader::CDNLoop
|
36
|
QHttpHeaders::WellKnownHeader::CertNotAfter
|
37
|
QHttpHeaders::WellKnownHeader::CertNotBefore
|
38
|
QHttpHeaders::WellKnownHeader::ClearSiteData
|
39
|
QHttpHeaders::WellKnownHeader::ClientCert
|
40
|
QHttpHeaders::WellKnownHeader::ClientCertChain
|
41
|
QHttpHeaders::WellKnownHeader::Close
|
42
|
QHttpHeaders::WellKnownHeader::Connection
|
43
|
QHttpHeaders::WellKnownHeader::ContentDigest
|
44
|
QHttpHeaders::WellKnownHeader::ContentDisposition
|
45
|
QHttpHeaders::WellKnownHeader::ContentEncoding
|
46
|
QHttpHeaders::WellKnownHeader::ContentID
|
47
|
QHttpHeaders::WellKnownHeader::ContentLanguage
|
48
|
QHttpHeaders::WellKnownHeader::ContentLength
|
49
|
QHttpHeaders::WellKnownHeader::ContentLocation
|
50
|
QHttpHeaders::WellKnownHeader::ContentRange
|
51
|
QHttpHeaders::WellKnownHeader::ContentSecurityPolicy
|
52
|
QHttpHeaders::WellKnownHeader::ContentSecurityPolicyReportOnly
|
53
|
QHttpHeaders::WellKnownHeader::ContentType
|
54
|
QHttpHeaders::WellKnownHeader::Cookie
|
55
|
QHttpHeaders::WellKnownHeader::CrossOriginEmbedderPolicy
|
56
|
QHttpHeaders::WellKnownHeader::CrossOriginEmbedderPolicyReportOnly
|
57
|
QHttpHeaders::WellKnownHeader::CrossOriginOpenerPolicy
|
58
|
QHttpHeaders::WellKnownHeader::CrossOriginOpenerPolicyReportOnly
|
59
|
QHttpHeaders::WellKnownHeader::CrossOriginResourcePolicy
|
60
|
QHttpHeaders::WellKnownHeader::DASL
|
61
|
QHttpHeaders::WellKnownHeader::Date
|
62
|
QHttpHeaders::WellKnownHeader::DAV
|
63
|
QHttpHeaders::WellKnownHeader::DeltaBase
|
64
|
QHttpHeaders::WellKnownHeader::Depth
|
65
|
QHttpHeaders::WellKnownHeader::Destination
|
66
|
QHttpHeaders::WellKnownHeader::DifferentialID
|
67
|
QHttpHeaders::WellKnownHeader::DPoP
|
68
|
QHttpHeaders::WellKnownHeader::DPoPNonce
|
69
|
QHttpHeaders::WellKnownHeader::EarlyData
|
70
|
QHttpHeaders::WellKnownHeader::ETag
|
71
|
QHttpHeaders::WellKnownHeader::Expect
|
72
|
QHttpHeaders::WellKnownHeader::ExpectCT
|
73
|
QHttpHeaders::WellKnownHeader::Expires
|
74
|
QHttpHeaders::WellKnownHeader::Forwarded
|
75
|
QHttpHeaders::WellKnownHeader::From
|
76
|
QHttpHeaders::WellKnownHeader::Hobareg
|
77
|
QHttpHeaders::WellKnownHeader::Host
|
78
|
QHttpHeaders::WellKnownHeader::If
|
79
|
QHttpHeaders::WellKnownHeader::IfMatch
|
80
|
QHttpHeaders::WellKnownHeader::IfModifiedSince
|
81
|
QHttpHeaders::WellKnownHeader::IfNoneMatch
|
82
|
QHttpHeaders::WellKnownHeader::IfRange
|
83
|
QHttpHeaders::WellKnownHeader::IfScheduleTagMatch
|
84
|
QHttpHeaders::WellKnownHeader::IfUnmodifiedSince
|
85
|
QHttpHeaders::WellKnownHeader::IM
|
86
|
QHttpHeaders::WellKnownHeader::IncludeReferredTokenBindingID
|
87
|
QHttpHeaders::WellKnownHeader::KeepAlive
|
88
|
QHttpHeaders::WellKnownHeader::Label
|
89
|
QHttpHeaders::WellKnownHeader::LastEventID
|
90
|
QHttpHeaders::WellKnownHeader::LastModified
|
91
|
QHttpHeaders::WellKnownHeader::Link
|
92
|
QHttpHeaders::WellKnownHeader::Location
|
93
|
QHttpHeaders::WellKnownHeader::LockToken
|
94
|
QHttpHeaders::WellKnownHeader::MaxForwards
|
95
|
QHttpHeaders::WellKnownHeader::MementoDatetime
|
96
|
QHttpHeaders::WellKnownHeader::Meter
|
97
|
QHttpHeaders::WellKnownHeader::MIMEVersion
|
98
|
QHttpHeaders::WellKnownHeader::Negotiate
|
99
|
QHttpHeaders::WellKnownHeader::NEL
|
100
|
QHttpHeaders::WellKnownHeader::ODataEntityId
|
101
|
QHttpHeaders::WellKnownHeader::ODataIsolation
|
102
|
QHttpHeaders::WellKnownHeader::ODataMaxVersion
|
103
|
QHttpHeaders::WellKnownHeader::ODataVersion
|
104
|
QHttpHeaders::WellKnownHeader::OptionalWWWAuthenticate
|
105
|
QHttpHeaders::WellKnownHeader::OrderingType
|
106
|
QHttpHeaders::WellKnownHeader::Origin
|
107
|
QHttpHeaders::WellKnownHeader::OriginAgentCluster
|
108
|
QHttpHeaders::WellKnownHeader::OSCORE
|
109
|
QHttpHeaders::WellKnownHeader::OSLCCoreVersion
|
110
|
QHttpHeaders::WellKnownHeader::Overwrite
|
111
|
QHttpHeaders::WellKnownHeader::PingFrom
|
112
|
QHttpHeaders::WellKnownHeader::PingTo
|
113
|
QHttpHeaders::WellKnownHeader::Position
|
114
|
QHttpHeaders::WellKnownHeader::Prefer
|
115
|
QHttpHeaders::WellKnownHeader::PreferenceApplied
|
116
|
QHttpHeaders::WellKnownHeader::Priority
|
117
|
QHttpHeaders::WellKnownHeader::ProxyAuthenticate
|
118
|
QHttpHeaders::WellKnownHeader::ProxyAuthenticationInfo
|
119
|
QHttpHeaders::WellKnownHeader::ProxyAuthorization
|
120
|
QHttpHeaders::WellKnownHeader::ProxyStatus
|
121
|
QHttpHeaders::WellKnownHeader::PublicKeyPins
|
122
|
QHttpHeaders::WellKnownHeader::PublicKeyPinsReportOnly
|
123
|
QHttpHeaders::WellKnownHeader::Range
|
124
|
QHttpHeaders::WellKnownHeader::RedirectRef
|
125
|
QHttpHeaders::WellKnownHeader::Referer
|
126
|
QHttpHeaders::WellKnownHeader::Refresh
|
127
|
QHttpHeaders::WellKnownHeader::ReplayNonce
|
128
|
QHttpHeaders::WellKnownHeader::ReprDigest
|
129
|
QHttpHeaders::WellKnownHeader::RetryAfter
|
130
|
QHttpHeaders::WellKnownHeader::ScheduleReply
|
131
|
QHttpHeaders::WellKnownHeader::ScheduleTag
|
132
|
QHttpHeaders::WellKnownHeader::SecPurpose
|
133
|
QHttpHeaders::WellKnownHeader::SecTokenBinding
|
134
|
QHttpHeaders::WellKnownHeader::SecWebSocketAccept
|
135
|
QHttpHeaders::WellKnownHeader::SecWebSocketExtensions
|
136
|
QHttpHeaders::WellKnownHeader::SecWebSocketKey
|
137
|
QHttpHeaders::WellKnownHeader::SecWebSocketProtocol
|
138
|
QHttpHeaders::WellKnownHeader::SecWebSocketVersion
|
139
|
QHttpHeaders::WellKnownHeader::Server
|
140
|
QHttpHeaders::WellKnownHeader::ServerTiming
|
141
|
QHttpHeaders::WellKnownHeader::SetCookie
|
142
|
QHttpHeaders::WellKnownHeader::Signature
|
143
|
QHttpHeaders::WellKnownHeader::SignatureInput
|
144
|
QHttpHeaders::WellKnownHeader::SLUG
|
145
|
QHttpHeaders::WellKnownHeader::SoapAction
|
146
|
QHttpHeaders::WellKnownHeader::StatusURI
|
147
|
QHttpHeaders::WellKnownHeader::StrictTransportSecurity
|
148
|
QHttpHeaders::WellKnownHeader::Sunset
|
149
|
QHttpHeaders::WellKnownHeader::SurrogateCapability
|
150
|
QHttpHeaders::WellKnownHeader::SurrogateControl
|
151
|
QHttpHeaders::WellKnownHeader::TCN
|
152
|
QHttpHeaders::WellKnownHeader::TE
|
153
|
QHttpHeaders::WellKnownHeader::Timeout
|
154
|
QHttpHeaders::WellKnownHeader::Topic
|
155
|
QHttpHeaders::WellKnownHeader::Traceparent
|
156
|
QHttpHeaders::WellKnownHeader::Tracestate
|
157
|
QHttpHeaders::WellKnownHeader::Trailer
|
158
|
QHttpHeaders::WellKnownHeader::TransferEncoding
|
159
|
QHttpHeaders::WellKnownHeader::TTL
|
160
|
QHttpHeaders::WellKnownHeader::Upgrade
|
161
|
QHttpHeaders::WellKnownHeader::Urgency
|
162
|
QHttpHeaders::WellKnownHeader::UserAgent
|
163
|
QHttpHeaders::WellKnownHeader::VariantVary
|
164
|
QHttpHeaders::WellKnownHeader::Vary
|
165
|
QHttpHeaders::WellKnownHeader::Via
|
166
|
QHttpHeaders::WellKnownHeader::WantContentDigest
|
167
|
QHttpHeaders::WellKnownHeader::WantReprDigest
|
168
|
QHttpHeaders::WellKnownHeader::WWWAuthenticate
|
169
|
QHttpHeaders::WellKnownHeader::XContentTypeOptions
|
170
|
QHttpHeaders::WellKnownHeader::XFrameOptions
|
171
|
QHttpHeaders::WellKnownHeader::AcceptCharset
|
172
|
QHttpHeaders::WellKnownHeader::CPEPInfo
|
173
|
QHttpHeaders::WellKnownHeader::Pragma
|
174
|
QHttpHeaders::WellKnownHeader::ProtocolInfo
|
175
|
QHttpHeaders::WellKnownHeader::ProtocolQuery
|
176
|
[noexcept]
QHttpHeaders::
QHttpHeaders
()
Creates a new QHttpHeaders object.
創建副本為 other .
[noexcept]
QHttpHeaders::
QHttpHeaders
(
QHttpHeaders
&&
other
)
Move-constructs the object from other , which will be left empty .
[noexcept]
QHttpHeaders::
~QHttpHeaders
()
Disposes of the headers object.
Appends a header entry with
name
and
value
並返迴
true
若成功。
另請參閱 append (QHttpHeaders::WellKnownHeader, QAnyStringView) and Allowed field name and value characters .
此函數重載 QHttpHeaders::append (QAnyStringView, QAnyStringView).
Clears all header entries.
另請參閱 size ().
Returns the values of header
name
in a comma-combined string. Returns a
null
QByteArray
if the header with
name
doesn't exist.
注意: Accessing the value(s) of 'Set-Cookie' header this way may not work as intended. It is a notable exception in the HTTP RFC in that its values cannot be combined this way. Prefer 值 () 代替。
另請參閱 值 (QAnyStringView).
此函數重載 QHttpHeaders::combinedValue (QAnyStringView).
Returns whether the headers contain header with name .
另請參閱 contains (QHttpHeaders::WellKnownHeader).
This function overloads QHttpHeaders::has(QAnyStringView).
[since 6.10]
std::optional
<
QDateTime
> QHttpHeaders::
dateTimeValue
(
QAnyStringView
name
) const
Converts the first found header value of
name
到
QDateTime
object, following the standard HTTP date formats. If the header does not exist or contains an invalid
QDateTime
,返迴
std::nullopt
.
該函數在 Qt 6.10 引入。
另請參閱 setDateTimeValue (), dateTimeValues (QAnyStringView name), and dateTimeValueAt (qsizetype i).
[since 6.10]
std::optional
<
QDateTime
> QHttpHeaders::
dateTimeValue
(
QHttpHeaders::WellKnownHeader
name
) const
此函數重載 QHttpHeaders::dateTimeValue (QAnyStringView).
該函數在 Qt 6.10 引入。
[since 6.10]
std::optional
<
QDateTime
> QHttpHeaders::
dateTimeValueAt
(
qsizetype
i
) const
Converts the header value at index i 到 QDateTime object following the standard HTTP date formats. The index i must be valid.
該函數在 Qt 6.10 引入。
另請參閱 dateTimeValue (QAnyStringView name) and dateTimeValues (QAnyStringView name).
[since 6.10]
std::optional
<
QList
<
QDateTime
>> QHttpHeaders::
dateTimeValues
(
QAnyStringView
name
) const
Returns all the header values of
name
in a list of
QDateTime
objects, following the standard HTTP date formats. If no valid date-time values are found, returns
std::nullopt
.
該函數在 Qt 6.10 引入。
另請參閱 dateTimeValue (QAnyStringView name) and dateTimeValueAt (qsizetype i).
[since 6.10]
std::optional
<
QList
<
QDateTime
>> QHttpHeaders::
dateTimeValues
(
QHttpHeaders::WellKnownHeader
name
) const
此函數重載 QHttpHeaders::dateTimeValues (QAnyStringView).
該函數在 Qt 6.10 引入。
[static]
QHttpHeaders
QHttpHeaders::
fromListOfPairs
(const
QList
<
std::pair
<
QByteArray
,
QByteArray
>> &
headers
)
創建新的 QHttpHeaders object that is populated with headers .
另請參閱 Allowed field name and value characters .
[static]
QHttpHeaders
QHttpHeaders::
fromMultiHash
(const
QMultiHash
<
QByteArray
,
QByteArray
> &
headers
)
創建新的 QHttpHeaders object that is populated with headers .
另請參閱 Allowed field name and value characters .
[static]
QHttpHeaders
QHttpHeaders::
fromMultiMap
(const
QMultiMap
<
QByteArray
,
QByteArray
> &
headers
)
創建新的 QHttpHeaders object that is populated with headers .
另請參閱 Allowed field name and value characters .
Inserts a header entry at index i ,采用 name and value . The index must be valid (see size ()). Returns whether the insert succeeded.
另請參閱 append (), insert (qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView), size (),和 Allowed field name and value characters .
此函數重載 QHttpHeaders::insert (qsizetype, QAnyStringView, QAnyStringView).
[noexcept, since 6.10]
std::optional
<
qint64
> QHttpHeaders::
intValue
(
QAnyStringView
name
) const
Returns the value of the first valid header
name
interpreted as a 64-bit integer. If the header does not exist or cannot be parsed as an integer, returns
std::nullopt
.
該函數在 Qt 6.10 引入。
另請參閱 intValues (QAnyStringView name) and intValueAt (qsizetype i).
[noexcept, since 6.10]
std::optional
<
qint64
> QHttpHeaders::
intValue
(
QHttpHeaders::WellKnownHeader
name
) const
此函數重載 QHttpHeaders::intValue (QAnyStringView).
該函數在 Qt 6.10 引入。
[noexcept, since 6.10]
std::optional
<
qint64
> QHttpHeaders::
intValueAt
(
qsizetype
i
) const
Returns the header value interpreted as 64-bit integer at index i . The index i must be valid.
該函數在 Qt 6.10 引入。
另請參閱 intValues (QAnyStringView name) and intValue (QAnyStringView name).
[since 6.10]
std::optional
<
QList
<
qint64
>> QHttpHeaders::
intValues
(
QAnyStringView
name
) const
Returns the values of the header
name
interpreted as 64-bit integer in a list. If the header does not exist or cannot be parsed as an integer, returns
std::nullopt
.
該函數在 Qt 6.10 引入。
另請參閱 intValue (QAnyStringView name) and intValueAt (qsizetype i).
[since 6.10]
std::optional
<
QList
<
qint64
>> QHttpHeaders::
intValues
(
QHttpHeaders::WellKnownHeader
name
) const
此函數重載 QHttpHeaders::intValues (QAnyStringView).
該函數在 Qt 6.10 引入。
[noexcept]
bool
QHttpHeaders::
isEmpty
() const
返迴
true
if the headers have size 0; otherwise returns
false
.
另請參閱 size ().
[noexcept]
QLatin1StringView
QHttpHeaders::
nameAt
(
qsizetype
i
) const
Returns the header name at index i . The index i must be valid (see size ()).
Header names are case-insensitive, and the returned names are lower-cased.
Removes the header name .
另請參閱 removeAt () 和 removeAll (QHttpHeaders::WellKnownHeader).
此函數重載 QHttpHeaders::removeAll (QAnyStringView).
Removes the header at index i . The index i must be valid (see size ()).
另請參閱 removeAll (QHttpHeaders::WellKnownHeader), removeAll (QAnyStringView), and size ().
Replaces the header entry at index i ,采用 name and newValue . The index must be valid (see size ()). Returns whether the replace succeeded.
另請參閱 append (), replace (qsizetype, QHttpHeaders::WellKnownHeader, QAnyStringView), size (),和 Allowed field name and value characters .
此函數重載 QHttpHeaders::replace (qsizetype, QAnyStringView, QAnyStringView).
[since 6.8]
bool
QHttpHeaders::
replaceOrAppend
(
QHttpHeaders::WellKnownHeader
name
,
QAnyStringView
newValue
)
若
QHttpHeaders
already contains
name
, replaces its value with
newValue
and removes possible additional
name
entries. If
name
didn't exist, appends a new entry. Returns
true
若成功。
This function is a convenience method for setting a unique name : newValue header. For most headers the relative order does not matter, which allows reusing an existing entry if one exists.
該函數在 Qt 6.8 引入。
另請參閱 replaceOrAppend (QAnyStringView, QAnyStringView).
This function overloads QHttpHeaders::replaceOrAppend(WellKnownHeader, QAnyStringView).
試圖分配內存為至少 size header entries.
If you know in advance how how many header entries there will be, you may call this function to prevent reallocations and memory fragmentation.
[since 6.10]
void
QHttpHeaders::
setDateTimeValue
(
QAnyStringView
name
, const
QDateTime
&
dateTime
)
Sets the value of the header name name to dateTime , following the standard HTTP IMF-fixdate format . If the header does not exist, adds a new one.
該函數在 Qt 6.10 引入。
另請參閱 dateTimeValue (QAnyStringView name) and dateTimeValueAt (qsizetype i).
[since 6.10]
void
QHttpHeaders::
setDateTimeValue
(
QHttpHeaders::WellKnownHeader
name
, const
QDateTime
&
dateTime
)
This function overloads QHttpHeaders::setDateTimeValue(QAnyStringView).
該函數在 Qt 6.10 引入。
[noexcept]
qsizetype
QHttpHeaders::
size
() const
Returns the number of header entries.
[noexcept]
void
QHttpHeaders::
swap
(
QHttpHeaders
&
other
)
交換此 QHttpHeaders with other 。此操作很快且從不失敗。
Returns the header entries as a list of (name, value) pairs. Header names are case-insensitive, and the returned names are lower-cased.
Returns the header entries as a hash from name to value(s). Header names are case-insensitive, and the returned names are lower-cased.
Returns the header entries as a map from name to value(s). Header names are case-insensitive, and the returned names are lower-cased.
[noexcept]
QByteArrayView
QHttpHeaders::
value
(
QAnyStringView
name
,
QByteArrayView
defaultValue
= {}) const
Returns the value of the (first) header name ,或 defaultValue if it doesn't exist.
另請參閱 value (QHttpHeaders::WellKnownHeader, QByteArrayView).
[noexcept]
QByteArrayView
QHttpHeaders::
value
(
QHttpHeaders::WellKnownHeader
name
,
QByteArrayView
defaultValue
= {}) const
此函數重載 QHttpHeaders::value (QAnyStringView, QByteArrayView).
[noexcept]
QByteArrayView
QHttpHeaders::
valueAt
(
qsizetype
i
) const
Returns the header value at index i . The index i must be valid (see size ()).
另請參閱 size (), value (), 值 (), combinedValue (),和 nameAt ().
Returns the values of header name in a list. Returns an empty list if header with name doesn't exist.
另請參閱 值 (QHttpHeaders::WellKnownHeader).
此函數重載 QHttpHeaders::values (QAnyStringView).
[static noexcept]
QByteArrayView
QHttpHeaders::
wellKnownHeaderName
(
QHttpHeaders::WellKnownHeader
name
)
Returns a header name corresponding to the provided name as a view.
[noexcept]
QHttpHeaders
&QHttpHeaders::
operator=
(
QHttpHeaders
&&
other
)
移動賦值 other and returns a reference to this object.
other will be left empty .
賦值內容對於 other and returns a reference to this object.
寫入 headers into debug stream.