42 #include <private/qabstractsocket_p.h> 45 #include "private/qnoncontiguousbytedevice_p.h" 46 #include <private/qnetworkrequest_p.h> 47 #include <private/qobject_p.h> 48 #include <private/qauthenticator_p.h> 61 # include <private/qsslsocket_p.h> 62 # include <QtNetwork/qsslkey.h> 63 # include <QtNetwork/qsslcipher.h> 64 # include <QtNetwork/qsslconfiguration.h> 85 : state(RunningState),
86 hostName(hostName), port(port), encrypt(encrypt),
87 channelCount(defaultChannelCount)
97 hostName(hostName), port(port), encrypt(encrypt),
98 channelCount(channelCount)
124 #ifndef QT_NO_BEARERMANAGEMENT 138 #ifndef QT_NO_OPENSSL 152 #ifndef QT_NO_OPENSSL 174 qFatal(
"Called with unknown socket object.");
180 return reply.d_func()->responseData.byteAmount();
197 if (uploadByteDevice) {
207 qFatal(
"QHttpNetworkConnectionPrivate: Neither content-length nor upload device size were given");
211 #ifndef QT_NO_NETWORKPROXY 221 #ifndef QT_NO_NETWORKPROXY 232 #ifndef QT_NO_COMPRESS 286 reply->d_func()->requestIsPrepared =
true;
297 if (socket && reply) {
303 reply->d_func()->eraseData();
330 if (i == fromChannel)
347 bool isProxy,
bool &resend)
378 if (
channels[i].authenticationCredentialsSent) {
386 #ifndef QT_NO_NETWORKPROXY 388 if (
channels[i].proxyCredentialsSent) {
480 reply->d_func()->connectionChannel = &
channels[0];
534 if (!messagePair.
second->d_func()->requestIsPrepared)
544 if (!messagePair.
second->d_func()->requestIsPrepared)
583 if (!
channels[i].request.isPipeliningAllowed())
600 if (!
channels[i].authenticator.isNull()
604 if (!
channels[i].proxyAuthenticator.isNull()
624 if (lengthBefore ==
channels[i].alreadyPipelinedRequests.length())
637 if (lengthBefore ==
channels[i].alreadyPipelinedRequests.length())
651 for (
int i = queue.
count() - 1; i >= 0; --i) {
672 if (!messagePair.
second->d_func()->requestIsPrepared)
721 errorString = extraDetail;
750 if (reply->d_func()->isConnectionCloseEnabled() || !reply->
isFinished())
759 if (
channels[i].alreadyPipelinedRequests.at(j).second == reply) {
770 channels[i].
reply->d_func()->forceConnectionCloseEnabled =
true;
781 if (messagePair.
second == reply) {
792 if (messagePair.
second == reply) {
859 if ( queuedRequest <=0 )
880 #ifndef QT_NO_BEARERMANAGEMENT 885 d->networkSession = networkSession;
893 d->networkSession = networkSession;
931 return d->queueRequest(request);
942 return d_func()->channels;
945 #ifndef QT_NO_NETWORKPROXY 949 d->networkProxy = networkProxy;
951 if (!
d->networkProxy.user().isEmpty()) {
952 for (
int i = 0; i <
d->channelCount; ++i) {
953 d->channels[i].proxyAuthenticator.setUser(
d->networkProxy.user());
954 d->channels[i].proxyAuthenticator.setPassword(
d->networkProxy.password());
962 return d->networkProxy;
968 for (
int i = 0; i <
d->channelCount; ++i)
969 d->channels[i].socket->setProxy(networkProxy);
975 return d->channels[0].socket->proxy();
981 #ifndef QT_NO_OPENSSL 989 for (
int i = 0; i <
d->channelCount; ++i)
990 static_cast<QSslSocket *>(
d->channels[i].socket)->setSslConfiguration(config);
1000 for (
int i = 0; i <
d->channelCount; ++i) {
1002 d->channels[i].ignoreAllSslErrors =
true;
1007 d->channels[channel].ignoreAllSslErrors =
true;
1017 if (channel == -1) {
1018 for (
int i = 0; i <
d->channelCount; ++i) {
1020 d->channels[i].ignoreSslErrorsList = errors;
1025 d->channels[channel].ignoreSslErrorsList = errors;
1029 #endif //QT_NO_OPENSSL 1031 #ifndef QT_NO_NETWORKPROXY 1042 int i = indexOf(chan->
socket);
1043 copyCredentials(i, auth,
true);
1050 #include "moc_qhttpnetworkconnection_p.cpp" 1052 #endif // QT_NO_HTTP QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
QSharedDataPointer< QHttpNetworkRequestPrivate > d
QList< HttpMessagePair > alreadyPipelinedRequests
void cacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *authenticator)
QString peerName() const
Returns the name of the peer as specified by connectToHost(), or an empty QString if connectToHost() ...
bool handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply, bool isProxy, bool &resend)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
static const QSystemLocale * systemLocale()
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
QHttpNetworkRequest request() const
static void resumeSocketNotifiers(QSslSocket *)
QAuthenticatorPrivate::Method authMethod
void setRequest(const QHttpNetworkRequest &request)
void fillPipeline(QAbstractSocket *socket)
bool authenticationCredentialsSent
void prepareRequest(HttpMessagePair &request)
QNetworkProxy transparentProxy() const
QString & replace(int i, int len, QChar after)
void parseHttpResponse(const QHttpResponseHeader &, bool isProxy)
The QByteArray class provides an array of bytes.
QList< QPair< QByteArray, QByteArray > > header() const
QByteArray methodName() const
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
static void resumeSocketNotifiers(QAbstractSocket *)
NetworkError
Indicates all possible error conditions found during the processing of the request.
QNetworkProxy cacheProxy() const
QList< HttpMessagePair > highPriorityQueue
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
bool proxyCredentialsSent
void setTransparentProxy(const QNetworkProxy &networkProxy)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
QString errorString() const
QString name() const
Returns the language and country of this locale as a string of the form "language_country", where language is a lowercase, two-letter ISO 639 language code, and country is an uppercase, two- or three-letter ISO 3166 country code.
The QString class provides a Unicode character string.
void setUser(const QString &user)
Sets the user used for authentication.
The QObject class is the base class of all Qt objects.
QHttpNetworkConnectionChannel * channels
void emitReplyError(QAbstractSocket *socket, QHttpNetworkReply *reply, QNetworkReply::NetworkError errorCode)
static const int defaultRePipelineLength
QString errorDetail(QNetworkReply::NetworkError errorCode, QAbstractSocket *socket, const QString &extraDetail=QString())
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
static QLocale system()
Returns a QLocale object initialized to the system locale.
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
static QAuthenticatorPrivate * getPrivate(QAuthenticator &auth)
void authenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *authenticator)
void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail=QString())
QHttpNetworkRequest predictNextRequest()
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
void setCacheProxy(const QNetworkProxy &networkProxy)
int indexOf(QAbstractSocket *socket) const
int port() const
Returns the port of the URL, or -1 if the port is unspecified.
QNonContiguousByteDevice * uploadByteDevice() const
Priority priority() const
The QNetworkProxy class provides a network layer proxy.
static QByteArray toAce(const QString &)
Returns the ASCII Compatible Encoding of the given domain name domain.
void requeueCurrentlyPipelinedRequests()
#define QT_BEGIN_NAMESPACE
This macro expands to.
QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue=QByteArray()) const
QSharedPointer< QNetworkSession > networkSession
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QHttpNetworkReply * queueRequest(const QHttpNetworkRequest &request)
static const int defaultPipelineLength
QList< HttpMessagePair > lowPriorityQueue
const T & at(int i) const
Returns the item at index position i in the list.
QString userInfo() const
Returns the user info of the URL, or an empty string if the user info is undefined.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
void createAuthorization(QAbstractSocket *socket, QHttpNetworkRequest &request)
void ignoreSslErrors(int channel=-1)
Operation operation() const
void close()
Closes the I/O device for the socket, disconnects the socket's connection with the host...
#define QT_NO_NETWORKPROXY
QHttpNetworkConnectionChannel * channels() const
~QHttpNetworkConnectionPrivate()
The QAuthenticator class provides an authentication object.
QHttpNetworkConnection * connection()
qint64 contentLength() const
void copyCredentials(int fromChannel, QAuthenticator *auth, bool isProxy)
Q_CORE_EXPORT void qFatal(const char *,...)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QAbstractSocket::NetworkLayerProtocol protocol() const
Returns the network layer protocol of the host address.
QSharedPointer< QNetworkSession > networkSession
int compare(const QString &s) const
void setContentLength(qint64 length)
void setAddress(quint32 ip4Addr)
Set the IPv4 address specified by ip4Addr.
bool withCredentials() const
QHttpNetworkConnection(const QString &hostName, quint16 port=80, bool encrypt=false, QObject *parent=0, QSharedPointer< QNetworkSession > networkSession=QSharedPointer< QNetworkSession >())
void removeReply(QHttpNetworkReply *reply)
QHttpNetworkReply * reply
void requeueRequest(const HttpMessagePair &pair)
bool isNull() const
Returns true if the authenticator is null.
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
QObject * parent() const
Returns a pointer to the parent object.
QString user() const
returns the user used for authentication.
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
void readMoreLater(QHttpNetworkReply *reply)
~QHttpNetworkConnection()
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
QByteArray calculateResponse(const QByteArray &method, const QByteArray &path)
void pipelineInto(HttpMessagePair &pair)
T takeAt(int i)
Removes the item at index position i and returns it.
void setSslConfiguration(const QSslConfiguration &config)
QHttpNetworkReply * sendRequest(const QHttpNetworkRequest &request)
QByteArray uri(bool throughProxy) const
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
A QNonContiguousByteDevice is a representation of a file, array or buffer that allows access with a r...
The QSslConfiguration class holds the configuration and state of an SSL connection.
void setHeaderField(const QByteArray &name, const QByteArray &data)
void _q_startNextRequest()
void setPassword(const QString &password)
Sets the password used for authentication.
bool dequeueRequest(QAbstractSocket *socket)
QAuthenticator authenticator
bool isPipeliningAllowed() const
The QHostAddress class provides an IP address.
QString password() const
returns the password used for authentication.
static void pauseSocketNotifiers(QAbstractSocket *)
virtual qint64 size()=0
Returns the size of the complete device or -1 if unknown.
QAuthenticator proxyAuthenticator
static const int defaultChannelCount
static QChar fromAscii(char c)
Converts the ASCII character c to its equivalent QChar.
QHttpNetworkConnectionPrivate(const QString &hostName, quint16 port, bool encrypt)
The QAbstractSocket class provides the base functionality common to all socket types.
QNetworkProxy networkProxy
qint64 uncompressedBytesAvailable(const QHttpNetworkReply &reply) const
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
static void pauseSocketNotifiers(QSslSocket *)
qint64 uncompressedBytesAvailableNextBlock(const QHttpNetworkReply &reply) const
void setConnection(QHttpNetworkConnection *c)
SocketState state() const
Returns the state of the socket.
The QList class is a template class that provides lists.
QHttpNetworkRequest request
void emitProxyAuthenticationRequired(const QHttpNetworkConnectionChannel *chan, const QNetworkProxy &proxy, QAuthenticator *auth)
QAuthenticatorPrivate::Method proxyAuthMethod
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)