qhttpnetworkconnection.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qhttpnetworkconnection.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14const int QHttpNetworkConnectionPrivate::defaultHttpChannelCount = 6;-
15-
16-
17const int QHttpNetworkConnectionPrivate::defaultPipelineLength = 3;-
18-
19-
20const int QHttpNetworkConnectionPrivate::defaultRePipelineLength = 2;-
21-
22-
23QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &hostName,-
24 quint16 port, bool encrypt,-
25 QHttpNetworkConnection::ConnectionType type)-
26: state(RunningState),-
27 networkLayerState(Unknown),-
28 hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true)-
29-
30, channelCount((type == QHttpNetworkConnection::ConnectionTypeSPDY) ? 1 : defaultHttpChannelCount)-
31-
32-
33-
34-
35 , networkProxy(QNetworkProxy::NoProxy)-
36-
37 , preConnectRequests(0)-
38 , connectionType(type)-
39{-
40 channels = new QHttpNetworkConnectionChannel[channelCount];-
41}-
42-
43QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(quint16 channelCount, const QString &hostName,-
44 quint16 port, bool encrypt,-
45 QHttpNetworkConnection::ConnectionType type)-
46: state(RunningState), networkLayerState(Unknown),-
47 hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true),-
48 channelCount(channelCount)-
49-
50 , networkProxy(QNetworkProxy::NoProxy)-
51-
52 , preConnectRequests(0)-
53 , connectionType(type)-
54{-
55 channels = new QHttpNetworkConnectionChannel[channelCount];-
56}-
57-
58-
59-
60QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate()-
61{-
62 for (int i = 0; i < channelCount
i < channelCountDescription
TRUEevaluated 3410 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_spdy - unknown status
FALSEevaluated 582 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_spdy - unknown status
; ++i) {
582-3410
63 if (channels[i].socket
channels[i].socketDescription
TRUEevaluated 752 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_spdy - unknown status
FALSEevaluated 2658 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
) {
752-2658
64 QObject::disconnect(channels[i].socket, nullptr, &channels[i], nullptr);-
65 channels[i].socket->close();-
66 delete channels[i].socket;-
67 }
executed 752 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_spdy - unknown status
752
68 }
executed 3410 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_spdy - unknown status
3410
69 delete []channels;-
70}
executed 582 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_spdy - unknown status
582
71-
72void QHttpNetworkConnectionPrivate::init()-
73{-
74 QHttpNetworkConnection * const q = q_func();-
75 for (int i = 0; i < channelCount; i++) {-
76 channels[i].setConnection(this->q_func());-
77 channels[i].ssl = encrypt;-
78-
79-
80 channels[i].networkSession = networkSession;-
81-
82 }-
83-
84 delayedConnectionTimer.setSingleShot(true);-
85 QObject::connect(&delayedConnectionTimer, qFlagLocation("2""timeout()" "\0" __FILE__ ":" "133""140"), q, qFlagLocation("1""_q_connectDelayedChannel()" "\0" __FILE__ ":" "133""140"));-
86}-
87-
88void QHttpNetworkConnectionPrivate::pauseConnection()-
89{-
90 state = PausedState;-
91-
92-
93 for (int i = 0; i < channelCount; i++) {-
94 if (channels[i].socket) {-
95-
96 if (encrypt)-
97 QSslSocketPrivate::pauseSocketNotifiers(static_cast<QSslSocket*>(channels[i].socket));-
98 else-
99-
100 QAbstractSocketPrivate::pauseSocketNotifiers(channels[i].socket);-
101 }-
102 }-
103}-
104-
105void QHttpNetworkConnectionPrivate::resumeConnection()-
106{-
107 state = RunningState;-
108-
109 for (int i = 0; i < channelCount; i++) {-
110 if (channels[i].socket) {-
111-
112 if (encrypt)-
113 QSslSocketPrivate::resumeSocketNotifiers(static_cast<QSslSocket*>(channels[i].socket));-
114 else-
115-
116 QAbstractSocketPrivate::resumeSocketNotifiers(channels[i].socket);-
117-
118-
119 if (channels[i].state == QHttpNetworkConnectionChannel::WritingState)-
120 QMetaObject::invokeMethod(&channels[i], "_q_uploadDataReadyRead", Qt::QueuedConnection);-
121 }-
122 }-
123-
124-
125 QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);-
126}-
127-
128int QHttpNetworkConnectionPrivate::indexOf(QAbstractSocket *socket) const-
129{-
130 for (int i = 0; i < channelCount; ++i)-
131 if (channels[i].socket == socket)-
132 return i;-
133-
134 QMessageLogger(__FILE__, 182189, __PRETTY_FUNCTION__).fatal("Called with unknown socket object.");-
135 return 0;-
136}-
137-
138-
139-
140-
141-
142bool QHttpNetworkConnectionPrivate::shouldEmitChannelError(QAbstractSocket *socket)-
143{-
144 QHttpNetworkConnection * const q = q_func();-
145-
146 bool emitError = true;-
147 int i = indexOf(socket);-
148 int otherSocket = (i == 0
i == 0Description
TRUEevaluated 27 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 125 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
? 1 : 0);
27-125
149-
150-
151 if (delayedConnectionTimer.isActive()
delayedConnect...mer.isActive()Description
TRUEevaluated 122 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 30 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
) {
30-122
152 delayedConnectionTimer.stop();-
153 channels[otherSocket].ensureConnection();-
154 }
executed 122 times by 2 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
122
155-
156 if (channelCount == 1
channelCount == 1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEevaluated 149 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
) {
3-149
157 if (networkLayerState == HostLookupPending
networkLayerSt...tLookupPendingDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_Spdy
|| networkLayerState == IPv4or6
networkLayerState == IPv4or6Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_Spdy
)
0-3
158 networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
never executed: networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
0
159 channels[0].close();-
160 emitError = true;-
161 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_Spdy
else {
3
162 if (networkLayerState == HostLookupPending
networkLayerSt...tLookupPendingDescription
TRUEnever evaluated
FALSEevaluated 149 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
|| networkLayerState == IPv4or6
networkLayerState == IPv4or6Description
TRUEevaluated 124 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
) {
0-149
163 if (channels[otherSocket].isSocketBusy()
channels[other...isSocketBusy()Description
TRUEevaluated 122 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
&& (
(channels[othe...:ClosingState)Description
TRUEevaluated 122 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEnever evaluated
channels[otherSocket].state != QHttpNetworkConnectionChannel::ClosingState)
(channels[othe...:ClosingState)Description
TRUEevaluated 122 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-122
164-
165 channels[i].close();-
166 emitError = false;-
167 }
executed 122 times by 2 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
122
168 else {-
169-
170 networkLayerState = QHttpNetworkConnectionPrivate::Unknown;-
171 channels[i].close();-
172 emitError = true;-
173 }
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
2
174 } else {-
175 if (((
(networkLayerS...Private::IPv4)Description
TRUEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
networkLayerState == QHttpNetworkConnectionPrivate::IPv4)
(networkLayerS...Private::IPv4)Description
TRUEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
&& (
(channels[i].n...:IPv4Protocol)Description
TRUEnever evaluated
FALSEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
channels[i].networkLayerPreference != QAbstractSocket::IPv4Protocol)
(channels[i].n...:IPv4Protocol)Description
TRUEnever evaluated
FALSEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
)
0-25
176 || ((
(networkLayerS...Private::IPv6)Description
TRUEnever evaluated
FALSEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
networkLayerState == QHttpNetworkConnectionPrivate::IPv6)
(networkLayerS...Private::IPv6)Description
TRUEnever evaluated
FALSEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
&& (
(channels[i].n...:IPv6Protocol)Description
TRUEnever evaluated
FALSEnever evaluated
channels[i].networkLayerPreference != QAbstractSocket::IPv6Protocol)
(channels[i].n...:IPv6Protocol)Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0-25
177-
178 channels[i].close();-
179 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);-
180 emitError = false;-
181 }
never executed: end of block
0
182 if (networkLayerState == QHttpNetworkConnectionPrivate::Unknown
networkLayerSt...ivate::UnknownDescription
TRUEnever evaluated
FALSEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
)
0-25
183 QMessageLogger(__FILE__, 231238, __PRETTY_FUNCTION__).warning() << ("We got a connection error when networkLayerState is Unknown";);
never executed: QMessageLogger(__FILE__, 238, __PRETTY_FUNCTION__).warning("We got a connection error when networkLayerState is Unknown");
0
184 }
executed 25 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
25
185 }-
186 return
executed 152 times by 4 tests: return emitError;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
emitError;
executed 152 times by 4 tests: return emitError;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
152
187}-
188-
189-
190qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailable(const QHttpNetworkReply &reply) const-
191{-
192 return reply.d_func()->responseData.byteAmount();-
193}-
194-
195qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailableNextBlock(const QHttpNetworkReply &reply) const-
196{-
197 return reply.d_func()->responseData.sizeNextBlock();-
198}-
199-
200void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair)-
201{-
202 QHttpNetworkRequest &request = messagePair.first;-
203 QHttpNetworkReply *reply = messagePair.second;-
204-
205-
206 QByteArray value;-
207-
208 QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice();-
209 if (uploadByteDevice
uploadByteDeviceDescription
TRUEevaluated 201 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 1436 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
) {
201-1436
210 if (const qint64 contentLength = request.contentLength()();-
211 const qint64 uploadDeviceSize = uploadByteDevice->size();-
212 if (contentLength
contentLength != -1Description
TRUEevaluated 131 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 70 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
contentLength != -1Description
TRUEevaluated 131 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 70 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
!= -1
contentLength != -1Description
TRUEevaluated 131 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 70 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
&& uploadByteDevice->size()uploadDeviceSize
uploadDeviceSize != -1Description
TRUEevaluated 130 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
!= -1
uploadDeviceSize != -1Description
TRUEevaluated 130 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
) {
1-131
213-
214 request.setContentLength(qMin(uploadByteDevice->size(), request.uploadDeviceSize, contentLength()));));-
215 }
executed 130 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
else if (request.contentLength ()== -1
contentLength == -1Description
TRUEevaluated 70 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
&& uploadByteDevice->size()uploadDeviceSize
uploadDeviceSize != -1Description
TRUEevaluated 70 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
!= -1
uploadDeviceSize != -1Description
TRUEevaluated 70 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-130
216-
217 request.setContentLength(uploadByteDevice->size());uploadDeviceSize);-
218 }
executed 70 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
else if (request.contentLength ()!= -1
contentLength != -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
&& uploadByteDevice->size()uploadDeviceSize
uploadDeviceSize == -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
== -1
uploadDeviceSize == -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-70
219-
220 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
else if (request.__builtin_expect(!!(
__builtin_expe...== -1), false)Description
TRUEnever evaluated
FALSEnever evaluated
contentLength ()== -1 && uploadByteDevice->size()uploadDeviceSize == -1)), false)
__builtin_expe...== -1), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0-1
221 QMessageLogger(__FILE__, 267276, __PRETTY_FUNCTION__).fatal("QHttpNetworkConnectionPrivate: Neither content-length nor upload device size were given");-
222 }
never executed: end of block
0
223 }
executed 201 times by 4 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
201
224-
225-
226 if (networkProxy.type() == QNetworkProxy::HttpCachingProxy
networkProxy.t...tpCachingProxyDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1629 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
) {
8-1629
227 value = request.headerField("proxy-connection");-
228 if (value.isEmpty()
value.isEmpty()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
)
0-8
229 request.setHeaderField("Proxy-Connection", "Keep-Alive");
executed 8 times by 1 test: request.setHeaderField("Proxy-Connection", "Keep-Alive");
Executed by:
  • tst_QNetworkReply
8
230 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
else {
8
231-
232 value = request.headerField("connection");-
233 if (value.isEmpty()
value.isEmpty()Description
TRUEevaluated 1629 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
)
0-1629
234 request.setHeaderField("Connection", "Keep-Alive");
executed 1629 times by 8 tests: request.setHeaderField("Connection", "Keep-Alive");
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1629
235-
236 }
executed 1629 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1629
237-
238-
239-
240-
241-
242-
243-
244 value = request.headerField("accept-encoding");-
245 if (value.isEmpty()
value.isEmpty()Description
TRUEevaluated 1635 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QHttpNetworkConnection
) {
2-1635
246-
247 request.setHeaderField("Accept-Encoding", "gzip, deflate");-
248 request.d->autoDecompress = true;-
249-
250-
251-
252-
253 }
executed 1635 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1635
254-
255-
256-
257-
258-
259 value = request.headerField("accept-language");-
260 if (value.isEmpty()
value.isEmpty()Description
TRUEevaluated 1637 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
) {
0-1637
261 QString systemLocale = QLocale::system().name().replace(QChar::fromLatin1('_'),QChar::fromLatin1('-'));-
262 QString acceptLanguage;-
263 if (systemLocale == QLatin1String("C")
systemLocale =...in1String("C")Description
TRUEnever evaluated
FALSEevaluated 1637 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
)
0-1637
264 acceptLanguage = QString::fromLatin1("en,*");
never executed: acceptLanguage = QString::fromLatin1("en,*");
0
265 else if (systemLocale.startsWith(QLatin1String("en-"))
systemLocale.s...String("en-"))Description
TRUEevaluated 1637 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
)
0-1637
266 acceptLanguage = QString::fromLatin1("%1,*").arg(systemLocale);
executed 1637 times by 8 tests: acceptLanguage = QString::fromLatin1("%1,*").arg(systemLocale);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1637
267 else-
268 acceptLanguage = QString::fromLatin1("%1,en,*").arg(systemLocale);
never executed: acceptLanguage = QString::fromLatin1("%1,en,*").arg(systemLocale);
0
269 request.setHeaderField("Accept-Language", acceptLanguage.toLatin1());-
270 }
executed 1637 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1637
271-
272-
273 value = request.headerField("user-agent");-
274 if (value.isEmpty()
value.isEmpty()Description
TRUEevaluated 1633 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
)
4-1633
275 request.setHeaderField("User-Agent", "Mozilla/5.0");
executed 1633 times by 7 tests: request.setHeaderField("User-Agent", "Mozilla/5.0");
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1633
276-
277 value = request.headerField("host");-
278 if (value.isEmpty()
value.isEmpty()Description
TRUEevaluated 1636 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QXmlInputSource
) {
1-1636
279 QHostAddress add;-
280 QByteArray host;-
281 if (add.setAddress(hostName)
add.setAddress(hostName)Description
TRUEevaluated 43 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 1593 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
) {
43-1593
282 if (add.protocol() == QAbstractSocket::IPv6Protocol
add.protocol()...::IPv6ProtocolDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 42 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
)
1-42
283 host = '[' + hostName.toLatin1() + ']';
executed 1 time by 1 test: host = '[' + hostName.toLatin1() + ']';
Executed by:
  • tst_QNetworkReply
1
284 else-
285 host = hostName.toLatin1();
executed 42 times by 3 tests: host = hostName.toLatin1();
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
42
286-
287 } else {-
288 host = QUrl::toAce(hostName);-
289 }
executed 1593 times by 7 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1593
290-
291 int port = request.url().port();-
292 if (port != -1
port != -1Description
TRUEevaluated 173 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 1463 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
) {
173-1463
293 host += ':';-
294 host += QByteArray::number(port);-
295 }
executed 173 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
173
296-
297 request.setHeaderField("Host", host);-
298 }
executed 1636 times by 7 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1636
299-
300 reply->d_func()->requestIsPrepared = true;-
301}
executed 1637 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1637
302-
303-
304-
305-
306void QHttpNetworkConnectionPrivate::emitReplyError(QAbstractSocket *socket,-
307 QHttpNetworkReply *reply,-
308 QNetworkReply::NetworkError errorCode)-
309{-
310 QHttpNetworkConnection * const q = q_func();-
311-
312 int i = 0;-
313 if (socket)-
314 i = indexOf(socket);-
315-
316 if (reply) {-
317-
318 reply->d_func()->errorString = errorDetail(errorCode, socket);-
319 reply->finishedWithError(errorCode, reply->d_func()->errorString);-
320-
321 reply->d_func()->eraseData();-
322-
323-
324 channels[i].close();-
325 channels[i].reply = 0;-
326 if (channels[i].protocolHandler)-
327 channels[i].protocolHandler->setReply(0);-
328 channels[i].request = QHttpNetworkRequest();-
329 if (socket)-
330 channels[i].requeueCurrentlyPipelinedRequests();-
331-
332-
333 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);-
334 }-
335}-
336-
337void QHttpNetworkConnectionPrivate::copyCredentials(int fromChannel, QAuthenticator *auth, bool isProxy)-
338{-
339 ((!(auth)) ? qt_assert("auth",__FILE__,385394) : qt_noop());-
340-
341-
342 if (fromChannel >= 0) {-
343 if (!isProxy && channels[fromChannel].authMethod == QAuthenticatorPrivate::Ntlm)-
344 return;-
345 if (isProxy && channels[fromChannel].proxyAuthMethod == QAuthenticatorPrivate::Ntlm)-
346 return;-
347 }-
348-
349-
350 QAuthenticator* otherAuth = 0;-
351 for (int i = 0; i < channelCount; ++i) {-
352 if (i == fromChannel)-
353 continue;-
354 if (isProxy)-
355 otherAuth = &channels[i].proxyAuthenticator;-
356 else-
357 otherAuth = &channels[i].authenticator;-
358-
359 if (otherAuth->user().compare(auth->user()))-
360 otherAuth->setUser(auth->user());-
361 if (otherAuth->password().compare(auth->password()))-
362 otherAuth->setPassword(auth->password());-
363 }-
364}-
365-
366-
367-
368bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply,-
369 bool isProxy, bool &resend)-
370{-
371 ((!(socket)) ? qt_assert("socket",__FILE__,417426) : qt_noop());-
372 ((!(reply)) ? qt_assert("reply",__FILE__,418427) : qt_noop());-
373-
374 resend = false;-
375-
376 QList<QPair<QByteArray, QByteArray> > fields = reply->header();-
377-
378-
379 QAuthenticatorPrivate::Method authMethod = reply->d_func()->authenticationMethod(isProxy);-
380 if (authMethod != QAuthenticatorPrivate::None) {-
381 int i = indexOf(socket);-
382-
383 QAuthenticator* auth = 0;-
384 if (isProxy) {-
385 auth = &channels[i].proxyAuthenticator;-
386 channels[i].proxyAuthMethod = authMethod;-
387 } else {-
388 auth = &channels[i].authenticator;-
389 channels[i].authMethod = authMethod;-
390 }-
391-
392 if (auth->isNull())-
393 auth->detach();-
394 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*auth);-
395 priv->parseHttpResponse(fields, isProxy);-
396-
397 if (priv->phase == QAuthenticatorPrivate::Done) {-
398 pauseConnection();-
399 if (!isProxy) {-
400 if (channels[i].authenticationCredentialsSent) {-
401 auth->detach();-
402 priv = QAuthenticatorPrivate::getPrivate(*auth);-
403 priv->hasFailed = true;-
404 priv->phase = QAuthenticatorPrivate::Done;-
405 channels[i].authenticationCredentialsSent = false;-
406 }-
407 reply->authenticationRequired(reply->request(), auth);-
408-
409 } else {-
410 if (channels[i].proxyCredentialsSent) {-
411 auth->detach();-
412 priv = QAuthenticatorPrivate::getPrivate(*auth);-
413 priv->hasFailed = true;-
414 priv->phase = QAuthenticatorPrivate::Done;-
415 channels[i].proxyCredentialsSent = false;-
416 }-
417 reply->proxyAuthenticationRequired(networkProxy, auth);-
418-
419 }-
420 resumeConnection();-
421-
422 if (priv->phase != QAuthenticatorPrivate::Done) {-
423-
424 copyCredentials(i, auth, isProxy);-
425 }-
426 } else if (priv->phase == QAuthenticatorPrivate::Start) {-
427-
428-
429-
430 reply->cacheCredentials(reply->request(), auth);-
431 }-
432-
433-
434-
435-
436 if (priv->phase == QAuthenticatorPrivate::Done || !reply->request().withCredentials()) {-
437-
438 auth = 0;-
439 if (isProxy)-
440 channels[i].proxyAuthenticator = QAuthenticator();-
441 else-
442 channels[i].authenticator = QAuthenticator();-
443-
444-
445 channels[i].reply->headerChanged();-
446 channels[i].reply->readyRead();-
447 QNetworkReply::NetworkError errorCode =-
448 isProxy-
449 ? QNetworkReply::ProxyAuthenticationRequiredError-
450 : QNetworkReply::AuthenticationRequiredError;-
451 reply->d_func()->errorString = errorDetail(errorCode, socket);-
452 reply->finishedWithError(errorCode, reply->d_func()->errorString);-
453-
454 return true;-
455 }-
456-
457 resend = true;-
458 return true;-
459 }-
460 return false;-
461}-
462-
463QUrl QHttpNetworkConnectionPrivate::parseRedirectResponse(QAbstractSocket *socket, QHttpNetworkReply *reply)-
464{-
465 if (!reply->request().isFollowRedirects()
!reply->reques...lowRedirects()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkProxyFactory
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
)
3-6
466 return
executed 3 times by 1 test: return QUrl();
Executed by:
  • tst_QNetworkProxyFactory
QUrl();
executed 3 times by 1 test: return QUrl();
Executed by:
  • tst_QNetworkProxyFactory
3
467-
468 QUrl rUrl;-
469 const QList<QPair<QByteArray, QByteArray> > fields = reply->header();-
470 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(fields)>::type> _container_((fields)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QNetworkReply::RawHeaderPair &header = *_container_.i; _container_.control; _container_.control = 0: fields) {-
471 if (header.first.toLower() == "location"
header.first.t... == "location"Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
) {
6
472 rUrl = QUrl::fromEncoded(header.second);-
473 break;
executed 6 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
6
474 }-
475 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
6
476-
477-
478 if (!rUrl.isValid()
!rUrl.isValid()Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
) {
0-6
479 emitReplyError(socket, reply, QNetworkReply::ProtocolUnknownError);-
480 return
never executed: return QUrl();
QUrl();
never executed: return QUrl();
0
481 }-
482-
483-
484 if (reply->request().redirectCount() <= 0
reply->request...ctCount() <= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
) {
1-5
485 emitReplyError(socket, reply, QNetworkReply::TooManyRedirectsError);-
486 return
executed 1 time by 1 test: return QUrl();
Executed by:
  • tst_QNetworkReply
QUrl();
executed 1 time by 1 test: return QUrl();
Executed by:
  • tst_QNetworkReply
1
487 }-
488-
489-
490 if (rUrl.isRelative()
rUrl.isRelative()Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
)
0-5
491 rUrl = reply->request().url().resolved(rUrl);
never executed: rUrl = reply->request().url().resolved(rUrl);
0
492-
493-
494 QString scheme = rUrl.scheme();-
495 if (scheme == QLatin1String("http")
scheme == QLat...String("http")Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
|| scheme == QLatin1String("https")
scheme == QLat...tring("https")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0-5
496 QString previousUrlScheme = reply->request().url().scheme();-
497-
498 if (previousUrlScheme == QLatin1String("https")
previousUrlSch...tring("https")Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-5
499 && scheme == QLatin1String("http")
scheme == QLat...String("http")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
500 emitReplyError(socket, reply, QNetworkReply::InsecureRedirectError);-
501 return
never executed: return QUrl();
QUrl();
never executed: return QUrl();
0
502 }-
503 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
else {
5
504 emitReplyError(socket, reply, QNetworkReply::ProtocolUnknownError);-
505 return
never executed: return QUrl();
QUrl();
never executed: return QUrl();
0
506 }-
507 return
executed 5 times by 1 test: return rUrl;
Executed by:
  • tst_QNetworkReply
rUrl;
executed 5 times by 1 test: return rUrl;
Executed by:
  • tst_QNetworkReply
5
508}-
509-
510void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, QHttpNetworkRequest &request)-
511{-
512 ((!(socket)) ? qt_assert("socket",__FILE__,558567) : qt_noop());-
513-
514 int i = indexOf(socket);-
515-
516-
517 if (channels[i].authMethod != QAuthenticatorPrivate::None) {-
518 if ((channels[i].authMethod != QAuthenticatorPrivate::Ntlm && request.headerField("Authorization").isEmpty()) || channels[i].lastStatus == 401) {-
519 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator);-
520 if (priv && priv->method != QAuthenticatorPrivate::None) {-
521 QByteArray response = priv->calculateResponse(request.methodName(), request.uri(false));-
522 request.setHeaderField("Authorization", response);-
523 channels[i].authenticationCredentialsSent = true;-
524 }-
525 }-
526 }-
527-
528-
529 if (channels[i].proxyAuthMethod != QAuthenticatorPrivate::None) {-
530 if (!(channels[i].proxyAuthMethod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 407)) {-
531 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].proxyAuthenticator);-
532 if (priv && priv->method != QAuthenticatorPrivate::None) {-
533 QByteArray response = priv->calculateResponse(request.methodName(), request.uri(false));-
534 request.setHeaderField("Proxy-Authorization", response);-
535 channels[i].proxyCredentialsSent = true;-
536 }-
537 }-
538 }-
539}-
540-
541QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetworkRequest &request)-
542{-
543 QHttpNetworkConnection * const q = q_func();-
544-
545-
546 QHttpNetworkReply *reply = new QHttpNetworkReply(request.url());-
547 reply->setRequest(request);-
548 reply->d_func()->connection = q;-
549 reply->d_func()->connectionChannel = &channels[0];-
550 HttpMessagePair pair = qMakePair(request, reply);-
551-
552 if (request.isPreConnect())-
553 preConnectRequests++;-
554-
555 if (connectionType == QHttpNetworkConnection::ConnectionTypeHTTP) {-
556 switch (request.priority()) {-
557 case QHttpNetworkRequest::HighPriority:-
558 highPriorityQueue.prepend(pair);-
559 break;-
560 case QHttpNetworkRequest::NormalPriority:-
561 case QHttpNetworkRequest::LowPriority:-
562 lowPriorityQueue.prepend(pair);-
563 break;-
564 }-
565 }-
566-
567 else {-
568 if (!pair.second->d_func()->requestIsPrepared)-
569 prepareRequest(pair);-
570 channels[0].spdyRequestsToSend.insertMulti(request.priority(), pair);-
571 }-
572-
573-
574-
575-
576-
577-
578 if (networkLayerState == Unknown || networkLayerState == HostLookupPending) {-
579 startHostInfoLookup();-
580 } else if ( networkLayerState == IPv4 || networkLayerState == IPv6 ) {-
581 _q_startNextRequest();-
582 }-
583 return reply;-
584}-
585-
586void QHttpNetworkConnectionPrivate::requeueRequest(const HttpMessagePair &pair)-
587{-
588 QHttpNetworkConnection * const q = q_func();-
589-
590 QHttpNetworkRequest request = pair.first;-
591 switch (request.priority()) {-
592 case QHttpNetworkRequest::HighPriority:-
593 highPriorityQueue.prepend(pair);-
594 break;-
595 case QHttpNetworkRequest::NormalPriority:-
596 case QHttpNetworkRequest::LowPriority:-
597 lowPriorityQueue.prepend(pair);-
598 break;-
599 }-
600-
601 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);-
602}-
603-
604bool QHttpNetworkConnectionPrivate::dequeueRequest(QAbstractSocket *socket)-
605{-
606 int i = 0;-
607 if (socket)-
608 i = indexOf(socket);-
609-
610 if (!highPriorityQueue.isEmpty()) {-
611-
612 HttpMessagePair messagePair = highPriorityQueue.takeLast();-
613 if (!messagePair.second->d_func()->requestIsPrepared)-
614 prepareRequest(messagePair);-
615 updateChannel(i, messagePair);-
616 return true;-
617 }-
618-
619 if (!lowPriorityQueue.isEmpty()) {-
620-
621 HttpMessagePair messagePair = lowPriorityQueue.takeLast();-
622 if (!messagePair.second->d_func()->requestIsPrepared)-
623 prepareRequest(messagePair);-
624 updateChannel(i, messagePair);-
625 return true;-
626 }-
627 return false;-
628}-
629-
630void QHttpNetworkConnectionPrivate::updateChannel(int i, const HttpMessagePair &messagePair)-
631{-
632 channels[i].request = messagePair.first;-
633 channels[i].reply = messagePair.second;-
634-
635-
636 channels[i].reply->d_func()->connectionChannel = &channels[i];-
637}-
638-
639QHttpNetworkRequest QHttpNetworkConnectionPrivate::predictNextRequest() const-
640{-
641 if (!highPriorityQueue.isEmpty()
!highPriorityQueue.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 21 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
)
0-21
642 return
never executed: return highPriorityQueue.last().first;
highPriorityQueue.last().first;
never executed: return highPriorityQueue.last().first;
0
643 if (!lowPriorityQueue.isEmpty()
!lowPriorityQueue.isEmpty()Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_Spdy
)
4-17
644 return
executed 17 times by 1 test: return lowPriorityQueue.last().first;
Executed by:
  • tst_QNetworkReply
lowPriorityQueue.last().first;
executed 17 times by 1 test: return lowPriorityQueue.last().first;
Executed by:
  • tst_QNetworkReply
17
645 return
executed 4 times by 1 test: return QHttpNetworkRequest();
Executed by:
  • tst_Spdy
QHttpNetworkRequest();
executed 4 times by 1 test: return QHttpNetworkRequest();
Executed by:
  • tst_Spdy
4
646}-
647-
648-
649void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket)-
650{-
651-
652 if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())-
653 return;-
654-
655 int i = indexOf(socket);-
656-
657-
658 if (channels[i].reply == 0)-
659 return;-
660-
661 if (! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.length() >= defaultRePipelineLength)) {-
662 return;-
663 }-
664-
665 if (channels[i].pipeliningSupported != QHttpNetworkConnectionChannel::PipeliningProbablySupported)-
666 return;-
667-
668-
669 if (!channels[i].request.isPipeliningAllowed())-
670 return;-
671-
672-
673 if (channels[i].request.operation() != QHttpNetworkRequest::Get)-
674 return;-
675-
676-
677 if (socket->state() != QAbstractSocket::ConnectedState)-
678 return;-
679-
680-
681 if (channels[i].resendCurrent)-
682 return;-
683-
684-
685-
686 if (!channels[i].authenticator.isNull()-
687 && (!channels[i].authenticator.user().isEmpty()-
688 || !channels[i].authenticator.password().isEmpty()))-
689 return;-
690 if (!channels[i].proxyAuthenticator.isNull()-
691 && (!channels[i].proxyAuthenticator.user().isEmpty()-
692 || !channels[i].proxyAuthenticator.password().isEmpty()))-
693 return;-
694-
695-
696 if (! (channels[i].state == QHttpNetworkConnectionChannel::WaitingState-
697 || channels[i].state == QHttpNetworkConnectionChannel::ReadingState))-
698 return;-
699-
700 int lengthBefore;-
701 while (!highPriorityQueue.isEmpty()) {-
702 lengthBefore = channels[i].alreadyPipelinedRequests.length();-
703 fillPipeline(highPriorityQueue, channels[i]);-
704-
705 if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) {-
706 channels[i].pipelineFlush();-
707 return;-
708 }-
709-
710 if (lengthBefore == channels[i].alreadyPipelinedRequests.length())-
711 break;-
712 }-
713-
714 while (!lowPriorityQueue.isEmpty()) {-
715 lengthBefore = channels[i].alreadyPipelinedRequests.length();-
716 fillPipeline(lowPriorityQueue, channels[i]);-
717-
718 if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) {-
719 channels[i].pipelineFlush();-
720 return;-
721 }-
722-
723 if (lengthBefore == channels[i].alreadyPipelinedRequests.length())-
724 break;-
725 }-
726-
727-
728 channels[i].pipelineFlush();-
729}-
730-
731-
732bool QHttpNetworkConnectionPrivate::fillPipeline(QList<HttpMessagePair> &queue, QHttpNetworkConnectionChannel &channel)-
733{-
734 if (queue.isEmpty())-
735 return true;-
736-
737 for (int i = queue.count() - 1; i >= 0; --i) {-
738 HttpMessagePair messagePair = queue.at(i);-
739 const QHttpNetworkRequest &request = messagePair.first;-
740-
741-
742 if (!request.url().userInfo().isEmpty())-
743 continue;-
744-
745-
746 if (request.operation() != QHttpNetworkRequest::Get)-
747 continue;-
748-
749 if (!request.isPipeliningAllowed())-
750 continue;-
751-
752-
753 queue.takeAt(i);-
754-
755-
756-
757-
758 if (!messagePair.second->d_func()->requestIsPrepared)-
759 prepareRequest(messagePair);-
760 channel.pipelineInto(messagePair);-
761-
762-
763 return false;-
764 }-
765-
766-
767 return true;-
768}-
769-
770-
771QString QHttpNetworkConnectionPrivate::errorDetail(QNetworkReply::NetworkError errorCode, QAbstractSocket *socket, const QString &extraDetail)-
772{-
773 QString errorString;-
774 switch (errorCode) {-
775 case QNetworkReply::HostNotFoundError:-
776 if (socket)-
777 errorString = QCoreApplication::translate("QHttp", "Host %1 not found").arg(socket->peerName());-
778 else-
779 errorString = QCoreApplication::translate("QHttp", "Host %1 not found").arg(hostName);-
780 break;-
781 case QNetworkReply::ConnectionRefusedError:-
782 errorString = QCoreApplication::translate("QHttp", "Connection refused");-
783 break;-
784 case QNetworkReply::RemoteHostClosedError:-
785 errorString = QCoreApplication::translate("QHttp", "Connection closed");-
786 break;-
787 case QNetworkReply::TimeoutError:-
788 errorString = QCoreApplication::translate("QAbstractSocket", "Socket operation timed out");-
789 break;-
790 case QNetworkReply::ProxyAuthenticationRequiredError:-
791 errorString = QCoreApplication::translate("QHttp", "Proxy requires authentication");-
792 break;-
793 case QNetworkReply::AuthenticationRequiredError:-
794 errorString = QCoreApplication::translate("QHttp", "Host requires authentication");-
795 break;-
796 case QNetworkReply::ProtocolFailure:-
797 errorString = QCoreApplication::translate("QHttp", "Data corrupted");-
798 break;-
799 case QNetworkReply::ProtocolUnknownError:-
800 errorString = QCoreApplication::translate("QHttp", "Unknown protocol specified");-
801 break;-
802 case QNetworkReply::SslHandshakeFailedError:-
803 errorString = QCoreApplication::translate("QHttp", "SSL handshake failed");-
804 break;-
805 case QNetworkReply::TooManyRedirectsError:-
806 errorString = QCoreApplication::translate("QHttp", "Too many redirects");-
807 break;-
808 case QNetworkReply::InsecureRedirectError:-
809 errorString = QCoreApplication::translate("QHttp", "Insecure redirect");-
810 break;-
811 default:-
812-
813 errorString = extraDetail;-
814 break;-
815 }-
816 return errorString;-
817}-
818-
819-
820-
821void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply)-
822{-
823 QHttpNetworkConnection * const q = q_func();-
824-
825-
826 for (int i = 0; i < channelCount; ++i) {-
827-
828 if (channels[i].reply == reply) {-
829 channels[i].reply = 0;-
830 if (channels[i].protocolHandler)-
831 channels[i].protocolHandler->setReply(0);-
832 channels[i].request = QHttpNetworkRequest();-
833 channels[i].resendCurrent = false;-
834-
835 if (!reply->isFinished() && !channels[i].alreadyPipelinedRequests.isEmpty()) {-
836-
837-
838 channels[i].requeueCurrentlyPipelinedRequests();-
839 }-
840-
841-
842-
843-
844 if (reply->d_func()->isConnectionCloseEnabled() || !reply->isFinished()) {-
845 if (reply->isAborted()) {-
846 channels[i].abort();-
847 } else {-
848 channels[i].close();-
849 }-
850 }-
851-
852 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);-
853 return;-
854 }-
855-
856-
857 for (int j = 0; j < channels[i].alreadyPipelinedRequests.length(); j++) {-
858 if (channels[i].alreadyPipelinedRequests.at(j).second == reply) {-
859-
860 channels[i].alreadyPipelinedRequests.removeAt(j);-
861-
862 channels[i].requeueCurrentlyPipelinedRequests();-
863-
864-
865-
866-
867-
868 if (channels[i].reply)-
869 channels[i].reply->d_func()->forceConnectionCloseEnabled = true;-
870-
871 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);-
872 return;-
873 }-
874 }-
875-
876-
877 QMultiMap<int, HttpMessagePair>::iterator it = channels[i].spdyRequestsToSend.begin();-
878 QMultiMap<int, HttpMessagePair>::iterator end = channels[i].spdyRequestsToSend.end();-
879 for (; it != end; ++it) {-
880 if (it.value().second == reply) {-
881 channels[i].spdyRequestsToSend.remove(it.key());-
882-
883 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);-
884 return;-
885 }-
886 }-
887-
888 }-
889-
890 if (!highPriorityQueue.isEmpty()) {-
891 for (int j = highPriorityQueue.count() - 1; j >= 0; --j) {-
892 HttpMessagePair messagePair = highPriorityQueue.at(j);-
893 if (messagePair.second == reply) {-
894 highPriorityQueue.removeAt(j);-
895 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);-
896 return;-
897 }-
898 }-
899 }-
900-
901 if (!lowPriorityQueue.isEmpty()) {-
902 for (int j = lowPriorityQueue.count() - 1; j >= 0; --j) {-
903 HttpMessagePair messagePair = lowPriorityQueue.at(j);-
904 if (messagePair.second == reply) {-
905 lowPriorityQueue.removeAt(j);-
906 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);-
907 return;-
908 }-
909 }-
910 }-
911}-
912-
913-
914-
915-
916-
917-
918void QHttpNetworkConnectionPrivate::_q_startNextRequest()-
919{-
920-
921 if (networkLayerState == Unknown || networkLayerState == HostLookupPending || networkLayerState == IPv4or6)-
922 return;-
923-
924-
925 if (state == PausedState)-
926 return;-
927-
928-
929 for (int i = 0; i < channelCount; ++i) {-
930 if (channels[i].resendCurrent && (channels[i].state != QHttpNetworkConnectionChannel::ClosingState)) {-
931 channels[i].resendCurrent = false;-
932-
933-
934 if (!channels[i].resetUploadData())-
935 continue;-
936 channels[i].sendRequest();-
937 }-
938 }-
939-
940-
941-
942 switch (connectionType) {-
943 case QHttpNetworkConnection::ConnectionTypeHTTP: {-
944-
945 if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())-
946 return;-
947-
948-
949 for (int i = 0; i < channelCount; ++i) {-
950 if (channels[i].socket) {-
951 if (!channels[i].reply && !channels[i].isSocketBusy() && channels[i].socket->state() == QAbstractSocket::ConnectedState) {-
952 if (dequeueRequest(channels[i].socket))-
953 channels[i].sendRequest();-
954 }-
955 }-
956 }-
957 break;-
958 }-
959 case QHttpNetworkConnection::ConnectionTypeSPDY: {-
960-
961 if (channels[0].spdyRequestsToSend.isEmpty())-
962 return;-
963-
964 if (networkLayerState == IPv4)-
965 channels[0].networkLayerPreference = QAbstractSocket::IPv4Protocol;-
966 else if (networkLayerState == IPv6)-
967 channels[0].networkLayerPreference = QAbstractSocket::IPv6Protocol;-
968 channels[0].ensureConnection();-
969 if (channels[0].socket && channels[0].socket->state() == QAbstractSocket::ConnectedState-
970 && !channels[0].pendingEncrypt)-
971 channels[0].sendRequest();-
972-
973 break;-
974 }-
975 }-
976 if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())-
977 return;-
978 for (int i = 0; i < channelCount; i++)-
979 if (channels[i].socket && channels[i].socket->state() == QAbstractSocket::ConnectedState)-
980 fillPipeline(channels[i].socket);-
981-
982-
983-
984-
985 int queuedRequests = highPriorityQueue.count() + lowPriorityQueue.count();-
986-
987-
988-
989 int neededOpenChannels = queuedRequests;-
990 if (preConnectRequests > 0) {-
991 int normalRequests = queuedRequests - preConnectRequests;-
992 neededOpenChannels = qMax(normalRequests, preConnectRequests);-
993 }-
994 for (int i = 0; i < channelCount && neededOpenChannels > 0; ++i) {-
995 bool connectChannel = false;-
996 if (channels[i].socket) {-
997 if ((channels[i].socket->state() == QAbstractSocket::ConnectingState)-
998 || (channels[i].socket->state() == QAbstractSocket::HostLookupState)-
999 || channels[i].pendingEncrypt)-
1000 neededOpenChannels--;-
1001-
1002 if (neededOpenChannels <= 0)-
1003 break;-
1004 if (!channels[i].reply && !channels[i].isSocketBusy() && (channels[i].socket->state() == QAbstractSocket::UnconnectedState))-
1005 connectChannel = true;-
1006 } else {-
1007 connectChannel = true;-
1008 }-
1009-
1010 if (connectChannel) {-
1011 if (networkLayerState == IPv4)-
1012 channels[i].networkLayerPreference = QAbstractSocket::IPv4Protocol;-
1013 else if (networkLayerState == IPv6)-
1014 channels[i].networkLayerPreference = QAbstractSocket::IPv6Protocol;-
1015 channels[i].ensureConnection();-
1016 neededOpenChannels--;-
1017 }-
1018 }-
1019}-
1020-
1021-
1022void QHttpNetworkConnectionPrivate::readMoreLater(QHttpNetworkReply *reply)-
1023{-
1024 for (int i = 0 ; i < channelCount; ++i) {-
1025 if (channels[i].reply == reply) {-
1026-
1027 QMetaObject::invokeMethod(&channels[i], "_q_readyRead", Qt::QueuedConnection);-
1028 return;-
1029 }-
1030 }-
1031}-
1032-
1033-
1034-
1035-
1036-
1037-
1038-
1039void QHttpNetworkConnectionPrivate::startHostInfoLookup()-
1040{-
1041 networkLayerState = HostLookupPending;-
1042-
1043-
1044 QString lookupHost = hostName;-
1045-
1046 if (networkProxy.capabilities() & QNetworkProxy::HostNameLookupCapability
networkProxy.c...okupCapabilityDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 539 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
) {
44-539
1047 lookupHost = networkProxy.hostName();-
1048 }
executed 44 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
else if (channels[0].proxy.capabilities() & QNetworkProxy::HostNameLookupCapability
channels[0].pr...okupCapabilityDescription
TRUEevaluated 58 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 481 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
) {
44-481
1049 lookupHost = channels[0].proxy.hostName();-
1050 }
executed 58 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
58
1051-
1052 QHostAddress temp;-
1053 if (temp.setAddress(lookupHost)
temp.setAddress(lookupHost)Description
TRUEevaluated 108 times by 5 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 475 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
) {
108-475
1054 if (const QAbstractSocket::NetworkLayerProtocol protocol = temp.protocol()();-
1055 if (protocol
protocol == QA...::IPv4ProtocolDescription
TRUEevaluated 107 times by 5 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
protocol == QA...::IPv4ProtocolDescription
TRUEevaluated 107 times by 5 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
== QAbstractSocket::IPv4Protocol
protocol == QA...::IPv4ProtocolDescription
TRUEevaluated 107 times by 5 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
) {
1-107
1056 networkLayerState = QHttpNetworkConnectionPrivate::IPv4;-
1057 QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);-
1058 return;
executed 107 times by 5 tests: return;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
107
1059 } else if (temp.protocol ()== QAbstractSocket::IPv6Protocol
protocol == QA...::IPv6ProtocolDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-1
1060 networkLayerState = QHttpNetworkConnectionPrivate::IPv6;-
1061 QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);-
1062 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QNetworkReply
1
1063 }-
1064 }
never executed: end of block
else {
0
1065 int hostLookupId;-
1066 bool immediateResultValid = false;-
1067 QHostInfo hostInfo = qt_qhostinfo_lookup(lookupHost,-
1068 this->q_func(),-
1069 qFlagLocation("1""_q_hostLookupFinished(QHostInfo)" "\0" __FILE__ ":" "1131""1141"),-
1070 &immediateResultValid,-
1071 &hostLookupId);-
1072 if (immediateResultValid
immediateResultValidDescription
TRUEevaluated 460 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 15 times by 5 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
) {
15-460
1073 _q_hostLookupFinished(hostInfo);-
1074 }
executed 460 times by 6 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
460
1075 }
executed 475 times by 7 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
475
1076}-
1077-
1078-
1079void QHttpNetworkConnectionPrivate::_q_hostLookupFinished(const QHostInfo info&info)-
1080{-
1081 bool bIpv4 = false;-
1082 bool bIpv6 = false;-
1083 bool foundAddress = false;-
1084 if (networkLayerState == IPv4
networkLayerState == IPv4Description
TRUEnever evaluated
FALSEevaluated 475 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
|| networkLayerState == IPv6
networkLayerState == IPv6Description
TRUEnever evaluated
FALSEevaluated 475 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
|| networkLayerState == IPv4or6
networkLayerState == IPv4or6Description
TRUEnever evaluated
FALSEevaluated 475 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
)
0-475
1085 return;
never executed: return;
0
1086-
1087 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(info.const auto addresses ())>::type> _container_((= info.addresses())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)();-
1088 for (const QHostAddress &address = *_container_.i; _container_.control; _container_.control = 0: addresses) {-
1089 if (const QAbstractSocket::NetworkLayerProtocol protocol = address.protocol()();-
1090 if (protocol
protocol == QA...::IPv4ProtocolDescription
TRUEevaluated 475 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 130 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
protocol == QA...::IPv4ProtocolDescription
TRUEevaluated 475 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 130 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
== QAbstractSocket::IPv4Protocol
protocol == QA...::IPv4ProtocolDescription
TRUEevaluated 475 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 130 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
) {
130-475
1091 if (!foundAddress
!foundAddressDescription
TRUEevaluated 349 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 126 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
) {
126-349
1092 foundAddress = true;-
1093 delayIpv4 = false;-
1094 }
executed 349 times by 6 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
349
1095 bIpv4 = true;-
1096 }
executed 475 times by 7 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
else if (address.protocol ()== QAbstractSocket::IPv6Protocol
protocol == QA...::IPv6ProtocolDescription
TRUEevaluated 130 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-475
1097 if (!foundAddress
!foundAddressDescription
TRUEevaluated 122 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
) {
8-122
1098 foundAddress = true;-
1099 delayIpv4 = true;-
1100 }
executed 122 times by 2 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
122
1101 bIpv6 = true;-
1102 }
executed 130 times by 3 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
130
1103 }
executed 605 times by 7 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
605
1104-
1105 if (bIpv4
bIpv4Description
TRUEevaluated 471 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 4 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
&& bIpv6
bIpv6Description
TRUEevaluated 126 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
FALSEevaluated 345 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
)
4-471
1106 startNetworkLayerStateLookup();
executed 126 times by 3 tests: startNetworkLayerStateLookup();
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
126
1107 else if (bIpv4
bIpv4Description
TRUEevaluated 345 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 4 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
) {
4-345
1108 networkLayerState = QHttpNetworkConnectionPrivate::IPv4;-
1109 QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);-
1110 }
executed 345 times by 5 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
else if (bIpv6
bIpv6Description
TRUEnever evaluated
FALSEevaluated 4 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
) {
0-345
1111 networkLayerState = QHttpNetworkConnectionPrivate::IPv6;-
1112 QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);-
1113 }
never executed: end of block
else {
0
1114 if (dequeueRequest(channels[0].socket)
dequeueRequest...els[0].socket)Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_Spdy
) {
2
1115 emitReplyError(channels[0].socket, channels[0].reply, QNetworkReply::HostNotFoundError);-
1116 networkLayerState = QHttpNetworkConnectionPrivate::Unknown;-
1117 }
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
2
1118-
1119 else if (connectionType == QHttpNetworkConnection::ConnectionTypeSPDY
connectionType...ectionTypeSPDYDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEnever evaluated
) {
0-2
1120 QList<for (const HttpMessagePair > spdyPairs =&spdyPair : qAsConst(channels[0].spdyRequestsToSend.values();-
for (int a = 0; a < spdyPairs.count(); ++a))) {
1121-
1122 QHttpNetworkReply *currentReply = spdyPairsspdyPair.at(a).second;-
1123 ((!(currentReply)) ? qt_assert("currentReply",__FILE__,11841195) : qt_noop());-
1124 emitReplyError(channels[0].socket, currentReply, QNetworkReply::HostNotFoundError);-
1125 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_Spdy
2
1126 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_Spdy
2
1127-
1128 else {-
1129-
1130 QMessageLogger(__FILE__, 11911202, __PRETTY_FUNCTION__).warning() << ("QHttpNetworkConnectionPrivate::_q_hostLookupFinished could not dequeude-queue request";);-
1131 networkLayerState = QHttpNetworkConnectionPrivate::Unknown;-
1132 }
never executed: end of block
0
1133 }-
1134}-
1135-
1136-
1137-
1138-
1139-
1140-
1141void QHttpNetworkConnectionPrivate::startNetworkLayerStateLookup()-
1142{-
1143 if (channelCount > 1
channelCount > 1Description
TRUEevaluated 126 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-126
1144-
1145 ((!(!channels[0].isSocketBusy())) ? qt_assert("!channels[0].isSocketBusy()",__FILE__,12061217) : qt_noop());-
1146 ((!(!channels[1].isSocketBusy())) ? qt_assert("!channels[1].isSocketBusy()",__FILE__,12071218) : qt_noop());-
1147-
1148 networkLayerState = IPv4or6;-
1149-
1150 channels[0].networkLayerPreference = QAbstractSocket::IPv4Protocol;-
1151 channels[1].networkLayerPreference = QAbstractSocket::IPv6Protocol;-
1152-
1153 int timeout = 300;-
1154-
1155 if (networkSession
networkSessionDescription
TRUEevaluated 126 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-126
1156 if (const QNetworkConfiguration::BearerType bearerType = networkSession->configuration().bearerType()();-
1157 if (bearerType
bearerType == ...tion::Bearer2GDescription
TRUEnever evaluated
FALSEevaluated 126 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
bearerType == ...tion::Bearer2GDescription
TRUEnever evaluated
FALSEevaluated 126 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
== QNetworkConfiguration::Bearer2G
bearerType == ...tion::Bearer2GDescription
TRUEnever evaluated
FALSEevaluated 126 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
)
0-126
1158 timeout = 800;
never executed: timeout = 800;
0
1159 else if (networkSession->configuration().bearerType ()== QNetworkConfiguration::BearerCDMA2000
bearerType == ...BearerCDMA2000Description
TRUEnever evaluated
FALSEevaluated 126 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
)
0-126
1160 timeout = 500;
never executed: timeout = 500;
0
1161 else if (networkSession->configuration().bearerType ()== QNetworkConfiguration::BearerWCDMA
bearerType == ...n::BearerWCDMADescription
TRUEnever evaluated
FALSEevaluated 126 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
)
0-126
1162 timeout = 500;
never executed: timeout = 500;
0
1163 else if (networkSession->configuration().bearerType ()== QNetworkConfiguration::BearerHSPA
bearerType == ...on::BearerHSPADescription
TRUEnever evaluated
FALSEevaluated 126 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
)
0-126
1164 timeout = 400;
never executed: timeout = 400;
0
1165 }
executed 126 times by 3 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
126
1166-
1167 delayedConnectionTimer.start(timeout);-
1168 if (delayIpv4
delayIpv4Description
TRUEevaluated 122 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
)
4-122
1169 channels[1].ensureConnection();
executed 122 times by 2 tests: channels[1].ensureConnection();
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
122
1170 else-
1171 channels[0].ensureConnection();
executed 4 times by 2 tests: channels[0].ensureConnection();
Executed by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
4
1172 } else {-
1173 networkLayerState = IPv4or6;-
1174 channels[0].networkLayerPreference = QAbstractSocket::AnyIPProtocol;-
1175 channels[0].ensureConnection();-
1176 }
never executed: end of block
0
1177}-
1178-
1179void QHttpNetworkConnectionPrivate::networkLayerDetected(QAbstractSocket::NetworkLayerProtocol protocol)-
1180{-
1181 for (int i = 0 ; i < channelCount; ++i) {-
1182 if ((channels[i].networkLayerPreference != protocol) && (channels[i].state == QHttpNetworkConnectionChannel::ConnectingState)) {-
1183 channels[i].close();-
1184 }-
1185 }-
1186}-
1187-
1188void QHttpNetworkConnectionPrivate::_q_connectDelayedChannel()-
1189{-
1190 if (delayIpv4)-
1191 channels[0].ensureConnection();-
1192 else-
1193 channels[1].ensureConnection();-
1194}-
1195-
1196-
1197QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 port, bool encrypt,-
1198 QHttpNetworkConnection::ConnectionType connectionType,-
1199 QObject *parent, QSharedPointer<QNetworkSession> networkSession)-
1200 : QObject(*(new QHttpNetworkConnectionPrivate(hostName, port, encrypt, connectionType)), parent)-
1201{-
1202 QHttpNetworkConnectionPrivate * const d = d_func();-
1203 d->networkSession = std::move(networkSession);-
1204 d->init();-
1205}-
1206-
1207QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QString &hostName,-
1208 quint16 port, bool encrypt, QObject *parent,-
1209 QSharedPointer<QNetworkSession> networkSession,-
1210 QHttpNetworkConnection::ConnectionType connectionType)-
1211 : QObject(*(new QHttpNetworkConnectionPrivate(connectionCount, hostName, port, encrypt,-
1212 connectionType)), parent)-
1213{-
1214 QHttpNetworkConnectionPrivate * const d = d_func();-
1215 d->networkSession = std::move(networkSession);-
1216 d->init();-
1217}-
1218QHttpNetworkConnection::~QHttpNetworkConnection()-
1219{-
1220}-
1221-
1222QString QHttpNetworkConnection::hostName() const-
1223{-
1224 const QHttpNetworkConnectionPrivate * const d = d_func();-
1225 return d->hostName;-
1226}-
1227-
1228quint16 QHttpNetworkConnection::port() const-
1229{-
1230 const QHttpNetworkConnectionPrivate * const d = d_func();-
1231 return d->port;-
1232}-
1233-
1234QHttpNetworkReply* QHttpNetworkConnection::sendRequest(const QHttpNetworkRequest &request)-
1235{-
1236 QHttpNetworkConnectionPrivate * const d = d_func();-
1237 return d->queueRequest(request);-
1238}-
1239-
1240bool QHttpNetworkConnection::isSsl() const-
1241{-
1242 const QHttpNetworkConnectionPrivate * const d = d_func();-
1243 return d->encrypt;-
1244}-
1245-
1246QHttpNetworkConnectionChannel *QHttpNetworkConnection::channels() const-
1247{-
1248 return d_func()->channels;-
1249}-
1250-
1251-
1252void QHttpNetworkConnection::setCacheProxy(const QNetworkProxy &networkProxy)-
1253{-
1254 QHttpNetworkConnectionPrivate * const d = d_func();-
1255 d->networkProxy = networkProxy;-
1256-
1257 if (!d->networkProxy.user().isEmpty()) {-
1258 for (int i = 0; i < d->channelCount; ++i) {-
1259 d->channels[i].proxyAuthenticator.setUser(d->networkProxy.user());-
1260 d->channels[i].proxyAuthenticator.setPassword(d->networkProxy.password());-
1261 }-
1262 }-
1263}-
1264-
1265QNetworkProxy QHttpNetworkConnection::cacheProxy() const-
1266{-
1267 const QHttpNetworkConnectionPrivate * const d = d_func();-
1268 return d->networkProxy;-
1269}-
1270-
1271void QHttpNetworkConnection::setTransparentProxy(const QNetworkProxy &networkProxy)-
1272{-
1273 QHttpNetworkConnectionPrivate * const d = d_func();-
1274 for (int i = 0; i < d->channelCount; ++i)-
1275 d->channels[i].setProxy(networkProxy);-
1276}-
1277-
1278QNetworkProxy QHttpNetworkConnection::transparentProxy() const-
1279{-
1280 const QHttpNetworkConnectionPrivate * const d = d_func();-
1281 return d->channels[0].proxy;-
1282}-
1283-
1284-
1285QHttpNetworkConnection::ConnectionType QHttpNetworkConnection::connectionType()-
1286{-
1287 QHttpNetworkConnectionPrivate * const d = d_func();-
1288 return d->connectionType;-
1289}-
1290-
1291void QHttpNetworkConnection::setConnectionType(ConnectionType type)-
1292{-
1293 QHttpNetworkConnectionPrivate * const d = d_func();-
1294 d->connectionType = type;-
1295}-
1296-
1297-
1298-
1299void QHttpNetworkConnection::setSslConfiguration(const QSslConfiguration &config)-
1300{-
1301 QHttpNetworkConnectionPrivate * const d = d_func();-
1302 if (!d->encrypt)-
1303 return;-
1304-
1305-
1306 for (int i = 0; i < d->channelCount; ++i)-
1307 d->channels[i].setSslConfiguration(config);-
1308}-
1309-
1310QSharedPointer<QSslContext> QHttpNetworkConnection::sslContext()-
1311{-
1312 QHttpNetworkConnectionPrivate * const d = d_func();-
1313 return d->sslContext;-
1314}-
1315-
1316void QHttpNetworkConnection::setSslContext(QSharedPointer<QSslContext> context)-
1317{-
1318 QHttpNetworkConnectionPrivate * const d = d_func();-
1319 d->sslContext = std::move(context);-
1320}-
1321-
1322void QHttpNetworkConnection::ignoreSslErrors(int channel)-
1323{-
1324 QHttpNetworkConnectionPrivate * const d = d_func();-
1325 if (!d->encrypt)-
1326 return;-
1327-
1328 if (channel == -1) {-
1329 for (int i = 0; i < d->channelCount; ++i) {-
1330 d->channels[i].ignoreSslErrors();-
1331 }-
1332-
1333 } else {-
1334 d->channels[channel].ignoreSslErrors();-
1335 }-
1336}-
1337-
1338void QHttpNetworkConnection::ignoreSslErrors(const QList<QSslError> &errors, int channel)-
1339{-
1340 QHttpNetworkConnectionPrivate * const d = d_func();-
1341 if (!d->encrypt)-
1342 return;-
1343-
1344 if (channel == -1) {-
1345 for (int i = 0; i < d->channelCount; ++i) {-
1346 d->channels[i].ignoreSslErrors(errors);-
1347 }-
1348-
1349 } else {-
1350 d->channels[channel].ignoreSslErrors(errors);-
1351 }-
1352}-
1353-
1354-
1355-
1356void QHttpNetworkConnection::preConnectFinished()-
1357{-
1358 d_func()->preConnectRequests--;-
1359}-
1360-
1361-
1362-
1363-
1364-
1365void QHttpNetworkConnectionPrivate::emitProxyAuthenticationRequired(const QHttpNetworkConnectionChannel *chan, const QNetworkProxy &proxy, QAuthenticator* auth)-
1366{-
1367-
1368-
1369 pauseConnection();-
1370 QHttpNetworkReply *reply;-
1371-
1372 if (connectionType == QHttpNetworkConnection::ConnectionTypeSPDY) {-
1373-
1374-
1375-
1376 ((!(chan->spdyRequestsToSend.count() > 0)) ? qt_assert("chan->spdyRequestsToSend.count() > 0",__FILE__,14561468) : qt_noop());-
1377 reply = chan->spdyRequestsToSend.cbegin().value().second;-
1378 } else {-
1379-
1380 reply = chan->reply;-
1381-
1382 }-
1383-
1384-
1385 ((!(reply)) ? qt_assert("reply",__FILE__,14651477) : qt_noop());-
1386 reply->proxyAuthenticationRequired(proxy, auth);-
1387 resumeConnection();-
1388 int i = indexOf(chan->socket);-
1389 copyCredentials(i, auth, true);-
1390}-
1391-
1392-
1393-
1394-
1395-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9