Request header case is ignored

Originally reported against case sensitivity of the Range header
(see issue #387), this fix applies to all request headers (since
according to RFC 7230 all header fields are case-insensitive, see
https://tools.ietf.org/html/rfc7230#section-3.2). However, a
corresponding unit-test was added only for the Range header.
This commit is contained in:
Veloman Yunkan
2020-07-24 12:30:32 +04:00
committed by Matthieu Gautier
parent d8991c5459
commit 3d425f44de
2 changed files with 18 additions and 2 deletions

View File

@ -26,6 +26,8 @@
#include <cstdio>
#include <atomic>
#include "tools/stringTools.h"
namespace kiwix {
static std::atomic_ullong s_requestIndex(0);
@ -96,7 +98,7 @@ MHD_Result RequestContext::fill_header(void *__this, enum MHD_ValueKind kind,
const char *key, const char *value)
{
RequestContext *_this = static_cast<RequestContext*>(__this);
_this->headers[key] = value;
_this->headers[lcAll(key)] = value;
return MHD_YES;
}
@ -178,7 +180,7 @@ std::string RequestContext::get_argument(const std::string& name) const {
}
std::string RequestContext::get_header(const std::string& name) const {
return headers.at(name);
return headers.at(lcAll(name));
}
}