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