qnetworkaccessdebugpipebackend.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkaccessdebugpipebackend.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6enum {-
7 ReadBufferSize = 16384,-
8 WriteBufferSize = ReadBufferSize-
9};-
10-
11QStringList QNetworkAccessDebugPipeBackendFactory::supportedSchemes() const-
12{-
13 return
never executed: return QStringList(([]() -> QString { enum { Size = sizeof(u"" "debugpipe")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "debugpipe" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));
QStringList(([]() -> QString { enum { Size = sizeof(u"" "debugpipe")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "debugpipe" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}()));
never executed: return QStringList(([]() -> QString { enum { Size = sizeof(u"" "debugpipe")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "debugpipe" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));
0
14}-
15-
16QNetworkAccessBackend *-
17QNetworkAccessDebugPipeBackendFactory::create(QNetworkAccessManager::Operation op,-
18 const QNetworkRequest &request) const-
19{-
20-
21 switch (op) {-
22 case
executed 8 times by 1 test: case QNetworkAccessManager::GetOperation:
Executed by:
  • tst_QNetworkReply
QNetworkAccessManager::GetOperation:
executed 8 times by 1 test: case QNetworkAccessManager::GetOperation:
Executed by:
  • tst_QNetworkReply
8
23 case
executed 46 times by 1 test: case QNetworkAccessManager::PutOperation:
Executed by:
  • tst_QNetworkReply
QNetworkAccessManager::PutOperation:
executed 46 times by 1 test: case QNetworkAccessManager::PutOperation:
Executed by:
  • tst_QNetworkReply
46
24 break;
executed 54 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
54
25-
26 default
never executed: default:
:
never executed: default:
0
27-
28 return
never executed: return 0;
0;
never executed: return 0;
0
29 }-
30-
31 QUrl url = request.url();-
32 if (url.scheme() == QLatin1String("debugpipe")
url.scheme() =...g("debugpipe")Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 47 times by 1 test
Evaluated by:
  • tst_QNetworkReply
)
7-47
33 return
executed 7 times by 1 test: return new QNetworkAccessDebugPipeBackend;
Executed by:
  • tst_QNetworkReply
new QNetworkAccessDebugPipeBackend;
executed 7 times by 1 test: return new QNetworkAccessDebugPipeBackend;
Executed by:
  • tst_QNetworkReply
7
34 return
executed 47 times by 1 test: return 0;
Executed by:
  • tst_QNetworkReply
0;
executed 47 times by 1 test: return 0;
Executed by:
  • tst_QNetworkReply
47
35}-
36-
37QNetworkAccessDebugPipeBackend::QNetworkAccessDebugPipeBackend()-
38 : bareProtocol(false), hasUploadFinished(false), hasDownloadFinished(false),-
39 hasEverythingFinished(false), bytesDownloaded(0), bytesUploaded(0)-
40{-
41}
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
42-
43QNetworkAccessDebugPipeBackend::~QNetworkAccessDebugPipeBackend()-
44{-
45-
46 socket.disconnect(this);-
47}
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
48-
49void QNetworkAccessDebugPipeBackend::open()-
50{-
51 socket.connectToHost(url().host(), url().port(12345));-
52 socket.setReadBufferSize(ReadBufferSize);-
53-
54-
55 connect(&socket, qFlagLocation("2""readyRead()" "\0" __FILE__ ":" "100"), qFlagLocation("1""socketReadyRead()" "\0" __FILE__ ":" "100"));-
56 connect(&socket, qFlagLocation("2""error(QAbstractSocket::SocketError)" "\0" __FILE__ ":" "101"), qFlagLocation("1""socketError()" "\0" __FILE__ ":" "101"));-
57 connect(&socket, qFlagLocation("2""disconnected()" "\0" __FILE__ ":" "102"), qFlagLocation("1""socketDisconnected()" "\0" __FILE__ ":" "102"));-
58 connect(&socket, qFlagLocation("2""connected()" "\0" __FILE__ ":" "103"), qFlagLocation("1""socketConnected()" "\0" __FILE__ ":" "103"));-
59-
60 connect(&socket, qFlagLocation("2""bytesWritten(qint64)" "\0" __FILE__ ":" "105"), qFlagLocation("1""socketBytesWritten(qint64)" "\0" __FILE__ ":" "105"));-
61-
62 bareProtocol = QUrlQuery(url()).queryItemValue(QLatin1String("bare")) == QLatin1String("1");-
63-
64 if (operation() == QNetworkAccessManager::PutOperation
operation() ==...::PutOperationDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-7
65 uploadByteDevice = createUploadByteDevice();-
66 QObject::connect(uploadByteDevice, qFlagLocation("2""readyRead()" "\0" __FILE__ ":" "111"), this, qFlagLocation("1""uploadReadyReadSlot()" "\0" __FILE__ ":" "111"));-
67 QMetaObject::invokeMethod(this, "uploadReadyReadSlot", Qt::QueuedConnection);-
68 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
69}
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
70-
71void QNetworkAccessDebugPipeBackend::socketReadyRead()-
72{-
73 pushFromSocketToDownstream();-
74}
never executed: end of block
0
75-
76void QNetworkAccessDebugPipeBackend::downstreamReadyWrite()-
77{-
78 pushFromSocketToDownstream();-
79}
never executed: end of block
0
80-
81void QNetworkAccessDebugPipeBackend::socketBytesWritten(qint64)-
82{-
83 pushFromUpstreamToSocket();-
84}
executed 136 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
136
85-
86void QNetworkAccessDebugPipeBackend::uploadReadyReadSlot()-
87{-
88 pushFromUpstreamToSocket();-
89}
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
90-
91void QNetworkAccessDebugPipeBackend::pushFromSocketToDownstream()-
92{-
93 QByteArray buffer;-
94-
95 if (socket.state() == QAbstractSocket::ConnectingState
socket.state()...onnectingStateDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
) {
0-1
96 return;
never executed: return;
0
97 }-
98-
99 for(;;) {-
100 if (hasDownloadFinished
hasDownloadFinishedDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
)
0-1
101 return;
never executed: return;
0
102-
103 buffer.resize(ReadBufferSize);-
104 qint64 haveRead = socket.read(buffer.data(), ReadBufferSize);-
105-
106 if (haveRead == -1
haveRead == -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-1
107 hasDownloadFinished = true;-
108-
109 setHeader(QNetworkRequest::ContentLengthHeader, QVariant());-
110 possiblyFinish();-
111 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QNetworkReply
1
112 } else if (haveRead == 0
haveRead == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
113 break;
never executed: break;
0
114 } else {-
115-
116 buffer.resize(haveRead);-
117 bytesDownloaded += haveRead;-
118-
119 QByteDataBuffer list;-
120 list.append(buffer);-
121 buffer.clear();-
122 writeDownstreamData(list);-
123 }
never executed: end of block
0
124 }-
125}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
126-
127void QNetworkAccessDebugPipeBackend::pushFromUpstreamToSocket()-
128{-
129-
130 if (operation() == QNetworkAccessManager::PutOperation
operation() ==...::PutOperationDescription
TRUEevaluated 143 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-143
131 if (hasUploadFinished
hasUploadFinishedDescription
TRUEnever evaluated
FALSEevaluated 143 times by 1 test
Evaluated by:
  • tst_QNetworkReply
)
0-143
132 return;
never executed: return;
0
133-
134 for(;;) {-
135 if (socket.bytesToWrite() >= WriteBufferSize
socket.bytesTo...riteBufferSizeDescription
TRUEevaluated 136 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 149 times by 1 test
Evaluated by:
  • tst_QNetworkReply
)
136-149
136 return;
executed 136 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
136
137-
138 qint64 haveRead;-
139 const char *readPointer = uploadByteDevice->readPointer(WriteBufferSize, haveRead);-
140 if (haveRead == -1
haveRead == -1Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 142 times by 1 test
Evaluated by:
  • tst_QNetworkReply
) {
7-142
141-
142 hasUploadFinished = true;-
143 emitReplyUploadProgress(bytesUploaded, bytesUploaded);-
144 possiblyFinish();-
145 break;
executed 7 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
7
146 } else if (haveRead == 0
haveRead == 0Description
TRUEnever evaluated
FALSEevaluated 142 times by 1 test
Evaluated by:
  • tst_QNetworkReply
|| readPointer == 0
readPointer == 0Description
TRUEnever evaluated
FALSEevaluated 142 times by 1 test
Evaluated by:
  • tst_QNetworkReply
) {
0-142
147-
148 break;
never executed: break;
0
149 } else {-
150 qint64 haveWritten;-
151 haveWritten = socket.write(readPointer, haveRead);-
152-
153 if (haveWritten < 0
haveWritten < 0Description
TRUEnever evaluated
FALSEevaluated 142 times by 1 test
Evaluated by:
  • tst_QNetworkReply
) {
0-142
154-
155 QString msg = QCoreApplication::translate("QNetworkAccessDebugPipeBackend", "Write error writing to %1: %2")-
156 .arg(url().toString(), socket.errorString());-
157 error(QNetworkReply::ProtocolFailure, msg);-
158 finished();-
159 return;
never executed: return;
0
160 } else {-
161 uploadByteDevice->advanceReadPointer(haveWritten);-
162 bytesUploaded += haveWritten;-
163 emitReplyUploadProgress(bytesUploaded, -1);-
164 }
executed 142 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
142
165-
166-
167-
168 }-
169 }-
170 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
171}
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
172-
173void QNetworkAccessDebugPipeBackend::possiblyFinish()-
174{-
175 if (hasEverythingFinished
hasEverythingFinishedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
)
1-7
176 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QNetworkReply
1
177 hasEverythingFinished = true;-
178-
179 if ((
(operation() =...:GetOperation)Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
operation() == QNetworkAccessManager::GetOperation)
(operation() =...:GetOperation)Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
&& hasDownloadFinished
hasDownloadFinishedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0-7
180 socket.close();-
181 finished();-
182 }
never executed: end of block
else if ((
(operation() =...:PutOperation)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
operation() == QNetworkAccessManager::PutOperation)
(operation() =...:PutOperation)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
&& hasUploadFinished
hasUploadFinishedDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-7
183 socket.close();-
184 finished();-
185 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
186-
187-
188}
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
189-
190void QNetworkAccessDebugPipeBackend::closeDownstreamChannel()-
191{-
192 QMessageLogger(__FILE__, 237, __PRETTY_FUNCTION__).warning("QNetworkAccessDebugPipeBackend::closeDownstreamChannel() %d",operation());;-
193-
194-
195}
never executed: end of block
0
196-
197-
198void QNetworkAccessDebugPipeBackend::socketError()-
199{-
200 QMessageLogger(__FILE__, 245, __PRETTY_FUNCTION__).warning("QNetworkAccessDebugPipeBackend::socketError() %d",socket.error());-
201 QNetworkReply::NetworkError code;-
202 switch (socket.error()) {-
203 case
never executed: case QAbstractSocket::RemoteHostClosedError:
QAbstractSocket::RemoteHostClosedError:
never executed: case QAbstractSocket::RemoteHostClosedError:
0
204 return;
never executed: return;
0
205-
206 case
never executed: case QAbstractSocket::NetworkError:
QAbstractSocket::NetworkError:
never executed: case QAbstractSocket::NetworkError:
0
207 code = QNetworkReply::UnknownNetworkError;-
208 break;
never executed: break;
0
209-
210 default
never executed: default:
:
never executed: default:
0
211 code = QNetworkReply::ProtocolFailure;-
212 break;
never executed: break;
0
213 }-
214-
215 error(code, QNetworkAccessDebugPipeBackend::tr("Socket error on %1: %2")-
216 .arg(url().toString(), socket.errorString()));-
217 finished();-
218 disconnect(&socket, qFlagLocation("2""disconnected()" "\0" __FILE__ ":" "263"), this, qFlagLocation("1""socketDisconnected()" "\0" __FILE__ ":" "263"));-
219-
220}
never executed: end of block
0
221-
222void QNetworkAccessDebugPipeBackend::socketDisconnected()-
223{-
224 pushFromSocketToDownstream();-
225-
226 if (socket.bytesToWrite() == 0
socket.bytesToWrite() == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
) {
0-1
227-
228 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
else {
1
229-
230 QString msg = QNetworkAccessDebugPipeBackend::tr("Remote host closed the connection prematurely on %1")-
231 .arg(url().toString());-
232 error(QNetworkReply::RemoteHostClosedError, msg);-
233 finished();-
234 }
never executed: end of block
0
235}-
236-
237void QNetworkAccessDebugPipeBackend::socketConnected()-
238{-
239}-
240-
241-
242-
243-
244-
Switch to Source codePreprocessed file

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