12 #define LOC QString("HTTPParse: ")
26 : m_serverName(Config.m_serverName),
27 m_method(std::move(Method)),
28 m_headers(std::move(Headers)),
30 m_root(Config.m_rootDir),
31 m_timeout(Config.m_timeout)
34 QStringList tokens =
m_method.simplified().split(
' ', Qt::SkipEmptyParts);
38 if (tokens.size() < 2 || tokens.size() > 3)
40 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Failed to parse HTTP method");
54 if (tokens.size() > 2)
60 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Unknown HTTP version");
68 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Unknown HTTP request");
73 bool havehost =
m_headers->contains(
"host");
76 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"No host header for HTTP/1.1");
81 if (havehost &&
m_headers->count(
"host") > 1)
83 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Multiple 'Host' headers forbidden");
112 QHostAddress host = Socket->localAddress();
117 if (!
m_url.isValid())
119 LOG(VB_GENERAL, LOG_WARNING,
LOC + QString(
"Invalid URL: '%1'").arg(
m_url.toString()));
124 m_path =
m_url.toString(QUrl::RemoveFilename | QUrl::RemoveFragment | QUrl::RemoveQuery);
132 if (connection.contains(QStringLiteral(
"keep-alive")))
134 else if (connection.contains(QStringLiteral(
"close")))
151 QStringList params = Query.split(
'&', Qt::SkipEmptyParts);
152 for (
const auto & param : std::as_const(params))
154 QString key = param.section(
'=', 0, 0);
155 QString value = param.section(
'=', 1);
156 QByteArray rawvalue = value.toUtf8();
157 value = QUrl::fromPercentEncoding(rawvalue);
158 value.replace(
"+",
" ");
160 result.insert(key.trimmed().toLower(), value);