20 int pos = auth.
indexOf(
"Basic ");
23 ret = auth.
mid(pos, auth.
indexOf(
',', pos) - pos);
32 const QByteArray authorization = decodeBasicAuth(auth);
34 int pos = authorization.
indexOf(
':');
56 : m_data(other.m_data)
62 return header(
"Content-Disposition");
86 return header(
"Content-Encoding");
91 setHeader(
"Content-Encoding"_ba, encoding);
113 int pos = _contentType.
indexOf(
"charset=", 0);
115 int endPos = _contentType.
indexOf(u
';', pos);
125 auto result = findHeaderConst(m_data,
"Content-Type");
126 if (result == m_data.end() || (result->value.isEmpty() && !charset.
isEmpty())) {
132 int pos = _contentType.
indexOf(
"charset=", 0);
134 int endPos = _contentType.
indexOf(
';', pos);
142 _contentType.
remove(lastPos, _contentType.
length() - lastPos);
145 _contentType.
replace(pos + 8, _contentType.
length() - pos + 8, charset);
148 _contentType.
replace(pos + 8, endPos, charset);
150 }
else if (!charset.
isEmpty()) {
151 _contentType.
append(
"; charset=" + charset);
164 return ct.
compare(
"text/html") == 0 || ct.
compare(
"application/xhtml+xml") == 0 ||
165 ct.
compare(
"application/vnd.wap.xhtml+xml") == 0;
171 return ct.
compare(
"application/xhtml+xml") == 0 ||
172 ct.
compare(
"application/vnd.wap.xhtml+xml") == 0;
183 auto value =
header(
"Content-Type");
184 if (!value.isEmpty()) {
185 return value.compare(
"application/json") == 0;
192 auto value =
header(
"Content-Length");
193 if (!value.isEmpty()) {
194 return value.toLongLong();
217 auto value =
header(
"Date");
218 if (!value.isEmpty()) {
219 if (value.endsWith(
" GMT")) {
221 u
"ddd, dd MMM yyyy hh:mm:ss"_s);
234 return header(
"If-Modified-Since");
240 auto value =
header(
"If-Modified-Since");
241 if (!value.isEmpty()) {
242 if (value.endsWith(
" GMT")) {
244 u
"ddd, dd MMM yyyy hh:mm:ss"_s);
257 auto value =
header(
"If-Modified-Since");
258 if (!value.isEmpty()) {
268 auto value =
header(
"If-Match");
269 if (!value.isEmpty()) {
271 return clientETag.sliced(1, clientETag.size() - 2) == etag ||
272 clientETag.
sliced(3, clientETag.size() - 4) == etag;
279 auto value =
header(
"If-None-Match");
280 if (!value.isEmpty()) {
282 return clientETag.sliced(1, clientETag.size() - 2) == etag ||
283 clientETag.
sliced(3, clientETag.size() - 4) == etag;
295 return header(
"Last-Modified");
324 return header(
"Connection");
334 return header(
"User-Agent");
344 int fragmentPos = uri.
indexOf(
'#');
345 if (fragmentPos != -1) {
360 setHeader(
"Proxy-Authenticate"_ba, value);
365 return header(
"Authorization");
372 int pos = auth.
indexOf(
"Bearer ");
375 ret = auth.
mid(pos, auth.
indexOf(
',', pos) - pos);
394 qCWarning(CUTELYST_CORE) <<
"Headers::Basic authorization user name can't contain ':'";
398 const QString result = username + u
':' + password;
406 return header(
"Proxy-Authorization");
421 if (
auto result = findHeaderConst(m_data, key); result != m_data.end()) {
422 return result->value;
434 if (
auto result = findHeaderConst(m_data, key); result != m_data.end()) {
435 return result->value;
442 if (
auto result = findHeaderConst(m_data, key); result != m_data.end()) {
451 for (
auto result = findHeaderConst(m_data, key); result != m_data.end(); ++result) {
452 ret.
append(result->value);
460 for (
auto result = findHeaderConst(m_data, key); result != m_data.end(); ++result) {
472 if (
auto result = std::ranges::find_if(m_data, matchKey); result != m_data.end()) {
473 result->value = value;
477 std::remove_if(result, m_data.end(), matchKey);
478 m_data.erase(begin, m_data.
cend());
508 auto result = findHeaderConst(m_data, key);
509 return result != m_data.end();
516 for (
const auto &_header : m_data) {
517 const bool exists = std::ranges::any_of(ret, [&](
const QByteArray &key) {
536 const auto otherData = other.data();
537 if (m_data.size() != otherData.size()) {
541 return std::ranges::all_of(
542 m_data, [otherData](
const auto &myValue) {
return otherData.contains(myValue); });
547 const auto data = headers.
data();
550 for (
auto it = data.begin(); it != data.end(); ++it) {
551 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) &&
qsizetype length() const const
QByteArray mid(qsizetype pos, qsizetype len) &&
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 setTimeSpec(Qt::TimeSpec spec)
bool autoInsertSpaces() const const
void setAutoInsertSpaces(bool b)
void append(QList< T > &&value)
QList< T >::const_iterator cend() const const
QDateTime toDateTime(const QString &string, QLocale::FormatType format, QCalendar cal, int baseYear) 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