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;
448 std::remove_if(result, m_data.end(), matchKey);
449 m_data.erase(begin, m_data.cend());
462 m_data.push_back({key, value});
467 m_data.push_back({key, values.
join(
", ")});
478 auto result = findHeaderConst(m_data, key);
479 return result != m_data.end();
486 for (
const auto &
header : m_data) {
488 for (
const auto &key : ret) {
510 const auto otherData = other.data();
511 if (m_data.size() != otherData.size()) {
515 for (
const auto &myValue : m_data) {
516 if (!other.data().contains(myValue)) {
527 int pos = auth.
indexOf(
"Basic ");
530 ret = auth.
mid(pos, auth.
indexOf(
',', pos) - pos);
539 const QByteArray authorization = decodeBasicAuth(auth);
540 if (!authorization.
isEmpty()) {
541 int pos = authorization.
indexOf(
':');
554 const auto data = headers.
data();
557 for (
auto it = data.begin(); it != data.end(); ++it) {
558 debug <<
'(' << it->key +
'=' + it->value <<
')';
void setAutoInsertSpaces(bool b)
QDateTime toUTC() const const
QByteArray trimmed() const const
qsizetype lastIndexOf(QByteArrayView bv) 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
QString toString(QDate date, QLocale::FormatType format) const const
int compare(QByteArrayView bv, Qt::CaseSensitivity cs) const const
void setTimeSpec(Qt::TimeSpec spec)
QByteArray join(QByteArrayView separator) const const
qsizetype indexOf(QByteArrayView bv, qsizetype from) const const
void append(QList::parameter_type value)
QByteArray number(double n, char format, int precision)
QByteArray & replace(QByteArrayView before, QByteArrayView after)
The Cutelyst namespace holds all public Cutelyst API.
QByteArray sliced(qsizetype pos) const const
QByteArray mid(qsizetype pos, qsizetype len) const const
QByteArray & append(QByteArrayView data)
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)
bool endsWith(QByteArrayView bv) const const