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 | #include <QtNetwork/qhttpheaders.h> |
21 | |
22 | #include <qshareddata.h> |
23 | #include <qurl.h> |
24 | |
25 | #ifndef Q_OS_WASM |
26 | QT_REQUIRE_CONFIG(http); |
27 | #endif |
28 | |
29 | QT_BEGIN_NAMESPACE |
30 | |
31 | class Q_AUTOTEST_EXPORT QHttpNetworkHeader |
32 | { |
33 | public: |
34 | virtual ~QHttpNetworkHeader(); |
35 | virtual QUrl url() const = 0; |
36 | virtual void setUrl(const QUrl &url) = 0; |
37 | |
38 | virtual int majorVersion() const = 0; |
39 | virtual int minorVersion() const = 0; |
40 | |
41 | virtual qint64 contentLength() const = 0; |
42 | virtual void setContentLength(qint64 length) = 0; |
43 | |
44 | virtual QHttpHeaders header() const = 0; |
45 | virtual QByteArray headerField(QByteArrayView name, const QByteArray &defaultValue = QByteArray()) const = 0; |
46 | virtual void setHeaderField(const QByteArray &name, const QByteArray &data) = 0; |
47 | }; |
48 | |
49 | class Q_AUTOTEST_EXPORT QHttpNetworkHeaderPrivate : public QSharedData |
50 | { |
51 | public: |
52 | QUrl url; |
53 | QHttpHeaderParser parser; |
54 | |
55 | QHttpNetworkHeaderPrivate(const QUrl &newUrl = QUrl()); |
56 | QHttpNetworkHeaderPrivate(const QHttpNetworkHeaderPrivate &other) = default; |
57 | qint64 contentLength() const; |
58 | void setContentLength(qint64 length); |
59 | |
60 | QByteArray headerField(QByteArrayView name, const QByteArray &defaultValue = QByteArray()) const; |
61 | QList<QByteArray> headerFieldValues(QByteArrayView name) const; |
62 | void setHeaderField(const QByteArray &name, const QByteArray &data); |
63 | void prependHeaderField(const QByteArray &name, const QByteArray &data); |
64 | void clearHeaders(); |
65 | QHttpHeaders headers() const; |
66 | bool operator==(const QHttpNetworkHeaderPrivate &other) const; |
67 | |
68 | }; |
69 | |
70 | |
71 | QT_END_NAMESPACE |
72 | |
73 | #endif // QHTTPNETWORKHEADER_H |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 |