1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtNetwork module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
42
#ifndef QNETWORKACCESSMANAGER_P_H
43
#define QNETWORKACCESSMANAGER_P_H
49
// This file is not part of the Qt API. It exists for the convenience
50
// of the Network Access API. This header file may change from
51
// version to version without notice, or even be removed.
56
#include "qnetworkaccessmanager.h"
57
#include "qnetworkaccesscache_p.h"
58
#include "qnetworkaccessbackend_p.h"
59
#include "private/qobject_p.h"
60
#include "QtNetwork/qnetworkproxy.h"
61
#include "QtNetwork/qnetworksession.h"
62
#include "qnetworkaccessauthenticationmanager_p.h"
67
class QAbstractNetworkCache;
68
class QNetworkAuthenticationCredential;
69
class QNetworkCookieJar;
71
class QNetworkAccessManagerPrivate: public QObjectPrivate
74
QNetworkAccessManagerPrivate()
75
: networkCache(0), cookieJar(0),
77
#ifndef QT_NO_NETWORKPROXY
80
#ifndef QT_NO_BEARERMANAGEMENT
81
lastSessionState(QNetworkSession::Invalid),
82
networkAccessible(QNetworkAccessManager::Accessible),
85
initializeSession(true),
87
cookieJarCreated(false),
88
authenticationManager(new QNetworkAccessAuthenticationManager)
90
~QNetworkAccessManagerPrivate();
92
void _q_replyFinished();
93
void _q_replySslErrors(const QList<QSslError> &errors);
94
QNetworkReply *postProcess(QNetworkReply *reply);
95
void createCookieJar() const;
97
void authenticationRequired(QAuthenticator *authenticator,
101
QUrl *urlForLastAuthentication,
102
bool allowAuthenticationReuse = true);
103
void cacheCredentials(const QUrl &url, const QAuthenticator *auth);
104
QNetworkAuthenticationCredential *fetchCachedCredentials(const QUrl &url,
105
const QAuthenticator *auth = 0);
107
#ifndef QT_NO_NETWORKPROXY
108
void proxyAuthenticationRequired(const QNetworkProxy &proxy,
110
QAuthenticator *authenticator,
111
QNetworkProxy *lastProxyAuthentication);
112
void cacheProxyCredentials(const QNetworkProxy &proxy, const QAuthenticator *auth);
113
QNetworkAuthenticationCredential *fetchCachedProxyCredentials(const QNetworkProxy &proxy,
114
const QAuthenticator *auth = 0);
115
QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query);
118
QNetworkAccessBackend *findBackend(QNetworkAccessManager::Operation op, const QNetworkRequest &request);
120
#ifndef QT_NO_BEARERMANAGEMENT
121
void createSession(const QNetworkConfiguration &config);
122
QSharedPointer<QNetworkSession> getNetworkSession() const;
124
void _q_networkSessionClosed();
125
void _q_networkSessionNewConfigurationActivated();
126
void _q_networkSessionPreferredConfigurationChanged(const QNetworkConfiguration &config,
128
void _q_networkSessionStateChanged(QNetworkSession::State state);
131
QNetworkRequest prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart);
133
// this is the cache for storing downloaded files
134
QAbstractNetworkCache *networkCache;
136
QNetworkCookieJar *cookieJar;
141
#ifndef QT_NO_NETWORKPROXY
143
QNetworkProxyFactory *proxyFactory;
146
#ifndef QT_NO_BEARERMANAGEMENT
147
QSharedPointer<QNetworkSession> networkSessionStrongRef;
148
QWeakPointer<QNetworkSession> networkSessionWeakRef;
149
QNetworkSession::State lastSessionState;
150
QString networkConfiguration;
151
QNetworkAccessManager::NetworkAccessibility networkAccessible;
152
int activeReplyCount;
154
bool initializeSession;
157
bool cookieJarCreated;
159
// The cache with authorization data:
160
QSharedPointer<QNetworkAccessAuthenticationManager> authenticationManager;
162
// this cache can be used by individual backends to cache e.g. their TCP connections to a server
163
// and use the connections for multiple requests.
164
QNetworkAccessCache objectCache;
165
static inline QNetworkAccessCache *getObjectCache(QNetworkAccessBackend *backend)
166
{ return &backend->manager->objectCache; }
167
Q_AUTOTEST_EXPORT static void clearCache(QNetworkAccessManager *manager);
168
#ifndef QT_NO_BEARERMANAGEMENT
169
Q_AUTOTEST_EXPORT static const QWeakPointer<const QNetworkSession> getNetworkSession(const QNetworkAccessManager *manager);
171
Q_DECLARE_PUBLIC(QNetworkAccessManager)