getassests cap: be tolerant to mismatch between viewer idea and assets types. we had those very wrong..

This commit is contained in:
UbitUmarov
2021-12-23 17:02:28 +00:00
parent 1791581650
commit eb5912817b

View File

@@ -141,34 +141,27 @@ namespace OpenSim.Capabilities.Handlers
return;
}
int len = asset.Data.Length;
if (len == 0)
{
m_log.Warn("[GETASSET]: asset with empty data: " + assetStr + " type " + asset.Type.ToString());
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
if (asset.Type != (sbyte)type)
{
m_log.Warn("[GETASSET]: asset with wrong type: " + assetStr + " " + asset.Type.ToString() + " != " + ((sbyte)type).ToString());
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
//response.StatusCode = (int)HttpStatusCode.NotFound;
//return;
}
if (asset.Data.Length == 0)
{
m_log.Warn("[GETASSET]: asset with empty data: " + assetStr +" type " + asset.Type.ToString());
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
int len = asset.Data.Length;
string range = null;
if (req.Headers["Range"] != null)
range = req.Headers["Range"];
else if (req.Headers["range"] != null)
range = req.Headers["range"];
// range request
int start, end;
if (Util.TryParseHttpRange(range, out start, out end))
if (Util.TryParseHttpRange(req.Headers["range"], out int start, out int end))
{
// viewers do send broken start, then flag good assets as bad
if (start >= asset.Data.Length)
if (start >= len)
{
//m_log.Warn("[GETASSET]: bad start: " + range);
response.StatusCode = (int)HttpStatusCode.OK;
@@ -176,17 +169,17 @@ namespace OpenSim.Capabilities.Handlers
else
{
if (end == -1)
end = asset.Data.Length - 1;
end = len - 1;
else
end = Utils.Clamp(end, 0, asset.Data.Length - 1);
end = Utils.Clamp(end, 0, len - 1);
start = Utils.Clamp(start, 0, end);
len = end - start + 1;
//m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
response.AddHeader("Content-Range", string.Format("bytes {0}-{1}/{2}", start, end, asset.Data.Length));
response.StatusCode = (int)HttpStatusCode.PartialContent;
response.RawBufferStart = start;
//m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
response.AddHeader("Content-Range", string.Format("bytes {0}-{1}/{2}", start, end, asset.Data.Length));
response.StatusCode = (int)HttpStatusCode.PartialContent;
response.RawBufferStart = start;
}
}
else