From e7c8a0cc4df560335e3df2c6c6d728a19699d066 Mon Sep 17 00:00:00 2001 From: Ciprian Dorin Craciun Date: Fri, 26 Aug 2022 17:42:36 +0300 Subject: [PATCH] [server] Fix resource resolution when using hosts. --- sources/cmd/server/server.go | 45 ++++++++++++++---------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/sources/cmd/server/server.go b/sources/cmd/server/server.go index df06633..8cb2072 100644 --- a/sources/cmd/server/server.go +++ b/sources/cmd/server/server.go @@ -155,13 +155,13 @@ func (_server *server) ServeUnwrapped (_context *fasthttp.RequestCtx) () { var _referencesValues [2]uint64 var _referencesBuffer []byte - if !_referencesFound { + for _hostIdx := 0; _hostIdx < 2; _hostIdx += 1 { - for _hostIdx := 0; _hostIdx < 2; _hostIdx += 1 { - - if (_hostIdx == 0) && _server.hostsDisabled { - continue - } + if (_hostIdx == 0) && _server.hostsDisabled { + continue + } + + if !_referencesFound { for _, _namespace := range _namespaces_a_static { @@ -195,27 +195,16 @@ func (_server *server) ServeUnwrapped (_context *fasthttp.RequestCtx) () { break } } - - if _referencesFound { - break - } } - } - - if !_referencesFound { - if bytes.Equal (StringToBytes ("/favicon.ico"), _path) { - _server.ServeStatic (_context, http.StatusOK, FaviconData, FaviconContentType, FaviconContentEncoding, true) - return - } - } - - if !_referencesFound { - for _hostIdx := 0; _hostIdx < 2; _hostIdx += 1 { - - if (_hostIdx == 0) && _server.hostsDisabled { - continue + if !_referencesFound { + if bytes.Equal (StringToBytes ("/favicon.ico"), _path) { + _server.ServeStatic (_context, http.StatusOK, FaviconData, FaviconContentType, FaviconContentEncoding, true) + return } + } + + if !_referencesFound { for _pathLimit := bytes.LastIndexByte (_path, '/'); @@ -261,10 +250,10 @@ func (_server *server) ServeUnwrapped (_context *fasthttp.RequestCtx) () { break } } - - if _referencesFound { - break - } + } + + if _referencesFound { + break } }