From 1a345a720f728438d0884c3ade4aa37d5c994701 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 24 Apr 2023 15:48:55 +0200 Subject: fixed dashboard file serving bug (#255) a recent change which introduced support for specifying accept: implicitly via the file extension in the URI caused fallout in the dashboard which would fail to serve any content because the extension was stripped from the RelativeUri accessor. This change fixes that by retaining a copy of the Uri string view which includes the suffix additionally, in order to test this change with both asio/http.sys paths I made the path used for all tests configurable in zenserver-test which involved pulling in a change from sb/proto which makes testing configuration a bit more flexible --- zenhttp/httpsys.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'zenhttp/httpsys.cpp') diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index 16ec135cd..0f4fe0a6d 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -1232,6 +1232,9 @@ HttpSysServerRequest::HttpSysServerRequest(HttpSysTransaction& Tx, HttpService& std::string_view UriSuffix8{m_UriUtf8}; + m_UriWithExtension = UriSuffix8; // Retain URI with extension for user access + m_Uri = UriSuffix8; + const size_t LastComponentIndex = UriSuffix8.find_last_of('/'); if (LastComponentIndex != std::string_view::npos) @@ -1244,22 +1247,18 @@ HttpSysServerRequest::HttpSysServerRequest(HttpSysTransaction& Tx, HttpService& if (LastDotIndex != std::string_view::npos) { UriSuffix8.remove_prefix(LastDotIndex + 1); + m_Uri.remove_suffix(UriSuffix8.size() + 1); AcceptContentType = ParseContentType(UriSuffix8); - - if (AcceptContentType != HttpContentType::kUnknownContentType) - { - m_UriUtf8.RemoveSuffix((uint32_t)(UriSuffix8.size() + 1)); - } } } else { m_UriUtf8.Reset(); + m_Uri = {}; + m_UriWithExtension = {}; } - m_Uri = std::string_view(m_UriUtf8); - if (uint16_t QueryStringLength = HttpRequestPtr->CookedUrl.QueryStringLength) { --QueryStringLength; // We skip the leading question mark -- cgit v1.2.3