aboutsummaryrefslogtreecommitdiff
path: root/zenhttp/httpsys.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-03 17:08:32 +0200
committerStefan Boberg <[email protected]>2021-10-03 17:08:32 +0200
commit5f4f5ab05019ff6e903db70f5b15878773eb120d (patch)
treeceae29d6bd090446837ca5a0d336bb921936d95b /zenhttp/httpsys.cpp
parentstructured cache: Added some more stats (hits/misses/upstream_hits) (diff)
parentMerged from upstream (diff)
downloadzen-5f4f5ab05019ff6e903db70f5b15878773eb120d.tar.xz
zen-5f4f5ab05019ff6e903db70f5b15878773eb120d.zip
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zenhttp/httpsys.cpp')
-rw-r--r--zenhttp/httpsys.cpp37
1 files changed, 34 insertions, 3 deletions
diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp
index 9b2e7f832..f4d3e45fe 100644
--- a/zenhttp/httpsys.cpp
+++ b/zenhttp/httpsys.cpp
@@ -1086,6 +1086,8 @@ HttpSysServerRequest::HttpSysServerRequest(HttpSysTransaction& Tx, HttpService&
const int PrefixLength = Service.UriPrefixLength();
const int AbsPathLength = HttpRequestPtr->CookedUrl.AbsPathLength / sizeof(char16_t);
+ HttpContentType AcceptContentType = HttpContentType::kUnknownContentType;
+
if (AbsPathLength >= PrefixLength)
{
// We convert the URI immediately because most of the code involved prefers to deal
@@ -1094,15 +1096,33 @@ HttpSysServerRequest::HttpSysServerRequest(HttpSysTransaction& Tx, HttpService&
WideToUtf8({(char16_t*)HttpRequestPtr->CookedUrl.pAbsPath + PrefixLength, gsl::narrow<size_t>(AbsPathLength - PrefixLength)},
m_UriUtf8);
+
+ std::string_view Uri8{m_UriUtf8};
+
+ const size_t LastComponentIndex = Uri8.find_last_of('/');
+
+ if (LastComponentIndex != std::string_view::npos)
+ {
+ Uri8.remove_prefix(LastComponentIndex);
+ }
+
+ const size_t LastDotIndex = Uri8.find_last_of('.');
+
+ if (LastDotIndex != std::string_view::npos)
+ {
+ Uri8.remove_prefix(LastDotIndex + 1);
+ }
+
+ AcceptContentType = ParseContentType(Uri8);
}
else
{
m_UriUtf8.Reset();
}
- if (auto QueryStringLength = HttpRequestPtr->CookedUrl.QueryStringLength)
+ if (uint16_t QueryStringLength = HttpRequestPtr->CookedUrl.QueryStringLength)
{
- --QueryStringLength;
+ --QueryStringLength; // We skip the leading question mark
WideToUtf8({(char16_t*)(HttpRequestPtr->CookedUrl.pQueryString) + 1, QueryStringLength / sizeof(char16_t)}, m_QueryStringUtf8);
}
@@ -1114,7 +1134,18 @@ HttpSysServerRequest::HttpSysServerRequest(HttpSysTransaction& Tx, HttpService&
m_Verb = TranslateHttpVerb(HttpRequestPtr->Verb);
m_ContentLength = GetContentLength(HttpRequestPtr);
m_ContentType = GetContentType(HttpRequestPtr);
- m_AcceptType = GetAcceptType(HttpRequestPtr);
+
+ // It an explicit content type extension was specified then we'll use that over any
+ // Accept: header value that may be present
+
+ if (AcceptContentType != HttpContentType::kUnknownContentType)
+ {
+ m_AcceptType = AcceptContentType;
+ }
+ else
+ {
+ m_AcceptType = GetAcceptType(HttpRequestPtr);
+ }
}
Oid