Qt 6.x
The Qt SDK
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
5
6#include <algorithm>
7
9
11 :url(newUrl)
12{
13}
14
16{
17 bool ok = false;
18 // We are not using the headerField() method here because servers might send us multiple content-length
19 // headers which is crap (see QTBUG-15311). Therefore just take the first content-length header field.
20 QByteArray value = parser.firstHeaderField("content-length");
22 if (ok)
23 return length;
24 return -1; // the header field is not set
25}
26
28{
29 setHeaderField("Content-Length", QByteArray::number(length));
30}
31
33{
35 if (allValues.isEmpty())
36 return defaultValue;
37 else
38 return allValues.join(", ");
39}
40
42{
44}
45
47{
49}
50
52{
54}
55
57{
58 return parser.headers();
59}
60
62{
64}
65
67{
68 return (url == other.url);
69}
70
71
\inmodule QtCore
Definition qbytearray.h:57
qulonglong toULongLong(bool *ok=nullptr, int base=10) const
Returns the byte array converted to an {unsigned long long} using base base, which is ten by default.
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
void setHeaderField(const QByteArray &name, const QByteArray &data)
const QList< QPair< QByteArray, QByteArray > > & headers() const
QByteArray firstHeaderField(const QByteArray &name, const QByteArray &defaultValue=QByteArray()) const
QList< QByteArray > headerFieldValues(const QByteArray &name) const
void prependHeaderField(const QByteArray &name, const QByteArray &data)
QHttpNetworkHeaderPrivate(const QUrl &newUrl=QUrl())
bool operator==(const QHttpNetworkHeaderPrivate &other) const
void setHeaderField(const QByteArray &name, const QByteArray &data)
void setContentLength(qint64 length)
QList< QPair< QByteArray, QByteArray > > headers() const
void prependHeaderField(const QByteArray &name, const QByteArray &data)
QList< QByteArray > headerFieldValues(const QByteArray &name) const
QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue=QByteArray()) const
Definition qlist.h:74
bool isEmpty() const noexcept
Definition qlist.h:390
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint name
long long qint64
Definition qtypes.h:55
QUrl url("example.com")
[constructor-url-reference]
QSharedPointer< T > other(t)
[5]