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
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:
71 QSharedDataPointer<QNetworkProxyQueryPrivate> d;
72};
73
74Q_DECLARE_SHARED(QNetworkProxyQuery)
75
77
78class Q_NETWORK_EXPORT QNetworkProxy
79{
81public:
90
92 TunnelingCapability = 0x0001,
93 ListeningCapability = 0x0002,
94 UdpTunnelingCapability = 0x0004,
95 CachingCapability = 0x0008,
96 HostNameLookupCapability = 0x0010,
97 SctpTunnelingCapability = 0x00020,
98 SctpListeningCapability = 0x00040
99 };
100 Q_DECLARE_FLAGS(Capabilities, Capability)
101
103 QNetworkProxy(ProxyType type, const QString &hostName = QString(), quint16 port = 0,
104 const QString &user = QString(), const QString &password = QString());
106 QNetworkProxy &operator=(QNetworkProxy &&other) noexcept { swap(other); return *this; }
107 QNetworkProxy &operator=(const QNetworkProxy &other);
109
110 void swap(QNetworkProxy &other) noexcept { d.swap(other.d); }
111
112 bool operator==(const QNetworkProxy &other) const;
113 inline bool operator!=(const QNetworkProxy &other) const
114 { return !(*this == other); }
115
118
119 void setCapabilities(Capabilities capab);
120 Capabilities capabilities() const;
121 bool isCachingProxy() const;
122 bool isTransparentProxy() const;
123
124 void setUser(const QString &userName);
125 QString user() const;
126
127 void setPassword(const QString &password);
128 QString password() const;
129
130 void setHostName(const QString &hostName);
131 QString hostName() const;
132
133 void setPort(quint16 port);
134 quint16 port() const;
135
136 static void setApplicationProxy(const QNetworkProxy &proxy);
137 static QNetworkProxy applicationProxy();
138
139 QHttpHeaders headers() const;
140 void setHeaders(const QHttpHeaders &newHeaders);
141 void setHeaders(QHttpHeaders &&newHeaders);
142
143 // "cooked" headers
146
147 // raw headers:
148 bool hasRawHeader(const QByteArray &headerName) const;
149 QList<QByteArray> rawHeaderList() const;
150 QByteArray rawHeader(const QByteArray &headerName) const;
151 void setRawHeader(const QByteArray &headerName, const QByteArray &value);
152
153private:
154 QSharedDataPointer<QNetworkProxyPrivate> d;
155};
156
157Q_DECLARE_SHARED(QNetworkProxy)
158Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkProxy::Capabilities)
159
160class Q_NETWORK_EXPORT QNetworkProxyFactory
161{
162public:
164 virtual ~QNetworkProxyFactory();
165
166 virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) = 0;
167
168 static bool usesSystemConfiguration();
169 static void setUseSystemConfiguration(bool enable);
170 static void setApplicationProxyFactory(QNetworkProxyFactory *factory);
171 static QList<QNetworkProxy> proxyForQuery(const QNetworkProxyQuery &query);
172 static QList<QNetworkProxy> systemProxyForQuery(const QNetworkProxyQuery &query = QNetworkProxyQuery());
173};
174
175#ifndef QT_NO_DEBUG_STREAM
176Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QNetworkProxy &proxy);
177Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QNetworkProxyQuery &proxyQuery);
178#endif
179
181
182QT_DECL_METATYPE_EXTERN(QNetworkProxy, Q_NETWORK_EXPORT)
183
184#endif // QT_NO_NETWORKPROXY
185
186#endif // QHOSTINFO_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
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.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:65
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:1388
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QNetworkProxy &proxy)
GLenum type
GLboolean enable
GLenum query
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
request setUrl(QUrl("http://qt-project.org"))
#define Q_ENUM(x)
#define Q_GADGET
unsigned short quint16
Definition qtypes.h:48
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)