QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &hostName, quint16 port, bool encrypt)
: state(RunningState),
networkLayerState(Unknown),
- hostName(hostName), port(port), encrypt(encrypt),
+ hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true),
channelCount(defaultChannelCount)
#ifndef QT_NO_NETWORKPROXY
, networkProxy(QNetworkProxy::NoProxy)
QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(quint16 channelCount, const QString &hostName, quint16 port, bool encrypt)
: state(RunningState), networkLayerState(Unknown),
- hostName(hostName), port(port), encrypt(encrypt),
+ hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true),
channelCount(channelCount)
#ifndef QT_NO_NETWORKPROXY
, networkProxy(QNetworkProxy::NoProxy)
#endif
channels[i].init();
}
- ipv4ConnectTimer.setSingleShot(true);
- QObject::connect(&ipv4ConnectTimer, SIGNAL(timeout()), q, SLOT(_q_connectIPv4Channel()));
+ delayedConnectionTimer.setSingleShot(true);
+ QObject::connect(&delayedConnectionTimer, SIGNAL(timeout()), q, SLOT(_q_connectDelayedChannel()));
}
void QHttpNetworkConnectionPrivate::pauseConnection()
int otherSocket = (i == 0 ? 1 : 0);
// If the IPv4 connection still isn't started we need to start it now.
- if (ipv4ConnectTimer.isActive()) {
- ipv4ConnectTimer.stop();
- channels[0].ensureConnection();
+ if (delayedConnectionTimer.isActive()) {
+ delayedConnectionTimer.stop();
+ channels[otherSocket].ensureConnection();
}
if (channelCount == 1) {
{
bool bIpv4 = false;
bool bIpv6 = false;
+ bool foundAddress = false;
foreach (QHostAddress address, info.addresses()) {
- if (address.protocol() == QAbstractSocket::IPv4Protocol)
+ if (address.protocol() == QAbstractSocket::IPv4Protocol) {
+ if (!foundAddress) {
+ foundAddress = true;
+ delayIpv4 = false;
+ }
bIpv4 = true;
- else if (address.protocol() == QAbstractSocket::IPv6Protocol)
+ } else if (address.protocol() == QAbstractSocket::IPv6Protocol) {
+ if (!foundAddress) {
+ foundAddress = true;
+ delayIpv4 = true;
+ }
bIpv6 = true;
+ }
}
if (bIpv4 && bIpv6)
else if (networkSession->configuration().bearerType() == QNetworkConfiguration::BearerHSPA)
timeout = 400;
#endif
- ipv4ConnectTimer.start(timeout);
- channels[1].ensureConnection();
+ delayedConnectionTimer.start(timeout);
+ if (delayIpv4)
+ channels[1].ensureConnection();
+ else
+ channels[0].ensureConnection();
} else {
networkLayerState = InProgress;
channels[0].networkLayerPreference = QAbstractSocket::AnyIPProtocol;
}
}
-void QHttpNetworkConnectionPrivate::_q_connectIPv4Channel()
+void QHttpNetworkConnectionPrivate::_q_connectDelayedChannel()
{
- channels[0].ensureConnection();
+ if (delayIpv4)
+ channels[0].ensureConnection();
+ else
+ channels[1].ensureConnection();
}
#ifndef QT_NO_BEARERMANAGEMENT
Q_PRIVATE_SLOT(d_func(), void _q_startNextRequest())
Q_PRIVATE_SLOT(d_func(), void _q_hostLookupFinished(QHostInfo))
- Q_PRIVATE_SLOT(d_func(), void _q_connectIPv4Channel())
+ Q_PRIVATE_SLOT(d_func(), void _q_connectDelayedChannel())
};
void _q_startNextRequest(); // send the next request from the queue
void _q_hostLookupFinished(QHostInfo info);
- void _q_connectIPv4Channel();
+ void _q_connectDelayedChannel();
void createAuthorization(QAbstractSocket *socket, QHttpNetworkRequest &request);
QString hostName;
quint16 port;
bool encrypt;
+ bool delayIpv4;
const int channelCount;
- QTimer ipv4ConnectTimer;
+ QTimer delayedConnectionTimer;
QHttpNetworkConnectionChannel *channels; // parallel connections to the server
bool shouldEmitChannelError(QAbstractSocket *socket);