Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/access/qhttpnetworkheader.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count |
---|---|---|
1 | - | |
2 | - | |
3 | - | |
4 | - | |
5 | - | |
6 | - | |
7 | - | |
8 | QHttpNetworkHeaderPrivate::QHttpNetworkHeaderPrivate(const QUrl &newUrl) | - |
9 | :url(newUrl) | - |
10 | { | - |
11 | } | - |
12 | - | |
13 | QHttpNetworkHeaderPrivate::QHttpNetworkHeaderPrivate(const QHttpNetworkHeaderPrivate &other) | - |
14 | :QSharedData(other) | - |
15 | { | - |
16 | url = other.url; | - |
17 | fields = other.fields; | - |
18 | } | - |
19 | - | |
20 | qint64 QHttpNetworkHeaderPrivate::contentLength() const | - |
21 | { | - |
22 | bool ok = false; | - |
23 | - | |
24 | - | |
25 | QByteArray value; | - |
26 | QList<QPair<QByteArray, QByteArray> >::ConstIterator it = fields.constBegin(), | - |
27 | end = fields.constEnd(); | - |
28 | for ( ; it != end; ++it) | - |
29 | if (qstricmp("content-length", it->first) == 0) { | - |
30 | value = it->second; | - |
31 | break; | - |
32 | } | - |
33 | - | |
34 | qint64 length = value.toULongLong(&ok); | - |
35 | if (ok) | - |
36 | return length; | - |
37 | return -1; | - |
38 | } | - |
39 | - | |
40 | void QHttpNetworkHeaderPrivate::setContentLength(qint64 length) | - |
41 | { | - |
42 | setHeaderField("Content-Length", QByteArray::number(length)); | - |
43 | } | - |
44 | - | |
45 | QByteArray QHttpNetworkHeaderPrivate::headerField(const QByteArray &name, const QByteArray &defaultValue) const | - |
46 | { | - |
47 | QList<QByteArray> allValues = headerFieldValues(name); | - |
48 | if (allValues.isEmpty()) | - |
49 | return defaultValue; | - |
50 | else | - |
51 | return allValues.join(", "); | - |
52 | } | - |
53 | - | |
54 | QList<QByteArray> QHttpNetworkHeaderPrivate::headerFieldValues(const QByteArray &name) const | - |
55 | { | - |
56 | QList<QByteArray> result; | - |
57 | QList<QPair<QByteArray, QByteArray> >::ConstIterator it = fields.constBegin(), | - |
58 | end = fields.constEnd(); | - |
59 | for ( ; it != end; ++it) | - |
60 | if (qstricmp(name.constData(), it->first) == 0) | - |
61 | result += it->second; | - |
62 | - | |
63 | return result; | - |
64 | } | - |
65 | - | |
66 | void QHttpNetworkHeaderPrivate::setHeaderField(const QByteArray &name, const QByteArray &data) | - |
67 | { | - |
68 | QList<auto firstEqualsName = [&name](const QPair<QByteArray, QByteArray> >::Iterator it = fields.begin(); | - |
while (it != fields.end())&header) { | ||
69 | if (return executed 20896 times by 8 tests: return qstricmp(name.constData(), header.first) == 0; Executed by:
executed 20896 times by 8 tests: qstricmp(name.constData(), it->header.first) == 0)return qstricmp(name.constData(), header.first) == 0; Executed by:
executed 20896 times by 8 tests: return qstricmp(name.constData(), header.first) == 0; Executed by:
| 20896 |
it = executed 20896 times by 8 tests: return qstricmp(name.constData(), header.first) == 0; Executed by:
executed 20896 times by 8 tests: ;return qstricmp(name.constData(), header.first) == 0; Executed by:
executed 20896 times by 8 tests: return qstricmp(name.constData(), header.first) == 0; Executed by:
| ||
70 | }; | - |
71 | fields.erase(it); | - |
else | ||
++it; | ||
}std::remove_if(fields.begin(), fields.end(), | ||
72 | firstEqualsName), | - |
73 | fields.end()); | - |
74 | fields.append(qMakePair(name, data)); | - |
75 | } executed 9410 times by 8 tests: end of block Executed by:
| 9410 |
76 | - | |
77 | bool QHttpNetworkHeaderPrivate::operator==(const QHttpNetworkHeaderPrivate &other) const | - |
78 | { | - |
79 | return (url == other.url); | - |
80 | } | - |
81 | - | |
82 | - | |
83 | - | |
Switch to Source code | Preprocessed file |