Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QNetworkRequest Class Reference

The QNetworkRequest class holds a request to be sent with QNetworkAccessManager. More...

#include <qnetworkrequest.h>

+ Collaboration diagram for QNetworkRequest:

Public Types

enum  KnownHeaders {
  ContentTypeHeader , ContentLengthHeader , LocationHeader , LastModifiedHeader ,
  CookieHeader , SetCookieHeader , ContentDispositionHeader , UserAgentHeader ,
  ServerHeader , IfModifiedSinceHeader , ETagHeader , IfMatchHeader ,
  IfNoneMatchHeader , NumKnownHeaders
}
 List of known header types that QNetworkRequest parses. More...
 
enum  Attribute {
  HttpStatusCodeAttribute , HttpReasonPhraseAttribute , RedirectionTargetAttribute , ConnectionEncryptedAttribute ,
  CacheLoadControlAttribute , CacheSaveControlAttribute , SourceIsFromCacheAttribute , DoNotBufferUploadDataAttribute ,
  HttpPipeliningAllowedAttribute , HttpPipeliningWasUsedAttribute , CustomVerbAttribute , CookieLoadControlAttribute ,
  AuthenticationReuseAttribute , CookieSaveControlAttribute , MaximumDownloadBufferSizeAttribute , DownloadBufferAttribute ,
  SynchronousRequestAttribute , BackgroundRequestAttribute , EmitAllUploadProgressSignalsAttribute , Http2AllowedAttribute ,
  Http2WasUsedAttribute , OriginalContentLengthAttribute , RedirectPolicyAttribute , Http2DirectAttribute ,
  ResourceTypeAttribute , AutoDeleteReplyOnFinishAttribute , ConnectionCacheExpiryTimeoutSecondsAttribute , Http2CleartextAllowedAttribute ,
  UseCredentialsAttribute , User = 1000 , UserMax = 32767
}
 
enum  CacheLoadControl { AlwaysNetwork , PreferNetwork , PreferCache , AlwaysCache }
 Controls the caching mechanism of QNetworkAccessManager. More...
 
enum  LoadControl { Automatic = 0 , Manual }
 
enum  Priority { HighPriority = 1 , NormalPriority = 3 , LowPriority = 5 }
 
enum  RedirectPolicy { ManualRedirectPolicy , NoLessSafeRedirectPolicy , SameOriginRedirectPolicy , UserVerifiedRedirectPolicy }
 
enum  TransferTimeoutConstant { DefaultTransferTimeoutConstant = 30000 }
 

Public Member Functions

 QNetworkRequest ()
 Constructs a QNetworkRequest object with no URL to be requested.
 
 QNetworkRequest (const QUrl &url)
 Constructs a QNetworkRequest object with url as the URL to be requested.
 
 QNetworkRequest (const QNetworkRequest &other)
 Creates a copy of other.
 
 ~QNetworkRequest ()
 Disposes of the QNetworkRequest object.
 
QNetworkRequestoperator= (QNetworkRequest &&other) noexcept
 
QNetworkRequestoperator= (const QNetworkRequest &other)
 Creates a copy of other.
 
void swap (QNetworkRequest &other) noexcept
 
bool operator== (const QNetworkRequest &other) const
 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).
 
bool operator!= (const QNetworkRequest &other) const
 Returns false if this object is not the same as other.
 
QUrl url () const
 Returns the URL this network request is referring to.
 
void setUrl (const QUrl &url)
 Sets the URL this network request is referring to be url.
 
QHttpHeaders headers () const
 
void setHeaders (const QHttpHeaders &newHeaders)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void setHeaders (QHttpHeaders &&newHeaders)
 
QVariant header (KnownHeaders header) const
 Returns the value of the known network header header if it is present in this request.
 
void setHeader (KnownHeaders header, const QVariant &value)
 Sets the value of the known header header to be value, overriding any previously set headers.
 
bool hasRawHeader (QAnyStringView headerName) const
 Returns true if the raw header headerName is present in this network request.
 
QList< QByteArrayrawHeaderList () const
 Returns a list of all raw headers that are set in this network request.
 
QByteArray rawHeader (QAnyStringView headerName) const
 Returns the raw form of header headerName.
 
