19 int pos = auth.
indexOf(
"Basic ");
22 ret = auth.
mid(pos, auth.
indexOf(
',', pos) - pos);
31 const QByteArray authorization = decodeBasicAuth(auth);
33 int pos = authorization.
indexOf(
':');
53 : m_data(other.m_data)
59 return header(
"Content-Disposition");
83 return header(
"Content-Encoding");
88 setHeader(
"Content-Encoding"_ba, encoding);
110 int pos = _contentType.
indexOf(
"charset=", 0);
112 int endPos = _contentType.
indexOf(u
';', pos);
122 auto result = findHeaderConst(m_data,
"Content-Type");
123 if (result == m_data.end() || (result->value.isEmpty() && !charset.
isEmpty())) {
129 int pos = _contentType.
indexOf(
"charset=", 0);
131 int endPos = _contentType.
indexOf(
';', pos);
139 _contentType.
remove(lastPos, _contentType.
length() - lastPos);
142 _contentType.
replace(pos + 8, _contentType.
length() - pos + 8, charset);
145 _contentType.
replace(pos + 8, endPos, charset);
147 }
else if (!charset.
isEmpty()) {
148 _contentType.
append(
"; charset=" + charset);
161 return ct.
compare(
"text/html") == 0 || ct.
compare(
"application/xhtml+xml") == 0 ||
162 ct.
compare(
"application/vnd.wap.xhtml+xml") == 0;
168 return ct.
compare(
"application/xhtml+xml") == 0 ||
169 ct.
compare(
"application/vnd.wap.xhtml+xml") == 0;
180 auto value =
header(
"Content-Type");
181 if (!value.isEmpty()) {
182 return value.compare(
"application/json") == 0;
189 auto value =
header(
"Content-Length");
190 if (!value.isEmpty()) {
191 return value.toLongLong();
214 auto value =
header(
"Date");
215 if (!value.isEmpty()) {
216 if (value.endsWith(
" GMT")) {
218 u
"ddd, dd MMM yyyy hh:mm:ss"_s);
231 return header(
"If-Modified-Since");
237 auto value =
header(
"If-Modified-Since");
238 if (!value.isEmpty()) {
239 if (value.endsWith(
" GMT")) {
241 u
"ddd, dd MMM yyyy hh:mm:ss"_s);
254 auto value =
header(
"If-Modified-Since");
255 if (!value.isEmpty()) {
265 auto value =
header(
"If-Match");
266 if (!value.isEmpty()) {
268 return clientETag.sliced(1, clientETag.size() - 2) == etag ||
269 clientETag.
sliced(3, clientETag.size() - 4) == etag;
276 auto value =
header(
"If-None-Match");
277 if (!value.isEmpty()) {
279 return clientETag.sliced(1, clientETag.size() - 2) == etag ||
280 clientETag.
sliced(3, clientETag.size() - 4) == etag;
292 return header(
"Last-Modified");
321 return header(
"Connection");
331 return header(
"User-Agent");
341 int fragmentPos = uri.
indexOf(
'#');
342 if (fragmentPos != -1) {
357 setHeader(
"Proxy-Authenticate"_ba, value);
362 return header(
"Authorization");
369 int pos = auth.
indexOf(
"Bearer ");
372 ret = auth.
mid(pos, auth.
indexOf(
',', pos) - pos);
391 qCWarning(CUTELYST_CORE) <<
"Headers::Basic authorization user name can't contain ':'";
395 const QString result = username + u
':' + password;
403 return header(
"Proxy-Authorization");
418 if (
auto result = findHeaderConst(m_data, key); result != m_data.end()) {
419 return result->value;
431 if (
auto result = findHeaderConst(m_data, key); result != m_data.end()) {
432 return result->value;
439 if (
auto result = findHeaderConst(m_data, key); result != m_data.end()) {
448 for (
auto result = findHeaderConst(m_data, key); result != m_data.end(); ++result) {
449 ret.
append(result->value);
457 for (
auto result = findHeaderConst(m_data, key); result != m_data.end(); ++result) {
469 if (
auto result = std::ranges::find_if(m_data, matchKey); result != m_data.end()) {
470 result->value = value;
474 std::remove_if(result, m_data.end(), matchKey);
475 m_data.erase(begin, m_data.cend());
505 auto result = findHeaderConst(m_data, key);
506 return result != m_data.end();
513 for (
const auto &_header : m_data) {
514 const bool exists = std::ranges::any_of(ret, [&](
const QByteArray &key) {
533 const auto otherData = other.data();
534 if (m_data.size() != otherData.size()) {
538 return std::ranges::all_of(
539 m_data, [otherData](
const auto &myValue) {
return otherData.contains(myValue); });
544 const auto data = headers.
data();
547 for (
auto it = data.begin(); it != data.end(); ++it) {
548 debug <<
'(' << it->key +
'=' + it->value <<
')';
The Cutelyst namespace holds all public Cutelyst API.
int compare(QAnyStringView lhs, QAnyStringView rhs, Qt::CaseSensitivity cs)
QAnyStringView sliced(qsizetype pos) const const
QByteArray & append(QByteArrayView data)
int compare(QByteArrayView bv, Qt::CaseSensitivity cs) const const
bool endsWith(QByteArrayView bv) const const
QByteArray fromBase64(const QByteArray &base64, QByteArray::Base64Options options)
qsizetype indexOf(QByteArrayView bv, qsizetype from) const const
bool isEmpty() const const
qsizetype lastIndexOf(QByteArrayView bv) const const
QByteArray left(qsizetype len) const const
qsizetype length() const const
QByteArray mid(qsizetype pos, qsizetype len) const const
QByteArray number(double n, char format, int precision)
QByteArray & remove(qsizetype pos, qsizetype len)
QByteArray & replace(QByteArrayView before, QByteArrayView after)
bool startsWith(QByteArrayView bv) const const
QByteArray toBase64(QByteArray::Base64Options options) const const
QByteArray toLower() const const
QByteArray toUpper() const const
QByteArray trimmed() const const
QByteArray join(QByteArrayView separator) const const
void setTimeZone(const QTimeZone &toZone)
QDateTime toUTC() const const
bool autoInsertSpaces() const const
void setAutoInsertSpaces(bool b)
void append(QList::parameter_type value)
QDateTime toDateTime(const QString &string, QLocale::FormatType format) const const
QString toString(QDate date, QLocale::FormatType format) const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
QString fromLatin1(QByteArrayView str)
QByteArray toLatin1() const const