| 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 | |
| 4 | #ifndef QNETWORKCOOKIE_P_H |
| 5 | #define QNETWORKCOOKIE_P_H |
| 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 framework. 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 | #include "QtCore/qdatetime.h" |
| 20 | #include "QtNetwork/qnetworkcookie.h" |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | class QNetworkCookiePrivate: public QSharedData |
| 25 | { |
| 26 | public: |
| 27 | QNetworkCookiePrivate() = default; |
| 28 | static QList<QNetworkCookie> (QByteArrayView cookieString); |
| 29 | |
| 30 | QDateTime expirationDate; |
| 31 | QString domain; |
| 32 | QString path; |
| 33 | QString ; |
| 34 | QByteArray name; |
| 35 | QByteArray value; |
| 36 | QNetworkCookie::SameSite sameSite = QNetworkCookie::SameSite::Default; |
| 37 | bool secure = false; |
| 38 | bool httpOnly = false; |
| 39 | }; |
| 40 | |
| 41 | static inline bool isLWS(char c) |
| 42 | { |
| 43 | return c == ' ' || c == '\t' || c == '\r' || c == '\n'; |
| 44 | } |
| 45 | |
| 46 | static int nextNonWhitespace(QByteArrayView text, int from) |
| 47 | { |
| 48 | // RFC 2616 defines linear whitespace as: |
| 49 | // LWS = [CRLF] 1*( SP | HT ) |
| 50 | // We ignore the fact that CRLF must come as a pair at this point |
| 51 | // It's an invalid HTTP header if that happens. |
| 52 | while (from < text.size()) { |
| 53 | if (isLWS(c: text.at(n: from))) |
| 54 | ++from; |
| 55 | else |
| 56 | return from; // non-whitespace |
| 57 | } |
| 58 | |
| 59 | // reached the end |
| 60 | return text.size(); |
| 61 | } |
| 62 | |
| 63 | QT_END_NAMESPACE |
| 64 | |
| 65 | #endif |
| 66 | |