void setRawHeader (const QByteArray &headerName, const QByteArray &value)
 Sets the header headerName to be of value headerValue.
 
QVariant attribute (Attribute code, const QVariant &defaultValue=QVariant()) const
 Returns the attribute associated with the code code.
 
void setAttribute (Attribute code, const QVariant &value)
 Sets the attribute associated with code code to be value value.
 
QSslConfiguration sslConfiguration () const
 Returns this network request's SSL configuration.
 
void setSslConfiguration (const QSslConfiguration &configuration)
 Sets this network request's SSL configuration to be config.
 
void setOriginatingObject (QObject *object)
 
QObjectoriginatingObject () const
 
Priority priority () const
 
void setPriority (Priority priority)
 
int maximumRedirectsAllowed () const
 
void setMaximumRedirectsAllowed (int maximumRedirectsAllowed)
 
QString peerVerifyName () const
 
void setPeerVerifyName (const QString &peerName)
 

Static Public Attributes

static constexpr auto DefaultTransferTimeout
 

Friends

class QNetworkRequestPrivate
 

Detailed Description

The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.

Since
4.4

\inmodule 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.

See also
QNetworkReply, QNetworkAccessManager

Definition at line 21 of file qnetworkrequest.h.

Member Enumeration Documentation

◆ Attribute

Since
4.7

Attribute codes for the 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.

\value HttpStatusCodeAttribute Replies only, type: QMetaType::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.

\value HttpReasonPhraseAttribute Replies only, type: QMetaType::QByteArray (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.

\value RedirectionTargetAttribute Replies only, type: QMetaType::QUrl (no default) If present, it indicates that the server is redirecting the request to a different URL. The Network Access API does follow redirections by default, unless QNetworkRequest::ManualRedirectPolicy is used. Additionally, if QNetworkRequest::UserVerifiedRedirectPolicy is used, then this attribute will be set if the redirect was not followed. The returned URL might be relative. Use QUrl::resolved() to create an absolute URL out of it.

\value ConnectionEncryptedAttribute Replies only, type: QMetaType::Bool (default: false) Indicates whether the data was obtained through an encrypted (secure) connection.

\value CacheLoadControlAttribute Requests only, type: QMetaType::Int (default: QNetworkRequest::PreferNetwork) Controls how the cache should be accessed. The possible values are those of QNetworkRequest::CacheLoadControl. Note that the default QNetworkAccessManager implementation does not support caching. However, this attribute may be used by certain backends to modify their requests (for example, for caching proxies).

\value CacheSaveControlAttribute Requests only, type: QMetaType::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).

\value SourceIsFromCacheAttribute Replies only, type: QMetaType::Bool (default: false) Indicates whether the data was obtained from cache or not.

\value DoNotBufferUploadDataAttribute Requests only, type: QMetaType::Bool (default: false) Indicates whether the 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.

\value HttpPipeliningAllowedAttribute Requests only, type: QMetaType::Bool (default: false) Indicates whether the QNetworkAccessManager code is allowed to use HTTP pipelining with this request.

\value HttpPipeliningWasUsedAttribute Replies only, type: QMetaType::Bool Indicates whether the HTTP pipelining was used for receiving this reply.

\value CustomVerbAttribute Requests only, type: QMetaType::QByteArray 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().

\value CookieLoadControlAttribute Requests only, type: QMetaType::Int (default: QNetworkRequest::Automatic) Indicates whether to send 'Cookie' headers in the request. This attribute is set to false by Qt WebKit when creating a cross-origin XMLHttpRequest where withCredentials has not been set explicitly to true by the Javascript that created the request. See \l{http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag}{here} for more information. (This value was introduced in 4.7.)

\value CookieSaveControlAttribute Requests only, type: QMetaType::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 Qt WebKit when creating a cross-origin XMLHttpRequest where withCredentials has not been set explicitly to true by the Javascript that created the request. See \l{http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag} {here} for more information. (This value was introduced in 4.7.)

\value AuthenticationReuseAttribute Requests only, type: QMetaType::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 'Authorization' HTTP header with any cached credentials it may have for the request's URL. This attribute is set to QNetworkRequest::Manual by Qt WebKit when creating a cross-origin XMLHttpRequest where withCredentials has not been set explicitly to true by the Javascript that created the request. See \l{http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag} {here} for more information. (This value was introduced in 4.7.)

