Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qhttpnetworkheader.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
8
9QHttpNetworkHeader::~QHttpNetworkHeader()
10 = default;
11
12QHttpNetworkHeaderPrivate::QHttpNetworkHeaderPrivate(const QUrl &newUrl)
13 :url(newUrl)
14{
15}
16
17qint64 QHttpNetworkHeaderPrivate::contentLength() const
18{
19 bool ok = false;
20 // We are not using the headerField() method here because servers might send us multiple content-length
21 // headers which is crap (see QTBUG-15311). Therefore just take the first content-length header field.
22 QByteArray value = parser.firstHeaderField("content-length");
23 qint64 length = value.toULongLong(&ok);
24 if (ok)
25 return length;
26 return -1; // the header field is not set
27}
28
29void QHttpNetworkHeaderPrivate::setContentLength(qint64 length)
30{
31 setHeaderField("Content-Length", QByteArray::number(length));
32}
33
34QByteArray QHttpNetworkHeaderPrivate::headerField(QByteArrayView name, const QByteArray &defaultValue) const
35{
36 QList<QByteArray> allValues = headerFieldValues(name);
37 if (allValues.isEmpty())
38 return defaultValue;
39 else
40 return allValues.join(", ");
41}
42
43QList<QByteArray> QHttpNetworkHeaderPrivate::headerFieldValues(QByteArrayView name) const
44{
45 return parser.headerFieldValues(name);
46}
47
48void QHttpNetworkHeaderPrivate::setHeaderField(const QByteArray &name, const QByteArray &data)
49{
50 parser.setHeaderField(name, data);
51}
52
53void QHttpNetworkHeaderPrivate::prependHeaderField(const QByteArray &name, const QByteArray &data)
54{
55 parser.prependHeaderField(name, data);
56}
57
58QHttpHeaders QHttpNetworkHeaderPrivate::headers() const
59{
60 return parser.headers();
61}
62
63void QHttpNetworkHeaderPrivate::clearHeaders()
64{
65 parser.clearHeaders();
66}
67
68bool QHttpNetworkHeaderPrivate::operator==(const QHttpNetworkHeaderPrivate &other) const
69{
70 return (url == other.url);
71}
72
73
74QT_END_NAMESPACE
Combined button and popup list for selecting options.