QNetworkCookiePrivate::parseSetCookieHeaderLine: port to QBAV
Change-Id: If777e43d5c24820dfab02bbf49501b09d82cc2a0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>bb10
parent
6db83b57de
commit
5d534d8913
|
|
@ -376,7 +376,7 @@ void QNetworkCookie::setValue(const QByteArray &value)
|
|||
}
|
||||
|
||||
// ### move this to qnetworkcookie_p.h and share with qnetworkaccesshttpbackend
|
||||
static QPair<QByteArray, QByteArray> nextField(const QByteArray &text, int &position, bool isNameValue)
|
||||
static QPair<QByteArray, QByteArray> nextField(QByteArrayView text, int &position, bool isNameValue)
|
||||
{
|
||||
// format is one of:
|
||||
// (1) token
|
||||
|
|
@ -396,11 +396,11 @@ static QPair<QByteArray, QByteArray> nextField(const QByteArray &text, int &posi
|
|||
equalsPosition = semiColonPosition; //no '=' means there is an attribute-name but no attribute-value
|
||||
}
|
||||
|
||||
QByteArray first = text.mid(position, equalsPosition - position).trimmed();
|
||||
QByteArray first = text.mid(position, equalsPosition - position).trimmed().toByteArray();
|
||||
QByteArray second;
|
||||
int secondLength = semiColonPosition - equalsPosition - 1;
|
||||
if (secondLength > 0)
|
||||
second = text.mid(equalsPosition + 1, secondLength).trimmed();
|
||||
second = text.mid(equalsPosition + 1, secondLength).trimmed().toByteArray();
|
||||
|
||||
position = semiColonPosition;
|
||||
return qMakePair(first, second);
|
||||
|
|
@ -940,7 +940,7 @@ QList<QNetworkCookie> QNetworkCookie::parseCookies(const QByteArray &cookieStrin
|
|||
return cookies;
|
||||
}
|
||||
|
||||
QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByteArray &cookieString)
|
||||
QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(QByteArrayView cookieString)
|
||||
{
|
||||
// According to http://wp.netscape.com/newsref/std/cookie_spec.html,<
|
||||
// the Set-Cookie response header is of the format:
|
||||
|
|
@ -982,14 +982,14 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt
|
|||
if (isValueSeparator(cookieString.at(end)))
|
||||
break;
|
||||
|
||||
QByteArray dateString = cookieString.mid(position, end - position).trimmed();
|
||||
QByteArray dateString = cookieString.mid(position, end - position).trimmed().toByteArray().toLower();
|
||||
position = end;
|
||||
QDateTime dt = parseDateString(dateString.toLower());
|
||||
QDateTime dt = parseDateString(dateString);
|
||||
if (dt.isValid())
|
||||
cookie.setExpirationDate(dt);
|
||||
//if unparsed, ignore the attribute but not the whole cookie (RFC6265 section 5.2.1)
|
||||
} else if (field.first == "domain") {
|
||||
QByteArray rawDomain = field.second;
|
||||
QByteArrayView rawDomain = field.second;
|
||||
//empty domain should be ignored (RFC6265 section 5.2.3)
|
||||
if (!rawDomain.isEmpty()) {
|
||||
QLatin1StringView maybeLeadingDot;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class QNetworkCookiePrivate: public QSharedData
|
|||
{
|
||||
public:
|
||||
QNetworkCookiePrivate() = default;
|
||||
static QList<QNetworkCookie> parseSetCookieHeaderLine(const QByteArray &cookieString);
|
||||
static QList<QNetworkCookie> parseSetCookieHeaderLine(QByteArrayView cookieString);
|
||||
|
||||
QDateTime expirationDate;
|
||||
QString domain;
|
||||
|
|
@ -43,7 +43,7 @@ static inline bool isLWS(char c)
|
|||
return c == ' ' || c == '\t' || c == '\r' || c == '\n';
|
||||
}
|
||||
|
||||
static int nextNonWhitespace(const QByteArray &text, int from)
|
||||
static int nextNonWhitespace(QByteArrayView text, int from)
|
||||
{
|
||||
// RFC 2616 defines linear whitespace as:
|
||||
// LWS = [CRLF] 1*( SP | HT )
|
||||
|
|
|
|||
Loading…
Reference in New Issue