diff options
| author | Stefan Boberg <[email protected]> | 2021-10-05 22:25:53 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-10-05 22:25:53 +0200 |
| commit | 20ac7384f8ca558f1fb933eda846604792240ea0 (patch) | |
| tree | e5c95b422b847af50b77807af916e389fcaf83aa /zenhttp/httpsys.cpp | |
| parent | stats: Mean returns zero when the count is zero (diff) | |
| download | zen-20ac7384f8ca558f1fb933eda846604792240ea0.tar.xz zen-20ac7384f8ca558f1fb933eda846604792240ea0.zip | |
Merged from upstream
Diffstat (limited to 'zenhttp/httpsys.cpp')
| -rw-r--r-- | zenhttp/httpsys.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
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<size_t>(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 { |