\omitvalue MaximumDownloadBufferSizeAttribute

\omitvalue DownloadBufferAttribute

\omitvalue SynchronousRequestAttribute

\value BackgroundRequestAttribute Type: QMetaType::Bool (default: false) Indicates that this is a background transfer, rather than a user initiated transfer. Depending on the platform, background transfers may be subject to different policies.

\value Http2AllowedAttribute Requests only, type: QMetaType::Bool (default: true) Indicates whether the QNetworkAccessManager code is allowed to use HTTP/2 with this request. This applies to SSL requests or 'cleartext' HTTP/2 if Http2CleartextAllowedAttribute is set.

\value Http2WasUsedAttribute Replies only, type: QMetaType::Bool (default: false) Indicates whether HTTP/2 was used for receiving this reply. (This value was introduced in 5.9.)

\value EmitAllUploadProgressSignalsAttribute Requests only, type: QMetaType::Bool (default: false) Indicates whether all upload signals should be emitted. By default, the uploadProgress signal is emitted only in 100 millisecond intervals. (This value was introduced in 5.5.)

\value OriginalContentLengthAttribute Replies only, type QMetaType::Int Holds the original content-length attribute before being invalidated and removed from the header when the data is compressed and the request was marked to be decompressed automatically. (This value was introduced in 5.9.)

\value RedirectPolicyAttribute Requests only, type: QMetaType::Int, should be one of the QNetworkRequest::RedirectPolicy values (default: NoLessSafeRedirectPolicy). (This value was introduced in 5.9.)

\value Http2DirectAttribute Requests only, type: QMetaType::Bool (default: false) If set, this attribute will force QNetworkAccessManager to use HTTP/2 protocol without initial HTTP/2 protocol negotiation. Use of this attribute implies prior knowledge that a particular server supports HTTP/2. The attribute works with SSL or with 'cleartext' HTTP/2 if Http2CleartextAllowedAttribute is set. If a server turns out to not support HTTP/2, when HTTP/2 direct was specified, QNetworkAccessManager gives up, without attempting to fall back to HTTP/1.1. If both Http2AllowedAttribute and Http2DirectAttribute are set, Http2DirectAttribute takes priority. (This value was introduced in 5.11.)

\omitvalue ResourceTypeAttribute

\value AutoDeleteReplyOnFinishAttribute Requests only, type: QMetaType::Bool (default: false) If set, this attribute will make QNetworkAccessManager delete the QNetworkReply after having emitted "finished". (This value was introduced in 5.14.)

\value ConnectionCacheExpiryTimeoutSecondsAttribute Requests only, type: QMetaType::Int To set when the TCP connections to a server (HTTP1 and HTTP2) should be closed after the last pending request had been processed. (This value was introduced in 6.3.)

\value Http2CleartextAllowedAttribute Requests only, type: QMetaType::Bool (default: false) If set, this attribute will tell QNetworkAccessManager to attempt an upgrade to HTTP/2 over cleartext (also known as h2c). Until Qt 7 the default value for this attribute can be overridden to true by setting the QT_NETWORK_H2C_ALLOWED environment variable. This attribute is ignored if the Http2AllowedAttribute is not set. (This value was introduced in 6.3.)

\value UseCredentialsAttribute Requests only, type: QMetaType::Bool (default: false) Indicates if the underlying XMLHttpRequest cross-site Access-Control requests should be made using credentials. Has no effect on same-origin requests. This only affects the WebAssembly platform. (This value was introduced in 6.5.)

\value 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 QNetworkAccessManager.

\value UserMax Special type. See User.

Enumerator
HttpStatusCodeAttribute 
HttpReasonPhraseAttribute 
RedirectionTargetAttribute 
ConnectionEncryptedAttribute 
CacheLoadControlAttribute 
CacheSaveControlAttribute 
SourceIsFromCacheAttribute 
DoNotBufferUploadDataAttribute 
HttpPipeliningAllowedAttribute 
HttpPipeliningWasUsedAttribute 
CustomVerbAttribute 
CookieLoadControlAttribute 
AuthenticationReuseAttribute 
CookieSaveControlAttribute 
MaximumDownloadBufferSizeAttribute 
DownloadBufferAttribute 
SynchronousRequestAttribute 
BackgroundRequestAttribute 
EmitAllUploadProgressSignalsAttribute 
Http2AllowedAttribute 
Http2WasUsedAttribute 
OriginalContentLengthAttribute 
RedirectPolicyAttribute 
Http2DirectAttribute 
ResourceTypeAttribute 
AutoDeleteReplyOnFinishAttribute 
ConnectionCacheExpiryTimeoutSecondsAttribute 
Http2CleartextAllowedAttribute 
UseCredentialsAttribute 
User 
UserMax 

