Allow earlier return in files server
This commit is contained in:
@ -112,7 +112,7 @@ namespace Oqtane.Pages
|
||||
|
||||
url += Request.QueryString.Value.Substring(1);
|
||||
}
|
||||
|
||||
|
||||
return RedirectPermanent(url);
|
||||
}
|
||||
|
||||
@ -137,6 +137,34 @@ namespace Oqtane.Pages
|
||||
string downloadName = file.Name;
|
||||
string filepath = _files.GetFilePath(file);
|
||||
|
||||
if (Request.QueryString.HasValue)
|
||||
{
|
||||
etag = Utilities.GenerateSimpleHash(Request.QueryString.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
etag = Convert.ToString(file.ModifiedOn.Ticks ^ file.Size, 16);
|
||||
}
|
||||
|
||||
var header = "";
|
||||
if (HttpContext.Request.Headers.TryGetValue(HeaderNames.IfNoneMatch, out var ifNoneMatch))
|
||||
{
|
||||
header = ifNoneMatch.ToString();
|
||||
}
|
||||
|
||||
if (header.Equals(etag))
|
||||
{
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.NotModified;
|
||||
return Content(String.Empty);
|
||||
}
|
||||
|
||||
if (!System.IO.File.Exists(filepath))
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "File Does Not Exist {FilePath}", filepath);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
return BrokenFile();
|
||||
}
|
||||
|
||||
// evaluate any querystring parameters
|
||||
bool isRequestingImageManipulation = false;
|
||||
|
||||
@ -165,34 +193,6 @@ namespace Oqtane.Pages
|
||||
isRequestingImageManipulation = true;
|
||||
}
|
||||
|
||||
if (isRequestingImageManipulation)
|
||||
{
|
||||
etag = Utilities.GenerateSimpleHash(Request.QueryString.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
etag = Convert.ToString(file.ModifiedOn.Ticks ^ file.Size, 16);
|
||||
}
|
||||
|
||||
var header = "";
|
||||
if (HttpContext.Request.Headers.TryGetValue(HeaderNames.IfNoneMatch, out var ifNoneMatch))
|
||||
{
|
||||
header = ifNoneMatch.ToString();
|
||||
}
|
||||
|
||||
if (header.Equals(etag))
|
||||
{
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.NotModified;
|
||||
return Content(String.Empty);
|
||||
}
|
||||
|
||||
if (!System.IO.File.Exists(filepath))
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Read, "File Does Not Exist {FilePath}", filepath);
|
||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
return BrokenFile();
|
||||
}
|
||||
|
||||
if (isRequestingImageManipulation)
|
||||
{
|
||||
var _ImageFiles = _settingRepository.GetSetting(EntityNames.Site, _alias.SiteId, "ImageFiles")?.SettingValue;
|
||||
|
Reference in New Issue
Block a user