10 #include <QStringList> 24 return std::find_if(headers.cbegin(), headers.cend(), matchKey);
29 : m_data(other.m_data)
35 return header(
"Content-Disposition");
59 return header(
"Content-Encoding");
64 setHeader(
"Content-Encoding"_qba, encoding);
98 auto result = findHeaderConst(m_data,
"Content-Type");
99 if (result == m_data.end() || (result->value.isEmpty() && !charset.
isEmpty())) {
123 }
else if (!charset.
isEmpty()) {
137 return ct.
compare(
"text/html") == 0 || ct.
compare(
"application/xhtml+xml") == 0 ||
138 ct.
compare(
"application/vnd.wap.xhtml+xml") == 0;
144 return ct.
compare(
"application/xhtml+xml") == 0 ||
145 ct.
compare(
"application/vnd.wap.xhtml+xml") == 0;
156 auto value =
header(
"Content-Type");
157 if (!value.isEmpty()) {
158 return value.compare(
"application/json") == 0;
165 auto value =
header(
"Content-Length");
166 if (!value.isEmpty()) {
167 return value.toLongLong();
190 auto value =
header(
"Date");
191 if (!value.isEmpty()) {
192 if (value.endsWith(
" GMT")) {
194 QStringLiteral(
"ddd, dd MMM yyyy hh:mm:ss"));
197 QStringLiteral(
"ddd, dd MMM yyyy hh:mm:ss"));
207 return header(
"If-Modified-Since");
213 auto value =
header(
"If-Modified-Since");
214 if (!value.isEmpty()) {
215 if (value.endsWith(
" GMT")) {
217 QStringLiteral(
"ddd, dd MMM yyyy hh:mm:ss"));
220 QStringLiteral(
"ddd, dd MMM yyyy hh:mm:ss"));
230 auto value =
header(
"If-Modified-Since");
231 if (!value.isEmpty()) {
241 auto value =
header(
"If-Match");
242 if (!value.isEmpty()) {
244 return clientETag.sliced(1, clientETag.size() - 2) == etag ||
245 clientETag.
sliced(3, clientETag.size() - 4) == etag;
252 auto value =
header(
"If-None-Match");
253 if (!value.isEmpty()) {
255 return clientETag.sliced(1, clientETag.size() - 2) == etag ||
256 clientETag.
sliced(3, clientETag.size() - 4) == etag;
268 return header(
"Last-Modified");
297 return header(
"Connection");
307 return header(
"User-Agent");
317 int fragmentPos = uri.
indexOf(
'#');
318 if (fragmentPos != -1) {
328 setHeader(
"Www-Authenticate"_qba, value);
333 setHeader(
"Proxy-Authenticate"_qba, value);
338 return header(
"Authorization");
345 int pos = auth.indexOf(
"Bearer ");
348 ret = auth.
mid(pos, auth.indexOf(
',', pos) - pos);
367 qCWarning(CUTELYST_CORE) <<
"Headers::Basic authorization user name can't contain ':'";
371 const QString result = username + u
':' + password;
379 return header(
"Proxy-Authorization");
394 if (
auto result = findHeaderConst(m_data, key); result != m_data.end()) {
395 return result->value;
407 if (
auto result = findHeaderConst(m_data, key); result != m_data.end()) {
408 return result->value;
421 for (
auto result = findHeaderConst(m_data, key); result != m_data.end(); ++result) {
422 ret.
append(result->value);
430 for (
auto result = findHeaderConst(m_data, key); result != m_data.end(); ++result) {
442 if (
auto result = std::find_if(m_data.begin(), m_data.end(), matchKey);
443 result != m_data.end()) {
444 result->value = value;
447 m_data.erase(std::remove_if(result, m_data.end(), matchKey), m_data.end());
460 m_data.push_back({key, value});
465 m_data.push_back({key, values.
join(
", ")});
476 auto result = findHeaderConst(m_data, key);
477 return result != m_data.end();
484 for (
const auto &
header : m_data) {
486 for (
const auto &key : ret) {
508 const auto otherData = other.data();
509 if (m_data.size() != otherData.size()) {
513 for (
const auto &myValue : m_data) {
514 if (!other.data().contains(myValue)) {
525 int pos = auth.
indexOf(
"Basic ");
528 ret = auth.
mid(pos, auth.
indexOf(
',', pos) - pos);
537 const QByteArray authorization = decodeBasicAuth(auth);
538 if (!authorization.
isEmpty()) {
539 int pos = authorization.
indexOf(
':');
552 const auto data = headers.
data();
555 for (
auto it = data.begin(); it != data.end(); ++it) {
556 debug <<
'(' << it->key +
'=' + it->value <<
')';
void setAutoInsertSpaces(bool b)
QDateTime toUTC() const const
bool endsWith(char ch) const const
QString toString(qlonglong i) const const
QByteArray trimmed() const const
qsizetype lastIndexOf(char ch, qsizetype from) const const
QByteArray toUpper() const const
bool isEmpty() const const
bool startsWith(QByteArrayView bv) const const
QDateTime toDateTime(const QString &string, QLocale::FormatType format) const const
qsizetype length() const const
int compare(QByteArrayView bv, Qt::CaseSensitivity cs) const const
void setTimeSpec(Qt::TimeSpec spec)
qsizetype indexOf(char ch, qsizetype from) const const
QByteArray join() const const
void append(QList::parameter_type value)
QByteArray number(int n, int base)
QByteArray & replace(qsizetype pos, qsizetype len, const char *after, qsizetype alen)
The Cutelyst namespace holds all public Cutelyst API.
QByteArray sliced(qsizetype pos) const const
QByteArray mid(qsizetype pos, qsizetype len) const const
QByteArray & append(char ch)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
QString fromLatin1(QByteArrayView str)
int compare(QByteArrayView bv, Qt::CaseSensitivity cs) const const
QByteArray left(qsizetype len) const const
QByteArray toLatin1() const const
QByteArray fromBase64(const QByteArray &base64, QByteArray::Base64Options options)
bool autoInsertSpaces() const const
QByteArray toBase64(QByteArray::Base64Options options) const const
QByteArray & remove(qsizetype pos, qsizetype len)