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
4#ifndef QHTTPNETWORKHEADER_H
5#define QHTTPNETWORKHEADER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of the Network Access API. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtNetwork/private/qtnetworkglobal_p.h>
19#include <QtNetwork/private/qhttpheaderparser_p.h>
20
21#include <qshareddata.h>
22#include <qurl.h>
23
24#ifndef Q_OS_WASM
25QT_REQUIRE_CONFIG(http);
26#endif
27
28QT_BEGIN_NAMESPACE
29
30class Q_AUTOTEST_EXPORT QHttpNetworkHeader
31{
32public:
33 virtual ~QHttpNetworkHeader() {}
34 virtual QUrl url() const = 0;
35 virtual void setUrl(const QUrl &url) = 0;
36
37 virtual int majorVersion() const = 0;
38 virtual int minorVersion() const = 0;
39
40 virtual qint64 contentLength() const = 0;
41 virtual void setContentLength(qint64 length) = 0;
42
43 virtual QList<QPair<QByteArray, QByteArray> > header() const = 0;
44 virtual QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const = 0;
45 virtual void setHeaderField(const QByteArray &name, const QByteArray &data) = 0;
46};
47
48class Q_AUTOTEST_EXPORT QHttpNetworkHeaderPrivate : public QSharedData
49{
50public:
51 QUrl url;
52 QHttpHeaderParser parser;
53
54 QHttpNetworkHeaderPrivate(const QUrl &newUrl = QUrl());
55 QHttpNetworkHeaderPrivate(const QHttpNetworkHeaderPrivate &other) = default;
56 qint64 contentLength() const;
57 void setContentLength(qint64 length);
58
59 QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const;
60 QList<QByteArray> headerFieldValues(const QByteArray &name) const;
61 void setHeaderField(const QByteArray &name, const QByteArray &data);
62 void prependHeaderField(const QByteArray &name, const QByteArray &data);
63 void clearHeaders();
64 QList<QPair<QByteArray, QByteArray> > headers() const;
65 bool operator==(const QHttpNetworkHeaderPrivate &other) const;
66
67};
68
69
70QT_END_NAMESPACE
71
72#endif // QHTTPNETWORKHEADER_H
73
74
75
76
77
78
79

source code of qtbase/src/network/access/qhttpnetworkheader_p.h