summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhttp1configuration.cpp
blob: cfa929bca509ebbdb6599c83c26ab61d1ba17e92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qhttp1configuration.h"

#include <QtCore/private/qnumeric_p.h>
#include <QtCore/qhashfunctions.h>

QT_BEGIN_NAMESPACE

// QHttp1ConfigurationPrivate is unused until we need it:
static_assert(sizeof(QHttp1Configuration) == sizeof(void*),
              "You have added too many members to QHttp1Configuration::ShortData. "
              "Decrease their size or switch to using a d-pointer.");

/*!
    \class QHttp1Configuration
    \brief The QHttp1Configuration class controls HTTP/1 parameters and settings.
    \since 6.5

    \reentrant
    \inmodule QtNetwork
    \ingroup network
    \ingroup shared

    QHttp1Configuration controls HTTP/1 parameters and settings that
    QNetworkAccessManager will use to send requests and process responses.

    \note The configuration must be set before the first request
    was sent to a given host (and thus an HTTP/1 session established).

    \sa QNetworkRequest::setHttp1Configuration(), QNetworkRequest::http1Configuration(), QNetworkAccessManager
*/

/*!
    Default constructs a QHttp1Configuration object.
*/
QHttp1Configuration::QHttp1Configuration()
    : u(ShortData{6, {}}) // QHttpNetworkConnectionPrivate::defaultHttpChannelCount
{
}

/*!
    Copy-constructs this QHttp1Configuration.
*/
QHttp1Configuration::QHttp1Configuration(const QHttp1Configuration &)
    = default;

/*!
    \fn QHttp1Configuration::QHttp1Configuration(QHttp1Configuration &&other)

    Move-constructs this QHttp1Configuration from \a other.

    \note The moved-from object \a other is placed in a
    partially-formed state, in which the only valid operations are
    destruction and assignment of a new value.
*/

/*!
    Copy-assigns \a other to this QHttp1Configuration.
*/
QHttp1Configuration &QHttp1Configuration::operator=(const QHttp1Configuration &)
    = default;

/*!
    \fn QHttp1Configuration &QHttp1Configuration::operator=(QHttp1Configuration &&)

    Move-assigns \a other to this QHttp1Configuration.

    \note The moved-from object \a other is placed in a
    partially-formed state, in which the only valid operations are
    destruction and assignment of a new value.
*/

/*!
    Destructor.
*/
QHttp1Configuration::~QHttp1Configuration()
    = default;

/*!
    Sets the number of connections (minimum: 1; maximum: 255)
    used per http(s) \e{host}:\e{port} combination to \a number.

    If \a number is ≤ 0, does nothing. If \a number is > 255, 255 is used.

    \sa numberOfConnectionsPerHost
*/
void QHttp1Configuration::setNumberOfConnectionsPerHost(qsizetype number)
{
    auto n = qt_saturate<std::uint8_t>(number);
    if (n == 0)
        return;
    u.data.numConnectionsPerHost = n;
}

/*!
    Returns the number of connections used per http(s) \c{host}:\e{port}
    combination. The default is six (6).

    \sa setNumberOfConnectionsPerHost
*/
qsizetype QHttp1Configuration::numberOfConnectionsPerHost() const
{
    return u.data.numConnectionsPerHost;
}

/*!
    \fn void QHttp1Configuration::swap(QHttp1Configuration &other)

    Swaps this HTTP/1 configuration with \a other. This operation is very fast
    and never fails.
*/

/*!
    \fn bool QHttp1Configuration::operator==(const QHttp1Configuration &lhs, const QHttp1Configuration &rhs) noexcept
    \since 6.5

    Returns \c true if \a lhs and \a rhs represent the same set of HTTP/1
    parameters.
*/

/*!
    \fn bool QHttp1Configuration::operator!=(const QHttp1Configuration &lhs, const QHttp1Configuration &rhs) noexcept
    \since 6.5

    Returns \c true if \a lhs and \a rhs do not represent the same set of
    HTTP/1 parameters.
*/

/*!
    \fn size_t QHttp1Configuration::qHash(const QHttp1Configuration &key, size_t seed)
    \since 6.5

    Returns the hash value for the \a key, using \a seed to seed the calculation.
*/

/*!
    \internal
*/
bool QHttp1Configuration::equals(const QHttp1Configuration &other) const noexcept
{
    return u.data.numConnectionsPerHost == other.u.data.numConnectionsPerHost;
}

/*!
    \internal
*/
size_t QHttp1Configuration::hash(size_t seed) const noexcept
{
    return qHash(u.data.numConnectionsPerHost, seed);
}

QT_END_NAMESPACE