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
5
#
include
"qhttpnetworkheader_p.h"
6
7
QT_BEGIN_NAMESPACE
8
9
QHttpNetworkHeader::~QHttpNetworkHeader()
10
=
default
;
11
12
QHttpNetworkHeaderPrivate::QHttpNetworkHeaderPrivate(
const
QUrl &newUrl)
13
:url(newUrl)
14
{
15
}
16
17
qint64 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
29
void
QHttpNetworkHeaderPrivate::setContentLength(qint64 length)
30
{
31
setHeaderField(
"Content-Length"
, QByteArray::number(length));
32
}
33
34
QByteArray 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
43
QList<QByteArray> QHttpNetworkHeaderPrivate::headerFieldValues(QByteArrayView name)
const
44
{
45
return
parser.headerFieldValues(name);
46
}
47
48
void
QHttpNetworkHeaderPrivate::setHeaderField(
const
QByteArray &name,
const
QByteArray &data)
49
{
50
parser.setHeaderField(name, data);
51
}
52
53
void
QHttpNetworkHeaderPrivate::prependHeaderField(
const
QByteArray &name,
const
QByteArray &data)
54
{
55
parser.prependHeaderField(name, data);
56
}
57
58
QHttpHeaders QHttpNetworkHeaderPrivate::headers()
const
59
{
60
return
parser.headers();
61
}
62
63
void
QHttpNetworkHeaderPrivate::clearHeaders()
64
{
65
parser.clearHeaders();
66
}
67
68
bool
QHttpNetworkHeaderPrivate::operator==(
const
QHttpNetworkHeaderPrivate &other)
const
69
{
70
return
(url == other.url);
71
}
72
73
74
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
qtbase
src
network
access
qhttpnetworkheader.cpp
Generated on
for Qt by
1.16.1