8#include <QtNetwork/qsslconfiguration.h>
11#include <QtCore/qloggingcategory.h>
12#include <QtCore/qmap.h>
170void QNetworkRequestFactory::setSslConfiguration(
const QSslConfiguration &configuration)
172 if (d->sslConfig == configuration)
176 d->sslConfig = configuration;
615 if (!sslConfig.isNull())
619 constexpr char Bearer[] =
"Bearer ";
639 if (!providedPath.scheme().isEmpty() || !providedPath.host().isEmpty()) {
640 qCWarning(lcQrequestfactory,
"The provided path %ls may only contain path and query item "
641 "components, and other parts will be ignored. Set the baseUrl instead",
653 const QString requestPath{providedPath.path()};
654 const QUrlQuery pathQueryItems{providedPath};
656 if (!pathQueryItems.isEmpty()) {
660 resultQuery.addQueryItem(
key,
value);
665 const QList<std::pair<QString,QString>>
items =
668 resultQuery.addQueryItem(
item.first,
item.second);
671 if (!resultQuery.isEmpty())
672 resultUrl.setQuery(resultQuery);
674 if (requestPath.isEmpty())
680 if (basePath.endsWith(u
'/') && requestPath.startsWith(u
'/'))
682 else if (!requestPath.startsWith(u
'/') && !basePath.endsWith(u
'/'))
685 resultUrl.setPath(basePath.append(requestPath));
689#ifndef QT_NO_DEBUG_STREAM
701 debug.resetFormat().nospace();
703 debug <<
"QNetworkRequestFactory(baseUrl = " <<
factory.baseUrl()
704 <<
", headers = " <<
factory.commonHeaders()
705 <<
", queryParameters = " <<
factory.queryParameters().queryItems()
706 <<
", bearerToken = " << (
factory.bearerToken().isEmpty() ?
"(empty)" :
"(is set)")
707 <<
", transferTimeout = " <<
factory.transferTimeout()
708 <<
", userName = " << (
factory.userName().isEmpty() ?
"(empty)" :
"(is set)")
709 <<
", password = " << (
factory.password().isEmpty() ?
"(empty)" :
"(is set)")
711 <<
", SSL configuration"
712 << (
factory.sslConfiguration().isNull() ?
" is not set (default)" :
" is set")
714 <<
", no SSL support"
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
void clear()
Clears the contents of the byte array and makes it null.
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
bool remove(const Key &key)
Removes the item that has the key from the hash.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
T value(const Key &key) const noexcept
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
void append(parameter_type t)
std::chrono::milliseconds transferTimeout
QHash< QNetworkRequest::Attribute, QVariant > attributes
~QNetworkRequestFactoryPrivate()
QNetworkRequest newRequest(const QUrl &url) const
QNetworkRequest::Priority priority
QUrl requestUrl(const QString *path=nullptr, const QUrlQuery *query=nullptr) const
QUrlQuery queryParameters
QNetworkRequestFactoryPrivate()
Convenience class for grouping remote server endpoints that share common network request properties.
Q_NETWORK_EXPORT void setQueryParameters(const QUrlQuery &query)
Sets query parameters that are added to individual requests' query parameters.
Q_NETWORK_EXPORT void clearUserName()
Clears the username set to this factory.
Q_NETWORK_EXPORT void setBaseUrl(const QUrl &url)
Sets the base URL used in individual requests to url.
Q_NETWORK_EXPORT QByteArray bearerToken() const
Returns the bearer token that has been set.
Q_NETWORK_EXPORT ~QNetworkRequestFactory()
Destroys this QNetworkRequestFactory object.
Q_NETWORK_EXPORT void clearBearerToken()
Clears the bearer token.
Q_NETWORK_EXPORT QNetworkRequest::Priority priority() const
Q_NETWORK_EXPORT void setBearerToken(const QByteArray &token)
Sets the bearer token to token.
Q_NETWORK_EXPORT void setAttribute(QNetworkRequest::Attribute attribute, const QVariant &value)
Q_NETWORK_EXPORT QNetworkRequestFactory & operator=(const QNetworkRequestFactory &other)
Creates a copy of other and returns a reference to this factory.
Q_NETWORK_EXPORT void clearQueryParameters()
Clears the query parameters.
Q_NETWORK_EXPORT void clearPassword()
Clears the password set to this factory.
Q_NETWORK_EXPORT void clearCommonHeaders()
Clears current headers.
Q_NETWORK_EXPORT void clearAttributes()
Q_NETWORK_EXPORT std::chrono::milliseconds transferTimeout() const
Returns the timeout used for transfers.
Q_NETWORK_EXPORT void setUserName(const QString &userName)
Sets the username of this factory to userName.
Q_NETWORK_EXPORT void setTransferTimeout(std::chrono::milliseconds timeout)
Sets timeout used for transfers.
Q_NETWORK_EXPORT void setPassword(const QString &password)
Sets the password of this factory to password.
Q_NETWORK_EXPORT void setPriority(QNetworkRequest::Priority priority)
Q_NETWORK_EXPORT void clearAttribute(QNetworkRequest::Attribute attribute)
Q_NETWORK_EXPORT QHttpHeaders commonHeaders() const
Returns the currently set headers.
Q_NETWORK_EXPORT void setCommonHeaders(const QHttpHeaders &headers)
Sets headers that are common to all requests.
Q_NETWORK_EXPORT QString password() const
Returns the password set to this factory.
Q_NETWORK_EXPORT QNetworkRequest createRequest() const
Returns a QNetworkRequest.
Q_NETWORK_EXPORT QString userName() const
Returns the username set to this factory.
Q_NETWORK_EXPORT QVariant attribute(QNetworkRequest::Attribute attribute) const
Q_NETWORK_EXPORT QUrl baseUrl() const
Returns the base URL used for the individual requests.
Q_NETWORK_EXPORT QNetworkRequestFactory()
Creates a new QNetworkRequestFactory object.
Q_NETWORK_EXPORT QUrlQuery queryParameters() const
Returns query parameters that are added to individual requests' query parameters.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
void setHeaders(const QHttpHeaders &newHeaders)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setSslConfiguration(const QSslConfiguration &configuration)
Sets this network request's SSL configuration to be config.
@ SourceIsFromCacheAttribute
@ OriginalContentLengthAttribute
@ HttpPipeliningWasUsedAttribute
@ HttpStatusCodeAttribute
@ RedirectionTargetAttribute
@ HttpReasonPhraseAttribute
@ ConnectionEncryptedAttribute
void setAttribute(Attribute code, const QVariant &value)
Sets the attribute associated with code code to be value value.
void setUrl(const QUrl &url)
Sets the URL this network request is referring to be url.
void setPriority(Priority priority)
The QSslConfiguration class holds the configuration and state of an SSL connection.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
void clear()
Clears the contents of the string and makes it null.
void clear()
Clears this QUrlQuery object by removing all of the key-value pairs currently stored.
bool isEmpty() const
Returns true if this QUrlQuery object contains no key-value pairs, such as after being default-constr...
QList< std::pair< QString, QString > > queryItems(QUrl::ComponentFormattingOptions encoding=QUrl::PrettyDecoded) const
Returns the query string of the URL, as a map of keys and values, using the options specified in enco...
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputLayerEXT EGLint attribute
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
QDebug operator<<(QDebug debug, const QNetworkRequestFactory &factory)
GLbitfield GLuint64 timeout
[4]
GLfloat GLfloat GLfloat GLfloat h
GLsizei const GLchar *const * path
#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
#define qUtf16Printable(string)
#define QT_CONFIG(feature)
QUrl url("example.com")
[constructor-url-reference]
QItemEditorFactory * factory
QNetworkRequest request(url)