Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qnetworkrequestfactory_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QNETWORKREQUESTFACTORY_P_H
6#define QNETWORKREQUESTFACTORY_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of the Network Access framework. This header file may change from
14// version to version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtNetwork/qhttpheaders.h>
20#include <QtNetwork/qnetworkrequest.h>
21#if QT_CONFIG(ssl)
22#include <QtNetwork/qsslconfiguration.h>
23#endif
24#include <QtCore/qhash.h>
25#include <QtCore/qshareddata.h>
26#include <QtCore/qurl.h>
27#include <QtCore/qurlquery.h>
28#include <QtCore/qvariant.h>
29
30QT_BEGIN_NAMESPACE
31
32class QNetworkRequestFactoryPrivate : public QSharedData
33{
34public:
35 QNetworkRequestFactoryPrivate();
36 explicit QNetworkRequestFactoryPrivate(const QUrl &baseUrl);
37 QNetworkRequest newRequest(const QUrl &url) const;
38 QUrl requestUrl(const QString *path = nullptr, const QUrlQuery *query = nullptr) const;
39
40#if QT_CONFIG(ssl)
41 QSslConfiguration sslConfig;
42#endif
43 QUrl baseUrl;
44 QHttpHeaders headers;
45 QByteArray bearerToken;
46 QString userName;
47 QString password;
48 QUrlQuery queryParameters;
49 QNetworkRequest::Priority priority = QNetworkRequest::NormalPriority;
50 std::chrono::milliseconds transferTimeout{0};
51 QHash<QNetworkRequest::Attribute, QVariant> attributes;
52};
53
55
56#endif // QNETWORKREQUESTFACTORY_P_H
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 ~QNetworkRequestFactory()
Destroys this QNetworkRequestFactory object.
Q_NETWORK_EXPORT void clearBearerToken()
Clears the bearer token.
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 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 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 void setCommonHeaders(const QHttpHeaders &headers)
Sets headers that are common to all requests.
QNetworkRequestFactory(QNetworkRequestFactory &&other) noexcept=default
Move-constructs the factory from other.
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")