Definition at line 43 of file qnetworkrequest.h.

◆ CacheLoadControl

Controls the caching mechanism of QNetworkAccessManager.

\value 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.

\value 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.

\value PreferCache load from cache if available, otherwise load from network. Note that this can return possibly stale (but not expired) items from cache.

\value AlwaysCache only load from cache, indicating error if the item was not cached (i.e., off-line mode)

Enumerator
AlwaysNetwork 
PreferNetwork 
PreferCache 
AlwaysCache 

Definition at line 77 of file qnetworkrequest.h.

◆ KnownHeaders

List of known header types that QNetworkRequest parses.

Each known header is also represented in raw form with its full HTTP name.

\value ContentDispositionHeader Corresponds to the HTTP Content-Disposition header and contains a string containing the disposition type (for instance, attachment) and a parameter (for instance, filename).

\value ContentTypeHeader Corresponds to the HTTP Content-Type header and contains a string containing the media (MIME) type and any auxiliary data (for instance, charset).

\value ContentLengthHeader Corresponds to the HTTP Content-Length header and contains the length in bytes of the data transmitted.

\value 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.

\value LastModifiedHeader Corresponds to the HTTP Last-Modified header and contains a QDateTime representing the last modification date of the contents.

\value IfModifiedSinceHeader Corresponds to the HTTP If-Modified-Since header and contains a QDateTime. It is usually added to a QNetworkRequest. The server shall send a 304 (Not Modified) response if the resource has not changed since this time.

\value ETagHeader Corresponds to the HTTP ETag header and contains a QString representing the last modification state of the contents.

\value IfMatchHeader Corresponds to the HTTP If-Match header and contains a QStringList. It is usually added to a QNetworkRequest. The server shall send a 412 (Precondition Failed) response if the resource does not match.

\value IfNoneMatchHeader Corresponds to the HTTP If-None-Match header and contains a QStringList. It is usually added to a QNetworkRequest. The server shall send a 304 (Not Modified) response if the resource does match.

\value CookieHeader Corresponds to the HTTP Cookie header and contains a QList<QNetworkCookie> representing the cookies to be sent back to the server.

\value SetCookieHeader Corresponds to the HTTP Set-Cookie header and contains a QList<QNetworkCookie> representing the cookies sent by the server to be stored locally.

\value UserAgentHeader The User-Agent header sent by HTTP clients.

\value ServerHeader The Server header received by HTTP clients.

\omitvalue NumKnownHeaders

See also
header(), setHeader(), rawHeader(), setRawHeader()
Enumerator
ContentTypeHeader 
ContentLengthHeader 
LocationHeader 
LastModifiedHeader 
CookieHeader 
SetCookieHeader 
ContentDispositionHeader 
UserAgentHeader 
ServerHeader 
IfModifiedSinceHeader 
ETagHeader 
IfMatchHeader 
IfNoneMatchHeader 
NumKnownHeaders 

Definition at line 25 of file qnetworkrequest.h.

◆ LoadControl

Since
4.7

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

\value Automatic default value: indicates default behaviour.

\value Manual indicates behaviour has been manually overridden.

Enumerator
Automatic 
Manual 

Definition at line 83 of file qnetworkrequest.h.

◆ Priority

Since
4.7

This enum lists the possible network request priorities.

\value HighPriority High priority \value NormalPriority Normal priority \value LowPriority Low priority

Enumerator
HighPriority 
NormalPriority 
LowPriority 

Definition at line 88 of file qnetworkrequest.h.

◆ RedirectPolicy

Since
5.9

Indicates whether the Network Access API should automatically follow a HTTP redirect response or not.

\value ManualRedirectPolicy Not following any redirects.

