Skip to content

Commit

Permalink
Move WellKnownHeaders code to top
Browse files Browse the repository at this point in the history
Small rearrangement to make diff on later variant/union commit
more readable

Task-number: QTBUG-119002
Change-Id: I3f6120b5dcd324b6493072d2eb58209866fb7dc6
Reviewed-by: Marc Mutz <[email protected]>
(cherry picked from commit f757662)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
  • Loading branch information
Juha Vuolle authored and Qt Cherry-pick Bot committed Jan 29, 2024
1 parent f643656 commit 9f6e20a
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions src/network/access/qhttpheaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,41 +69,6 @@ Q_LOGGING_CATEGORY(lcQHttpHeaders, "qt.network.http.headers");
the values.
*/

// A clarification on case-sensitivity:
// - Header *names* are case-insensitive; Content-Type and content-type are considered equal
// - Header *values* are case-sensitive
// (In addition, the HTTP/2 and HTTP/3 standards mandate that all headers must be lower-cased when
// encoded into transmission)
struct Header {
QByteArray name;
QByteArray value;

private:
friend bool operator==(const Header &lhs, const Header &rhs) noexcept
{
return lhs.value == rhs.value && lhs.name == rhs.name;
}
};

class QHttpHeadersPrivate : public QSharedData
{
public:
QHttpHeadersPrivate() = default;

QList<Header> headers;
};

QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QHttpHeadersPrivate)
template <> void QExplicitlySharedDataPointer<QHttpHeadersPrivate>::detach()
{
if (!d) {
d = new QHttpHeadersPrivate();
d->ref.ref();
} else if (d->ref.loadRelaxed() != 1) {
detach_helper();
}
}

// This list is from IANA HTTP Field Name Registry
// https://www.iana.org/assignments/http-fields
// It contains entries that are either "permanent"
Expand Down Expand Up @@ -478,6 +443,41 @@ static constexpr auto headerNames = qOffsetStringArray(
\value ProtocolQuery
*/

// A clarification on case-sensitivity:
// - Header *names* are case-insensitive; Content-Type and content-type are considered equal
// - Header *values* are case-sensitive
// (In addition, the HTTP/2 and HTTP/3 standards mandate that all headers must be lower-cased when
// encoded into transmission)
struct Header {
QByteArray name;
QByteArray value;

private:
friend bool operator==(const Header &lhs, const Header &rhs) noexcept
{
return lhs.value == rhs.value && lhs.name == rhs.name;
}
};

class QHttpHeadersPrivate : public QSharedData
{
public:
QHttpHeadersPrivate() = default;

QList<Header> headers;
};

QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QHttpHeadersPrivate)
template <> void QExplicitlySharedDataPointer<QHttpHeadersPrivate>::detach()
{
if (!d) {
d = new QHttpHeadersPrivate();
d->ref.ref();
} else if (d->ref.loadRelaxed() != 1) {
detach_helper();
}
}

/*!
Creates a new QHttpHeaders object.
*/
Expand Down

0 comments on commit 9f6e20a

Please sign in to comment.