1// Copyright (C) 2016 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#ifndef QNETWORKCOOKIE_P_H
6#define QNETWORKCOOKIE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of the Network Access framework. This header file may change from
14// version to version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtNetwork/private/qtnetworkglobal_p.h>
20#include "QtCore/qdatetime.h"
21#include "QtNetwork/qnetworkcookie.h"
22
23QT_BEGIN_NAMESPACE
24
25class QNetworkCookiePrivate: public QSharedData
26{
27public:
28 QNetworkCookiePrivate() = default;
29 static QList<QNetworkCookie> parseSetCookieHeaderLine(QByteArrayView cookieString);
30
31 QDateTime expirationDate;
32 QString domain;
33 QString path;
34 QString comment;
35 QByteArray name;
36 QByteArray value;
37 QNetworkCookie::SameSite sameSite = QNetworkCookie::SameSite::Default;
38 bool secure = false;
39 bool httpOnly = false;
40};
41
42static inline bool isLWS(char c)
43{
44 return c == ' ' || c == '\t' || c == '\r' || c == '\n';
45}
46
47static int nextNonWhitespace(QByteArrayView text, int from)
48{
49 // RFC 2616 defines linear whitespace as:
50 // LWS = [CRLF] 1*( SP | HT )
51 // We ignore the fact that CRLF must come as a pair at this point
52 // It's an invalid HTTP header if that happens.
53 while (from < text.size()) {
54 if (isLWS(c: text.at(n: from)))
55 ++from;
56 else
57 return from; // non-whitespace
58 }
59
60 // reached the end
61 return text.size();
62}
63
64QT_END_NAMESPACE
65
66#endif
67

source code of qtbase/src/network/access/qnetworkcookie_p.h