Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op, | - |
7 | QHttpNetworkRequest::Priority pri, const QUrl &newUrl) | - |
8 | : QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), uploadByteDevice(0), | - |
9 | autoDecompress(false), pipeliningAllowed(false), withCredentials(true) | - |
10 | { | - |
11 | } executed: } Execution Count:5837 | 5837 |
12 | | - |
13 | QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(const QHttpNetworkRequestPrivate &other) | - |
14 | : QHttpNetworkHeaderPrivate(other) | - |
15 | { | - |
16 | operation = other.operation; | - |
17 | priority = other.priority; | - |
18 | uploadByteDevice = other.uploadByteDevice; | - |
19 | autoDecompress = other.autoDecompress; | - |
20 | pipeliningAllowed = other.pipeliningAllowed; | - |
21 | customVerb = other.customVerb; | - |
22 | withCredentials = other.withCredentials; | - |
23 | ssl = other.ssl; | - |
24 | } executed: } Execution Count:867 | 867 |
25 | | - |
26 | QHttpNetworkRequestPrivate::~QHttpNetworkRequestPrivate() | - |
27 | { | - |
28 | } | - |
29 | | - |
30 | bool QHttpNetworkRequestPrivate::operator==(const QHttpNetworkRequestPrivate &other) const | - |
31 | { | - |
32 | return QHttpNetworkHeaderPrivate::operator==(other) | 0 |
33 | && (operation == other.operation) | 0 |
34 | && (ssl == other.ssl) | 0 |
35 | && (uploadByteDevice == other.uploadByteDevice); never executed: return QHttpNetworkHeaderPrivate::operator==(other) && (operation == other.operation) && (ssl == other.ssl) && (uploadByteDevice == other.uploadByteDevice); | 0 |
36 | } | - |
37 | | - |
38 | QByteArray QHttpNetworkRequestPrivate::methodName() const | - |
39 | { | - |
40 | switch (operation) { | - |
41 | case QHttpNetworkRequest::Get: | - |
42 | return "GET"; executed: return "GET"; Execution Count:707 | 707 |
43 | case QHttpNetworkRequest::Head: | - |
44 | return "HEAD"; executed: return "HEAD"; Execution Count:47 | 47 |
45 | case QHttpNetworkRequest::Post: | - |
46 | return "POST"; executed: return "POST"; Execution Count:238 | 238 |
47 | case QHttpNetworkRequest::Options: | - |
48 | return "OPTIONS"; never executed: return "OPTIONS"; | 0 |
49 | case QHttpNetworkRequest::Put: | - |
50 | return "PUT"; executed: return "PUT"; Execution Count:36 | 36 |
51 | case QHttpNetworkRequest::Delete: | - |
52 | return "DELETE"; executed: return "DELETE"; Execution Count:7 | 7 |
53 | case QHttpNetworkRequest::Trace: | - |
54 | return "TRACE"; never executed: return "TRACE"; | 0 |
55 | case QHttpNetworkRequest::Connect: | - |
56 | return "CONNECT"; never executed: return "CONNECT"; | 0 |
57 | case QHttpNetworkRequest::Custom: | - |
58 | return customVerb; executed: return customVerb; Execution Count:6 | 6 |
59 | default: | - |
60 | break; | 0 |
61 | } | - |
62 | return QByteArray(); never executed: return QByteArray(); | 0 |
63 | } | - |
64 | | - |
65 | QByteArray QHttpNetworkRequestPrivate::uri(bool throughProxy) const | - |
66 | { | - |
67 | QUrl::FormattingOptions format(QUrl::RemoveFragment | QUrl::RemoveUserInfo | QUrl::FullyEncoded); | - |
68 | | - |
69 | | - |
70 | if (operation == QHttpNetworkRequest::Post && !uploadByteDevice) evaluated: operation == QHttpNetworkRequest::Post yes Evaluation Count:238 | yes Evaluation Count:803 |
partially evaluated: !uploadByteDevice no Evaluation Count:0 | yes Evaluation Count:238 |
| 0-803 |
71 | format |= QUrl::RemoveQuery; never executed: format |= QUrl::RemoveQuery; | 0 |
72 | | - |
73 | if (!throughProxy) evaluated: !throughProxy yes Evaluation Count:937 | yes Evaluation Count:104 |
| 104-937 |
74 | format |= QUrl::RemoveScheme | QUrl::RemoveAuthority; executed: format |= QUrl::RemoveScheme | QUrl::RemoveAuthority; Execution Count:937 | 937 |
75 | QUrl copy = url; | - |
76 | if (copy.path().isEmpty()) evaluated: copy.path().isEmpty() yes Evaluation Count:179 | yes Evaluation Count:862 |
| 179-862 |
77 | copy.setPath(QString::fromUtf8("" "/" "", sizeof("/") - 1)); executed: copy.setPath(QString::fromUtf8("" "/" "", sizeof("/") - 1)); Execution Count:179 | 179 |
78 | QByteArray uri = copy.toEncoded(format); | - |
79 | return uri; executed: return uri; Execution Count:1041 | 1041 |
80 | } | - |
81 | | - |
82 | QByteArray QHttpNetworkRequestPrivate::header(const QHttpNetworkRequest &request, bool throughProxy) | - |
83 | { | - |
84 | QList<QPair<QByteArray, QByteArray> > fields = request.header(); | - |
85 | QByteArray ba; | - |
86 | ba.reserve(40 + fields.length()*25); | - |
87 | | - |
88 | ba += request.d->methodName(); | - |
89 | ba += ' '; | - |
90 | ba += request.d->uri(throughProxy); | - |
91 | | - |
92 | ba += " HTTP/"; | - |
93 | ba += QByteArray::number(request.majorVersion()); | - |
94 | ba += '.'; | - |
95 | ba += QByteArray::number(request.minorVersion()); | - |
96 | ba += "\r\n"; | - |
97 | | - |
98 | QList<QPair<QByteArray, QByteArray> >::const_iterator it = fields.constBegin(); | - |
99 | QList<QPair<QByteArray, QByteArray> >::const_iterator endIt = fields.constEnd(); | - |
100 | for (; it != endIt; ++it) { evaluated: it != endIt yes Evaluation Count:4974 | yes Evaluation Count:859 |
| 859-4974 |
101 | ba += it->first; | - |
102 | ba += ": "; | - |
103 | ba += it->second; | - |
104 | ba += "\r\n"; | - |
105 | } executed: } Execution Count:4974 | 4974 |
106 | if (request.d->operation == QHttpNetworkRequest::Post) { evaluated: request.d->operation == QHttpNetworkRequest::Post yes Evaluation Count:187 | yes Evaluation Count:672 |
| 187-672 |
107 | | - |
108 | if (request.headerField("content-type").isEmpty()) { partially evaluated: request.headerField("content-type").isEmpty() no Evaluation Count:0 | yes Evaluation Count:187 |
| 0-187 |
109 | | - |
110 | | - |
111 | | - |
112 | QMessageLogger("access/qhttpnetworkrequest.cpp", 155, __PRETTY_FUNCTION__).warning("content-type missing in HTTP POST, defaulting to application/x-www-form-urlencoded. Use QNetworkRequest::setHeader() to fix this problem."); | - |
113 | ba += "Content-Type: application/x-www-form-urlencoded\r\n"; | - |
114 | } | 0 |
115 | if (!request.d->uploadByteDevice && request.d->url.hasQuery()) { partially evaluated: !request.d->uploadByteDevice no Evaluation Count:0 | yes Evaluation Count:187 |
never evaluated: request.d->url.hasQuery() | 0-187 |
116 | QByteArray query = request.d->url.query(QUrl::FullyEncoded).toLatin1(); | - |
117 | ba += "Content-Length: "; | - |
118 | ba += QByteArray::number(query.size()); | - |
119 | ba += "\r\n\r\n"; | - |
120 | ba += query; | - |
121 | } else { | 0 |
122 | ba += "\r\n"; | - |
123 | } executed: } Execution Count:187 | 187 |
124 | } else { | - |
125 | ba += "\r\n"; | - |
126 | } executed: } Execution Count:672 | 672 |
127 | return ba; executed: return ba; Execution Count:859 | 859 |
128 | } | - |
129 | | - |
130 | | - |
131 | | - |
132 | | - |
133 | QHttpNetworkRequest::QHttpNetworkRequest(const QUrl &url, Operation operation, Priority priority) | - |
134 | : d(new QHttpNetworkRequestPrivate(operation, priority, url)) | - |
135 | { | - |
136 | } executed: } Execution Count:5837 | 5837 |
137 | | - |
138 | QHttpNetworkRequest::QHttpNetworkRequest(const QHttpNetworkRequest &other) | - |
139 | : QHttpNetworkHeader(other), d(other.d) | - |
140 | { | - |
141 | } executed: } Execution Count:3739 | 3739 |
142 | | - |
143 | QHttpNetworkRequest::~QHttpNetworkRequest() | - |
144 | { | - |
145 | } | - |
146 | | - |
147 | QUrl QHttpNetworkRequest::url() const | - |
148 | { | - |
149 | return d->url; executed: return d->url; Execution Count:3179 | 3179 |
150 | } | - |
151 | void QHttpNetworkRequest::setUrl(const QUrl &url) | - |
152 | { | - |
153 | d->url = url; | - |
154 | } executed: } Execution Count:738 | 738 |
155 | | - |
156 | bool QHttpNetworkRequest::isSsl() const | - |
157 | { | - |
158 | return d->ssl; executed: return d->ssl; Execution Count:694 | 694 |
159 | } | - |
160 | void QHttpNetworkRequest::setSsl(bool s) | - |
161 | { | - |
162 | d->ssl = s; | - |
163 | } executed: } Execution Count:712 | 712 |
164 | | - |
165 | qint64 QHttpNetworkRequest::contentLength() const | - |
166 | { | - |
167 | return d->contentLength(); executed: return d->contentLength(); Execution Count:584 | 584 |
168 | } | - |
169 | | - |
170 | void QHttpNetworkRequest::setContentLength(qint64 length) | - |
171 | { | - |
172 | d->setContentLength(length); | - |
173 | } executed: } Execution Count:178 | 178 |
174 | | - |
175 | QList<QPair<QByteArray, QByteArray> > QHttpNetworkRequest::header() const | - |
176 | { | - |
177 | return d->fields; executed: return d->fields; Execution Count:859 | 859 |
178 | } | - |
179 | | - |
180 | QByteArray QHttpNetworkRequest::headerField(const QByteArray &name, const QByteArray &defaultValue) const | - |
181 | { | - |
182 | return d->headerField(name, defaultValue); executed: return d->headerField(name, defaultValue); Execution Count:3648 | 3648 |
183 | } | - |
184 | | - |
185 | void QHttpNetworkRequest::setHeaderField(const QByteArray &name, const QByteArray &data) | - |
186 | { | - |
187 | d->setHeaderField(name, data); | - |
188 | } executed: } Execution Count:3966 | 3966 |
189 | | - |
190 | QHttpNetworkRequest &QHttpNetworkRequest::operator=(const QHttpNetworkRequest &other) | - |
191 | { | - |
192 | d = other.d; | - |
193 | return *this; executed: return *this; Execution Count:2743 | 2743 |
194 | } | - |
195 | | - |
196 | bool QHttpNetworkRequest::operator==(const QHttpNetworkRequest &other) const | - |
197 | { | - |
198 | return d->operator==(*other.d); never executed: return d->operator==(*other.d); | 0 |
199 | } | - |
200 | | - |
201 | QHttpNetworkRequest::Operation QHttpNetworkRequest::operation() const | - |
202 | { | - |
203 | return d->operation; executed: return d->operation; Execution Count:872 | 872 |
204 | } | - |
205 | | - |
206 | void QHttpNetworkRequest::setOperation(Operation operation) | - |
207 | { | - |
208 | d->operation = operation; | - |
209 | } executed: } Execution Count:709 | 709 |
210 | | - |
211 | QByteArray QHttpNetworkRequest::customVerb() const | - |
212 | { | - |
213 | return d->customVerb; never executed: return d->customVerb; | 0 |
214 | } | - |
215 | | - |
216 | void QHttpNetworkRequest::setCustomVerb(const QByteArray &customVerb) | - |
217 | { | - |
218 | d->customVerb = customVerb; | - |
219 | } executed: } Execution Count:6 | 6 |
220 | | - |
221 | QHttpNetworkRequest::Priority QHttpNetworkRequest::priority() const | - |
222 | { | - |
223 | return d->priority; executed: return d->priority; Execution Count:694 | 694 |
224 | } | - |
225 | | - |
226 | void QHttpNetworkRequest::setPriority(Priority priority) | - |
227 | { | - |
228 | d->priority = priority; | - |
229 | } executed: } Execution Count:709 | 709 |
230 | | - |
231 | bool QHttpNetworkRequest::isPipeliningAllowed() const | - |
232 | { | - |
233 | return d->pipeliningAllowed; executed: return d->pipeliningAllowed; Execution Count:805 | 805 |
234 | } | - |
235 | | - |
236 | void QHttpNetworkRequest::setPipeliningAllowed(bool b) | - |
237 | { | - |
238 | d->pipeliningAllowed = b; | - |
239 | } executed: } Execution Count:20 | 20 |
240 | | - |
241 | bool QHttpNetworkRequest::withCredentials() const | - |
242 | { | - |
243 | return d->withCredentials; executed: return d->withCredentials; Execution Count:1289 | 1289 |
244 | } | - |
245 | | - |
246 | void QHttpNetworkRequest::setWithCredentials(bool b) | - |
247 | { | - |
248 | d->withCredentials = b; | - |
249 | } executed: } Execution Count:1 | 1 |
250 | | - |
251 | void QHttpNetworkRequest::setUploadByteDevice(QNonContiguousByteDevice *bd) | - |
252 | { | - |
253 | d->uploadByteDevice = bd; | - |
254 | } executed: } Execution Count:179 | 179 |
255 | | - |
256 | QNonContiguousByteDevice* QHttpNetworkRequest::uploadByteDevice() const | - |
257 | { | - |
258 | return d->uploadByteDevice; executed: return d->uploadByteDevice; Execution Count:7902 | 7902 |
259 | } | - |
260 | | - |
261 | int QHttpNetworkRequest::majorVersion() const | - |
262 | { | - |
263 | return 1; executed: return 1; Execution Count:859 | 859 |
264 | } | - |
265 | | - |
266 | int QHttpNetworkRequest::minorVersion() const | - |
267 | { | - |
268 | return 1; executed: return 1; Execution Count:859 | 859 |
269 | } | - |
270 | | - |
271 | | - |
272 | | - |
273 | | - |
| | |