\value NoLessSafeRedirectPolicy Default value: Only "http"->"http", "http" -> "https" or "https" -> "https" redirects are allowed.

\value 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).

\value UserVerifiedRedirectPolicy Client decides whether to follow each redirect by handling the redirected() signal, emitting redirectAllowed() on the QNetworkReply object to allow the redirect or aborting/finishing it to reject the redirect. This can be used, for example, to ask the user whether to accept the redirect, or to decide based on some app-specific configuration.

Note
When Qt handles redirects it will, for legacy and compatibility reasons, issue the redirected request using GET when the server returns a 301 or 302 response, regardless of the original method used, unless it was HEAD.
Enumerator
ManualRedirectPolicy 
NoLessSafeRedirectPolicy 
SameOriginRedirectPolicy 
UserVerifiedRedirectPolicy 

Definition at line 94 of file qnetworkrequest.h.

◆ TransferTimeoutConstant

Since
5.15

A constant that can be used for enabling transfer timeouts with a preset value.

\value DefaultTransferTimeoutConstant The transfer timeout in milliseconds. Used if setTimeout() is called without an argument.

See also
QNetworkRequest::DefaultTransferTimeout
Enumerator
DefaultTransferTimeoutConstant 

Definition at line 101 of file qnetworkrequest.h.

Constructor & Destructor Documentation

◆ QNetworkRequest() [1/3]

QNetworkRequest::QNetworkRequest ( )

Constructs a QNetworkRequest object with no URL to be requested.

Use setUrl() to set one.

See also
url(), setUrl()

Definition at line 508 of file qnetworkrequest.cpp.

References Http2::maxSessionReceiveWindowSize(), and Http2::qtDefaultStreamReceiveWindowSize.

+ Here is the call graph for this function:

◆ QNetworkRequest() [2/3]

QNetworkRequest::QNetworkRequest ( const QUrl & url)
explicit

Constructs a QNetworkRequest object with url as the URL to be requested.

See also
url(), setUrl()

Definition at line 529 of file qnetworkrequest.cpp.

References QNetworkRequestPrivate::url, and url().

+ Here is the call graph for this function:

◆ QNetworkRequest() [3/3]

QNetworkRequest::QNetworkRequest ( const QNetworkRequest & other)

Creates a copy of other.

Definition at line 538 of file qnetworkrequest.cpp.

◆ ~QNetworkRequest()

QNetworkRequest::~QNetworkRequest ( )

Disposes of the QNetworkRequest object.

Definition at line 546 of file qnetworkrequest.cpp.

Member Function Documentation

◆ attribute()

QVariant QNetworkRequest::attribute ( Attribute code,
const QVariant & defaultValue = QVariant() ) const

Returns the attribute associated with the code code.

If the attribute has not been set, it returns defaultValue.

Note
This function does not apply the defaults listed in QNetworkRequest::Attribute.
See also
setAttribute(), QNetworkRequest::Attribute

Definition at line 741 of file qnetworkrequest.cpp.

References QNetworkHeadersPrivate::attributes, and QHash< Key, T >::value().

Referenced by QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(), QNetworkReplyImplPrivate::QNetworkReplyImplPrivate(), QNetworkReplyHttpImplPrivate::_q_metaDataChanged(), QNetworkAccessManagerPrivate::_q_replyFinished(), QNetworkReplyHttpImplPrivate::createCache(), QNetworkReplyImplPrivate::createCache(), QNetworkAccessManager::createRequest(), QNetworkReplyWasmImplPrivate::doSendRequest(), QNetworkReplyImplPrivate::getDownloadBuffer(), QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), QNetworkReplyImplPrivate::metaDataChanged(), QNetworkReplyHttpImplPrivate::postRequest(), QNetworkReplyImplPrivate::setup(), and QNetworkReplyWasmImplPrivate::setup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasRawHeader()

bool QNetworkRequest::hasRawHeader ( QAnyStringView headerName) const

Returns true if the raw header headerName is present in this network request.

See also
rawHeader(), setRawHeader()
Note
In Qt versions prior to 6.7, this function took QByteArray only.

Definition at line 676 of file qnetworkrequest.cpp.

References QHttpHeaders::contains(), and QNetworkHeadersPrivate::headers().

+ Here is the call graph for this function:

