From 20ac7384f8ca558f1fb933eda846604792240ea0 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Tue, 5 Oct 2021 22:25:53 +0200 Subject: Merged from upstream --- zenhttp/httpsys.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'zenhttp/httpsys.cpp') diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index fedaf282e..de3069bb8 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -1091,29 +1091,34 @@ HttpSysServerRequest::HttpSysServerRequest(HttpSysTransaction& Tx, HttpService& if (AbsPathLength >= PrefixLength) { // We convert the URI immediately because most of the code involved prefers to deal - // with utf8. This has some performance impact which I'd prefer to avoid but for now - // we just have to live with it + // with utf8. This is overhead which I'd prefer to avoid but for now we just have + // to live with it WideToUtf8({(char16_t*)HttpRequestPtr->CookedUrl.pAbsPath + PrefixLength, gsl::narrow(AbsPathLength - PrefixLength)}, m_UriUtf8); - std::string_view Uri8{m_UriUtf8}; + std::string_view UriSuffix8{m_UriUtf8}; - const size_t LastComponentIndex = Uri8.find_last_of('/'); + const size_t LastComponentIndex = UriSuffix8.find_last_of('/'); if (LastComponentIndex != std::string_view::npos) { - Uri8.remove_prefix(LastComponentIndex); + UriSuffix8.remove_prefix(LastComponentIndex); } - const size_t LastDotIndex = Uri8.find_last_of('.'); + const size_t LastDotIndex = UriSuffix8.find_last_of('.'); if (LastDotIndex != std::string_view::npos) { - Uri8.remove_prefix(LastDotIndex + 1); - } + UriSuffix8.remove_prefix(LastDotIndex + 1); + + AcceptContentType = ParseContentType(UriSuffix8); - AcceptContentType = ParseContentType(Uri8); + if (AcceptContentType != HttpContentType::kUnknownContentType) + { + m_UriUtf8.RemoveSuffix(uint32_t(m_UriUtf8.Size() - LastComponentIndex - LastDotIndex - 1)); + } + } } else { -- cgit v1.2.3