/src/qtbase/src/network/access/qhttp1configuration.cpp
Line | Count | Source |
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 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #include "qhttp1configuration.h" |
6 | | |
7 | | #include <QtCore/private/qnumeric_p.h> |
8 | | #include <QtCore/qhashfunctions.h> |
9 | | |
10 | | QT_BEGIN_NAMESPACE |
11 | | |
12 | | // QHttp1ConfigurationPrivate is unused until we need it: |
13 | | static_assert(sizeof(QHttp1Configuration) == sizeof(void*), |
14 | | "You have added too many members to QHttp1Configuration::ShortData. " |
15 | | "Decrease their size or switch to using a d-pointer."); |
16 | | |
17 | | /*! |
18 | | \class QHttp1Configuration |
19 | | \brief The QHttp1Configuration class controls HTTP/1 parameters and settings. |
20 | | \since 6.5 |
21 | | |
22 | | \reentrant |
23 | | \inmodule QtNetwork |
24 | | \ingroup network |
25 | | \ingroup shared |
26 | | |
27 | | QHttp1Configuration controls HTTP/1 parameters and settings that |
28 | | QNetworkAccessManager will use to send requests and process responses. |
29 | | |
30 | | \note The configuration must be set before the first request |
31 | | was sent to a given host (and thus an HTTP/1 session established). |
32 | | |
33 | | \sa QNetworkRequest::setHttp1Configuration(), QNetworkRequest::http1Configuration(), QNetworkAccessManager |
34 | | */ |
35 | | |
36 | | /*! |
37 | | Default constructs a QHttp1Configuration object. |
38 | | */ |
39 | | QHttp1Configuration::QHttp1Configuration() |
40 | 0 | : u(ShortData{6, {}}) // QHttpNetworkConnectionPrivate::defaultHttpChannelCount |
41 | 0 | { |
42 | 0 | } |
43 | | |
44 | | /*! |
45 | | Copy-constructs this QHttp1Configuration. |
46 | | */ |
47 | 0 | QHttp1Configuration::QHttp1Configuration(const QHttp1Configuration &) |
48 | | = default; |
49 | | |
50 | | /*! |
51 | | \fn QHttp1Configuration::QHttp1Configuration(QHttp1Configuration &&other) |
52 | | |
53 | | Move-constructs this QHttp1Configuration from \a other. |
54 | | |
55 | | \note The moved-from object \a other is placed in a |
56 | | partially-formed state, in which the only valid operations are |
57 | | destruction and assignment of a new value. |
58 | | */ |
59 | | |
60 | | /*! |
61 | | Copy-assigns \a other to this QHttp1Configuration. |
62 | | */ |
63 | 0 | QHttp1Configuration &QHttp1Configuration::operator=(const QHttp1Configuration &) |
64 | | = default; |
65 | | |
66 | | /*! |
67 | | \fn QHttp1Configuration &QHttp1Configuration::operator=(QHttp1Configuration &&) |
68 | | |
69 | | Move-assigns \a other to this QHttp1Configuration. |
70 | | |
71 | | \note The moved-from object \a other is placed in a |
72 | | partially-formed state, in which the only valid operations are |
73 | | destruction and assignment of a new value. |
74 | | */ |
75 | | |
76 | | /*! |
77 | | Destructor. |
78 | | */ |
79 | 0 | QHttp1Configuration::~QHttp1Configuration() |
80 | | = default; |
81 | | |
82 | | /*! |
83 | | Sets the number of connections (minimum: 1; maximum: 255) |
84 | | used per http(s) \e{host}:\e{port} combination to \a number. |
85 | | |
86 | | If \a number is ≤ 0, does nothing. If \a number is > 255, 255 is used. |
87 | | |
88 | | \sa numberOfConnectionsPerHost |
89 | | */ |
90 | | void QHttp1Configuration::setNumberOfConnectionsPerHost(qsizetype number) |
91 | 0 | { |
92 | 0 | auto n = qt_saturate<std::uint8_t>(number); |
93 | 0 | if (n == 0) |
94 | 0 | return; |
95 | 0 | u.data.numConnectionsPerHost = n; |
96 | 0 | } |
97 | | |
98 | | /*! |
99 | | Returns the number of connections used per http(s) \c{host}:\e{port} |
100 | | combination. The default is six (6). |
101 | | |
102 | | \sa setNumberOfConnectionsPerHost |
103 | | */ |
104 | | qsizetype QHttp1Configuration::numberOfConnectionsPerHost() const |
105 | 0 | { |
106 | 0 | return u.data.numConnectionsPerHost; |
107 | 0 | } |
108 | | |
109 | | /*! |
110 | | \fn void QHttp1Configuration::swap(QHttp1Configuration &other) |
111 | | \memberswap{HTTP/1 configuration} |
112 | | */ |
113 | | |
114 | | /*! |
115 | | \fn bool QHttp1Configuration::operator==(const QHttp1Configuration &lhs, const QHttp1Configuration &rhs) noexcept |
116 | | \since 6.5 |
117 | | |
118 | | Returns \c true if \a lhs and \a rhs represent the same set of HTTP/1 |
119 | | parameters. |
120 | | */ |
121 | | |
122 | | /*! |
123 | | \fn bool QHttp1Configuration::operator!=(const QHttp1Configuration &lhs, const QHttp1Configuration &rhs) noexcept |
124 | | \since 6.5 |
125 | | |
126 | | Returns \c true if \a lhs and \a rhs do not represent the same set of |
127 | | HTTP/1 parameters. |
128 | | */ |
129 | | |
130 | | /*! |
131 | | \fn size_t QHttp1Configuration::qHash(const QHttp1Configuration &key, size_t seed) |
132 | | \since 6.5 |
133 | | \qhash{QHttp1Configuration} |
134 | | */ |
135 | | |
136 | | /*! |
137 | | \internal |
138 | | */ |
139 | | bool QHttp1Configuration::equals(const QHttp1Configuration &other) const noexcept |
140 | 0 | { |
141 | 0 | return u.data.numConnectionsPerHost == other.u.data.numConnectionsPerHost; |
142 | 0 | } |
143 | | |
144 | | /*! |
145 | | \internal |
146 | | */ |
147 | | size_t QHttp1Configuration::hash(size_t seed) const noexcept |
148 | 0 | { |
149 | 0 | return qHash(u.data.numConnectionsPerHost, seed); |
150 | 0 | } |
151 | | |
152 | | QT_END_NAMESPACE |