◆ header()

QVariant QNetworkRequest::header ( KnownHeaders header) const

Returns the value of the known network header header if it is present in this request.

If it is not present, returns QVariant() (i.e., an invalid variant).

See also
KnownHeaders, rawHeader(), setHeader()

Definition at line 652 of file qnetworkrequest.cpp.

References QNetworkHeadersPrivate::cookedHeaders, header(), and QHash< Key, T >::value().

Referenced by QHttpNetworkRequestPrivate::header(), header(), setHeader(), and QNetworkReplyWasmImplPrivate::setup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ headers()

QHttpHeaders QNetworkRequest::headers ( ) const
Since
6.8

Returns headers that are set in this network request.

See also
setHeaders()

Definition at line 615 of file qnetworkrequest.cpp.

References QNetworkHeadersPrivate::headers().

Referenced by QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(), QNetworkAccessManager::createRequest(), QRestAccessManagerPrivate::executeRequest(), QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), QNetworkReplyHttpImplPrivate::onRedirected(), and QNetworkReplyHttpImplPrivate::replyDownloadMetaData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maximumRedirectsAllowed()

int QNetworkRequest::maximumRedirectsAllowed ( ) const
Since
5.6

Returns the maximum number of redirects allowed to be followed for this request.

See also
setMaximumRedirectsAllowed()

Definition at line 870 of file qnetworkrequest.cpp.

References QNetworkRequestPrivate::maxRedirectsAllowed.

◆ operator!=()

bool QNetworkRequest::operator!= ( const QNetworkRequest & other) const
inline

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

See also
operator==()

Definition at line 118 of file qnetworkrequest.h.

References operator==(), and other().

+ Here is the call graph for this function:

◆ operator=() [1/2]

QNetworkRequest & QNetworkRequest::operator= ( const QNetworkRequest & other)

Creates a copy of other.

Definition at line 574 of file qnetworkrequest.cpp.

References other().

+ Here is the call graph for this function:

◆ operator=() [2/2]

QNetworkRequest & QNetworkRequest::operator= ( QNetworkRequest && other)
inlinenoexcept

Definition at line 112 of file qnetworkrequest.h.

References other(), and swap().

+ Here is the call graph for this function:

◆ operator==()

bool QNetworkRequest::operator== ( const QNetworkRequest & other) const

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

See also
operator!=()

Definition at line 558 of file qnetworkrequest.cpp.

References other().

+ Here is the call graph for this function:

◆ originatingObject()

QObject * QNetworkRequest::originatingObject ( ) const
Since
4.6

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

See also
setOriginatingObject()

Definition at line 818 of file qnetworkrequest.cpp.

References QPointer< T >::data(), and QNetworkHeadersPrivate::originatingObject.

+ Here is the call graph for this function:

◆ peerVerifyName()

QString QNetworkRequest::peerVerifyName ( ) const
Since
5.13

Returns the host name set for the certificate validation, as set by setPeerVerifyName. By default this returns a null string.

See also
setPeerVerifyName

Definition at line 896 of file qnetworkrequest.cpp.

References QNetworkRequestPrivate::peerVerifyName.

◆ priority()

QNetworkRequest::Priority QNetworkRequest::priority ( ) const
Since
4.7

Return the priority of this request.

See also
setPriority()

Definition at line 830 of file qnetworkrequest.cpp.

References QNetworkRequestPrivate::priority.

Referenced by QHttpNetworkConnectionPrivate::queueRequest(), QHttpNetworkConnectionPrivate::requeueRequest(), and setPriority().

+ Here is the caller graph for this function:

◆ rawHeader()

QByteArray QNetworkRequest::rawHeader ( QAnyStringView headerName) const

Returns the raw form of header headerName.

If no such header is present, an empty QByteArray is returned, which may be indistinguishable from a header that is present but has no content (use hasRawHeader() to find out if the header exists or not).

Raw headers can be set with setRawHeader() or with setHeader().

See also
header(), setRawHeader()
Note
In Qt versions prior to 6.7, this function took QByteArray only.

Definition at line 692 of file qnetworkrequest.cpp.

References QNetworkHeadersPrivate::rawHeader().

