Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qnetworkproxy.h
Go to the documentation of this file.
1// Copyright (C) 2016 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
4#ifndef QNETWORKPROXY_H
5#define QNETWORKPROXY_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtNetwork/qhostaddress.h>
9#include <QtNetwork/qnetworkrequest.h>
10#include <QtCore/qshareddata.h>
11
12#ifndef QT_NO_NETWORKPROXY
13
15
16
17class QUrl;
18
20class Q_NETWORK_EXPORT QNetworkProxyQuery
21{
23
24public:
25 enum QueryType {
29 TcpServer = 100,
31 SctpServer
32 };
33 Q_ENUM(QueryType)
34
36 explicit QNetworkProxyQuery(const QUrl &requestUrl, QueryType queryType = UrlRequest);
37 QNetworkProxyQuery(const QString &hostname, int port, const QString &protocolTag = QString(),
38 QueryType queryType = TcpSocket);
39 explicit QNetworkProxyQuery(quint16 bindPort, const QString &protocolTag = QString(),
40 QueryType queryType = TcpServer);
45
46 void swap(QNetworkProxyQuery &other) noexcept { d.swap(other.d); }
47
48 bool operator==(const QNetworkProxyQuery &other) const;
49 inline bool operator!=(const QNetworkProxyQuery &other) const
50 { return !(*this == other); }
51
52 QueryType queryType() const;
53 void setQueryType(QueryType type);
54
55 int peerPort() const;
56 void setPeerPort(int port);
57
58 QString peerHostName() const;
59 void setPeerHostName(const QString &hostname);
60
61 int localPort() const;
62 void setLocalPort(int port);
63
64 QString protocolTag() const;
65 void setProtocolTag(const QString &protocolTag);
66
67 QUrl url() const;
68 void setUrl(const QUrl &url);
69
70private:
72};
73
74Q_DECLARE_SHARED(QNetworkProxyQuery)
75
77
78class Q_NETWORK_EXPORT QNetworkProxy
79{
80public:
81 enum ProxyType {
87 FtpCachingProxy
88 };
89
91 TunnelingCapability = 0x0001,
92 ListeningCapability = 0x0002,
93 UdpTunnelingCapability = 0x0004,
94 CachingCapability = 0x0008,
95 HostNameLookupCapability = 0x0010,
96 SctpTunnelingCapability = 0x00020,
97 SctpListeningCapability = 0x00040
98 };
99 Q_DECLARE_FLAGS(Capabilities, Capability)
100
102 QNetworkProxy(ProxyType type, const QString &hostName = QString(), quint16 port = 0,
103 const QString &user = QString(), const QString &password = QString());
105 QNetworkProxy &operator=(QNetworkProxy &&other) noexcept { swap(other); return *this; }
106 QNetworkProxy &operator=(const QNetworkProxy &other);
108
109 void swap(QNetworkProxy &other) noexcept { d.swap(other.d); }
110
111 bool operator==(const QNetworkProxy &other) const;
112 inline bool operator!=(const QNetworkProxy &other) const
113 { return !(*this == other); }
114
117
118 void setCapabilities(Capabilities capab);
119 Capabilities capabilities() const;
120 bool isCachingProxy() const;
121 bool isTransparentProxy() const;
122
123 void setUser(const QString &userName);
124 QString user() const;
125
126 void setPassword(const QString &password);
127 QString password() const;
128
129 void setHostName(const QString &hostName);
130 QString hostName() const;
131
132 void setPort(quint16 port);
133 quint16 port() const;
134
135 static void setApplicationProxy(const QNetworkProxy &proxy);
136 static QNetworkProxy applicationProxy();
137
138 // "cooked" headers
141
142 // raw headers:
143 bool hasRawHeader(const QByteArray &headerName) const;
144 QList<QByteArray> rawHeaderList() const;
145 QByteArray rawHeader(const QByteArray &headerName) const;
147
148private:
150};
151
152Q_DECLARE_SHARED(QNetworkProxy)
153Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkProxy::Capabilities)
154
155class Q_NETWORK_EXPORT QNetworkProxyFactory
156{
157public:
159 virtual ~QNetworkProxyFactory();
160
162
163 static bool usesSystemConfiguration();
164 static void setUseSystemConfiguration(bool enable);
165 static void setApplicationProxyFactory(QNetworkProxyFactory *factory);
166 static QList<QNetworkProxy> proxyForQuery(const QNetworkProxyQuery &query);
167 static QList<QNetworkProxy> systemProxyForQuery(const QNetworkProxyQuery &query = QNetworkProxyQuery());
168};
169
170#ifndef QT_NO_DEBUG_STREAM
171Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QNetworkProxy &proxy);
172Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QNetworkProxyQuery &proxyQuery);
173#endif
174
176
177QT_DECL_METATYPE_EXTERN(QNetworkProxy, Q_NETWORK_EXPORT)
178
179#endif // QT_NO_NETWORKPROXY
180
181#endif // QHOSTINFO_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qlist.h:74
The QNetworkProxyFactory class provides fine-grained proxy selection.
virtual QList< QNetworkProxy > queryProxy(const QNetworkProxyQuery &query=QNetworkProxyQuery())=0
This function takes the query request, query, examines the details of the type of socket or request a...
The QNetworkProxyQuery class is used to query the proxy settings for a socket.
QueryType
Describes the type of one QNetworkProxyQuery query.
bool operator!=(const QNetworkProxyQuery &other) const
Returns true if this QNetworkProxyQuery object does not contain the same data as other.
QNetworkProxyQuery & operator=(QNetworkProxyQuery &&other) noexcept
void swap(QNetworkProxyQuery &other) noexcept
The QNetworkProxy class provides a network layer proxy.
ProxyType
This enum describes the types of network proxying provided in Qt.
void swap(QNetworkProxy &other) noexcept
QNetworkProxy & operator=(QNetworkProxy &&other) noexcept
bool operator!=(const QNetworkProxy &other) const
KnownHeaders
List of known header types that QNetworkRequest parses.
\inmodule QtCore
Definition qshareddata.h:35
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:64
Combined button and popup list for selecting options.
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputPortEXT port
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
Definition qmetatype.h:1367
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QNetworkProxy &proxy)
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
GLenum type
GLboolean enable
GLenum query
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1219
request setUrl(QUrl("http://qt-project.org"))
#define Q_ENUM(x)
#define Q_GADGET
unsigned short quint16
Definition qtypes.h:43
QUrl url("example.com")
[constructor-url-reference]
QSharedPointer< T > other(t)
[5]
this swap(other)
QItemEditorFactory * factory
textPart setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\""))
imagePart setRawHeader("Content-ID", "my@content.id")
proxy setUser("username")
proxy setPassword("password")
QNetworkProxy proxy
[0]
proxy setHostName("proxy.example.com")
proxy setType(QNetworkProxy::Socks5Proxy)
proxy setPort(1080)