1 | // Copyright (C) 2022 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 QHTTPHEADERPARSER_H |
5 | #define |
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/qhttpheaders.h> |
20 | |
21 | #include <QByteArray> |
22 | #include <QList> |
23 | #include <QPair> |
24 | #include <QString> |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | namespace HeaderConstants { |
29 | |
30 | // We previously used 8K, which is common on server side, but it turned out to |
31 | // not be enough for various uses. Historically Firefox used 10K as the limit of |
32 | // a single field, but some Location headers and Authorization challenges can |
33 | // get even longer. Other browsers, such as Chrome, instead have a limit on the |
34 | // total size of all the headers (as well as extra limits on some of the |
35 | // individual fields). We'll use 100K as our default limit, which would be a ridiculously large |
36 | // header, with the possibility to override it where we need to. |
37 | static constexpr int = 100 * 1024; |
38 | // Taken from http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfields |
39 | static constexpr int = 100; |
40 | // Chromium has a limit on the total size of the header set to 256KB, |
41 | // which is a reasonable default for QNetworkAccessManager. |
42 | // https://stackoverflow.com/a/3436155 |
43 | static constexpr int = 256 * 1024; |
44 | |
45 | } |
46 | |
47 | class Q_NETWORK_EXPORT |
48 | { |
49 | public: |
50 | (); |
51 | |
52 | void (); |
53 | bool (QByteArrayView ); |
54 | bool (QByteArrayView status); |
55 | |
56 | const QHttpHeaders& () const &; |
57 | QHttpHeaders () &&; |
58 | void (int code); |
59 | int () const; |
60 | int () const; |
61 | void (int version); |
62 | int () const; |
63 | void (int version); |
64 | QString () const; |
65 | void (const QString &reason); |
66 | |
67 | QByteArray (QByteArrayView name, |
68 | const QByteArray &defaultValue = QByteArray()) const; |
69 | QByteArray (QByteArrayView name, |
70 | const QByteArray &defaultValue = QByteArray()) const; |
71 | QList<QByteArray> (QByteArrayView name) const; |
72 | void (const QByteArray &name, const QByteArray &data); |
73 | void (const QByteArray &name, const QByteArray &data); |
74 | void (const QByteArray &name, const QByteArray &data); |
75 | void (QByteArrayView name); |
76 | void (); |
77 | |
78 | void (qsizetype size) { maxFieldSize = size; } |
79 | qsizetype () const { return maxFieldSize; } |
80 | |
81 | void (qsizetype size) { maxTotalSize = size; } |
82 | qsizetype () const { return maxTotalSize; } |
83 | |
84 | void (qsizetype count) { maxFieldCount = count; } |
85 | qsizetype () const { return maxFieldCount; } |
86 | |
87 | private: |
88 | QHttpHeaders ; |
89 | QString ; |
90 | int ; |
91 | int ; |
92 | int ; |
93 | |
94 | qsizetype = HeaderConstants::MAX_HEADER_FIELD_SIZE; |
95 | qsizetype = HeaderConstants::MAX_TOTAL_HEADER_SIZE; |
96 | qsizetype = HeaderConstants::MAX_HEADER_FIELDS; |
97 | }; |
98 | |
99 | |
100 | QT_END_NAMESPACE |
101 | |
102 | #endif // QHTTPHEADERPARSER_H |
103 | |