summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
authorPrasanth Ullattil <prasanth.ullattil@nokia.com>2009-06-11 13:59:33 (GMT)
committerPrasanth Ullattil <prasanth.ullattil@nokia.com>2009-06-12 09:51:15 (GMT)
commit814667587e6ab9dda754647f08fec969ed8434aa (patch)
tree6f9ed3d54728b2dd017e85926af3693231c91358 /src/network/access
parentfd0ef21c295c316ccfebc833c011ed7a9fb5b3fc (diff)
downloadQt-814667587e6ab9dda754647f08fec969ed8434aa.zip
Qt-814667587e6ab9dda754647f08fec969ed8434aa.tar.gz
Qt-814667587e6ab9dda754647f08fec969ed8434aa.tar.bz2
Allow a maximum of 6 simultaneous HTTP connections to a server.
Even though the standard mandates a maximum of 2 connections, most new browsers support atleast 6 connections. So we are also bumping the limit. Task-number: 251144 Reviewed-by: Markus Goetz Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp37
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h2
2 files changed, 21 insertions, 18 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index abaa7fb..b40b4c8 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -64,7 +64,7 @@
QT_BEGIN_NAMESPACE
-const int QHttpNetworkConnectionPrivate::channelCount = 2;
+const int QHttpNetworkConnectionPrivate::channelCount = 6;
QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &hostName, quint16 port, bool encrypt)
: hostName(hostName), port(port), encrypt(encrypt),
@@ -74,6 +74,7 @@ QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &host
#endif
{
+ channels = new Channel[channelCount];
}
QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate()
@@ -82,6 +83,7 @@ QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate()
channels[i].socket->close();
delete channels[i].socket;
}
+ delete []channels;
}
void QHttpNetworkConnectionPrivate::connectSignals(QAbstractSocket *socket)
@@ -1090,25 +1092,26 @@ void QHttpNetworkConnectionPrivate::_q_disconnected()
void QHttpNetworkConnectionPrivate::_q_startNextRequest()
{
- // send the current request again
- if (channels[0].resendCurrent || channels[1].resendCurrent) {
- int i = channels[0].resendCurrent ? 0:1;
- QAbstractSocket *socket = channels[i].socket;
- channels[i].resendCurrent = false;
- channels[i].state = IdleState;
- if (channels[i].reply)
- sendRequest(socket);
- return;
+ //resend the necessary ones.
+ for (int i = 0; i < channelCount; ++i) {
+ if (channels[i].resendCurrent) {
+ channels[i].resendCurrent = false;
+ channels[i].state = IdleState;
+ if (channels[i].reply)
+ sendRequest(channels[i].socket);
+ }
}
- // send the request using the idle socket
- QAbstractSocket *socket = channels[0].socket;
- if (isSocketBusy(socket)) {
- socket = (isSocketBusy(channels[1].socket) ? 0 :channels[1].socket);
+ QAbstractSocket *socket = 0;
+ for (int i = 0; i < channelCount; ++i) {
+ QAbstractSocket *chSocket = channels[i].socket;
+ // send the request using the idle socket
+ if (!isSocketBusy(chSocket)) {
+ socket = chSocket;
+ break;
+ }
}
-
- if (!socket) {
+ if (!socket)
return; // this will be called after finishing current request.
- }
unqueueAndSendRequest(socket);
}
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index 4603a55..b5f3593 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -250,7 +250,7 @@ public:
{}
};
static const int channelCount;
- Channel channels[2]; // maximum of 2 socket connections to the server
+ Channel *channels; // parallel connections to the server
bool pendingAuthSignal; // there is an incomplete authentication signal
bool pendingProxyAuthSignal; // there is an incomplete proxy authentication signal