Referenced by QQmlXMLHttpRequest::addHeader(), QNetworkReplyWasmImplPrivate::doSendRequest(), and AndroidMediaPlayer::setDataSource().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rawHeaderList()

QList< QByteArray > QNetworkRequest::rawHeaderList ( ) const

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.

See also
hasRawHeader(), rawHeader()

Definition at line 703 of file qnetworkrequest.cpp.

References QNetworkHeadersPrivate::rawHeadersKeys().

Referenced by QNetworkReplyWasmImplPrivate::doSendRequest(), and AndroidMediaPlayer::setDataSource().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAttribute()

void QNetworkRequest::setAttribute ( Attribute code,
const QVariant & 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 is an invalid QVariant, the attribute is unset.

See also
attribute(), QNetworkRequest::Attribute

Definition at line 754 of file qnetworkrequest.cpp.

References QNetworkHeadersPrivate::attributes, QHash< Key, T >::insert(), and QHash< Key, T >::remove().

Referenced by QNetworkAccessManager::connectToHostEncrypted(), QNetworkAccessManager::createRequest(), QQuickAnimatedImage::load(), QNetworkRequestFactoryPrivate::newRequest(), QQmlXMLHttpRequest::open(), TileProvider::resolveProvider(), and QNetworkAccessManager::sendCustomRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHeader()

void QNetworkRequest::setHeader ( KnownHeaders header,
const QVariant & value )

Sets the value of the known header header to be value, overriding any previously set headers.

This operation also sets the equivalent raw HTTP header.

See also
KnownHeaders, setRawHeader(), header()

Definition at line 664 of file qnetworkrequest.cpp.

References header(), and QNetworkHeadersPrivate::setCookedHeader().

Referenced by GeoRoutingManagerEngineEsri::calculateRoute(), QGeoRoutingManagerEngineMapbox::calculateRoute(), QGeoRoutingManagerEngineOsm::calculateRoute(), GeoCodingManagerEngineEsri::geocode(), GeoTileFetcherEsri::getTileImage(), QGeoTileFetcherOsm::getTileImage(), TileProvider::resolveProvider(), and GeoCodingManagerEngineEsri::reverseGeocode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHeaders() [1/2]

void QNetworkRequest::setHeaders ( const QHttpHeaders & newHeaders)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
6.8

Definition at line 640 of file qnetworkrequest.cpp.

References QNetworkHeadersPrivate::setHeaders().

Referenced by QNetworkAccessManager::createRequest(), QRestAccessManagerPrivate::executeRequest(), QNetworkRequestFactoryPrivate::newRequest(), and QNetworkReplyHttpImplPrivate::onRedirected().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHeaders() [2/2]

void QNetworkRequest::setHeaders ( QHttpHeaders && newHeaders)
Since
6.8

Sets newHeaders as headers in this network request, overriding any previously set headers.

If some headers correspond to the known headers, the values will be parsed and the corresponding parsed form will also be set.

See also
headers(), KnownHeaders

Definition at line 631 of file qnetworkrequest.cpp.

References QNetworkHeadersPrivate::setHeaders().

+ Here is the call graph for this function:

◆ setMaximumRedirectsAllowed()

void QNetworkRequest::setMaximumRedirectsAllowed ( int maxRedirectsAllowed)
Since
5.6

Sets the maximum number of redirects allowed to be followed for this request to maxRedirectsAllowed.

See also
maximumRedirectsAllowed()

Definition at line 883 of file qnetworkrequest.cpp.

References QNetworkRequestPrivate::maxRedirectsAllowed.

Referenced by QNetworkReplyHttpImplPrivate::createRedirectRequest().

+ Here is the caller graph for this function:

◆ setOriginatingObject()

void QNetworkRequest::setOriginatingObject ( QObject * object)
Since
4.6

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.

See also
originatingObject()

Definition at line 804 of file qnetworkrequest.cpp.

References QNetworkHeadersPrivate::originatingObject.

◆ setPeerVerifyName()

void QNetworkRequest::setPeerVerifyName ( const QString & peerName)
Since
5.13

Sets peerName as host name for the certificate validation, instead of the one used for the TCP connection.

See also
peerVerifyName

Definition at line 909 of file qnetworkrequest.cpp.

References QNetworkRequestPrivate::peerVerifyName.

Referenced by QNetworkAccessManager::connectToHostEncrypted().

+ Here is the caller graph for this function:

◆ setPriority()

void QNetworkRequest::setPriority ( Priority priority)
Since
4.7

Set the priority of this request to priority.

Note
The 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.
See also
priority()

Definition at line 857 of file qnetworkrequest.cpp.

References QNetworkRequestPrivate::priority, and priority().

Referenced by QNetworkRequestFactoryPrivate::newRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setRawHeader()

void QNetworkRequest::setRawHeader ( const QByteArray & headerName,
const QByteArray & headerValue )

Sets the header headerName to be of value headerValue.

If headerName corresponds to a known header (see QNetworkRequest::KnownHeaders), the raw format will be parsed and the corresponding "cooked" header will be set as well.

For example:

will also set the known header LastModifiedHeader to be the QDateTime object of the parsed date.

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.
See also
KnownHeaders, setHeader(), hasRawHeader(), rawHeader()

Definition at line 727 of file qnetworkrequest.cpp.

References headerValue(), and QNetworkHeadersPrivate::setRawHeader().

Referenced by QQmlXMLHttpRequest::addHeader(), QGeoCodingManagerEngineOsm::geocode(), QGeoTileFetcherMapbox::getTileImage(), QQmlXmlListModel::reload(), and QGeoCodingManagerEngineOsm::reverseGeocode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSslConfiguration()

void QNetworkRequest::setSslConfiguration ( const QSslConfiguration & config)

Sets this network request's SSL configuration to be config.

The settings that apply are the private key, the local certificate, the TLS protocol (e.g. TLS 1.3), the CA certificates and the ciphers that the SSL backend is allowed to use.

See also
sslConfiguration(), QSslConfiguration::defaultConfiguration()

Definition at line 784 of file qnetworkrequest.cpp.

References QNetworkRequestPrivate::sslConfiguration.

Referenced by QNetworkAccessManager::connectToHostEncrypted(), and QNetworkRequestFactoryPrivate::newRequest().

+ Here is the caller graph for this function:

◆ setUrl()

void QNetworkRequest::setUrl ( const QUrl & url)

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

See also
url()

Definition at line 603 of file qnetworkrequest.cpp.

References QNetworkRequestPrivate::url, and url().

Referenced by QNetworkReplyHttpImplPrivate::createRedirectRequest(), QNetworkAccessManager::createRequest(), GeoCodingManagerEngineEsri::geocode(), QGeoCodingManagerEngineOsm::geocode(), GeoTileFetcherEsri::getTileImage(), QGeoTileFetcherMapbox::getTileImage(), QGeoTileFetcherOsm::getTileImage(), QNetworkRequestFactoryPrivate::newRequest(), TileProvider::resolveProvider(), GeoCodingManagerEngineEsri::reverseGeocode(), and QGeoCodingManagerEngineOsm::reverseGeocode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sslConfiguration()

QSslConfiguration QNetworkRequest::sslConfiguration ( ) const

Returns this network request's SSL configuration.

By default this is the same as QSslConfiguration::defaultConfiguration().

See also
setSslConfiguration(), QSslConfiguration::defaultConfiguration()

Definition at line 769 of file qnetworkrequest.cpp.

References QSslConfiguration::defaultConfiguration(), and QNetworkRequestPrivate::sslConfiguration.

Referenced by QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(), QNetworkAccessManager::createRequest(), and QNetworkReplyHttpImpl::sslConfigurationImplementation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swap()

void QNetworkRequest::swap ( QNetworkRequest & other)
inlinenoexcept
Since
5.0

Swaps this network request with other. This function is very fast and never fails.

Definition at line 115 of file qnetworkrequest.h.

References d, and other().

+ Here is the call graph for this function:

◆ url()

Friends And Related Symbol Documentation

◆ QNetworkRequestPrivate

friend class QNetworkRequestPrivate
friend

Definition at line 187 of file qnetworkrequest.h.

Member Data Documentation

◆ DefaultTransferTimeout

constexpr std::chrono::milliseconds QNetworkRequest::DefaultTransferTimeout
staticconstexpr
Initial value:
=
std::chrono::milliseconds(DefaultTransferTimeoutConstant)

Definition at line 105 of file qnetworkrequest.h.


The documentation for this class was generated from the following files: