Make the asset IN connector return HTTP 404 if an asset is not found, and

also make it return a non-xml content type so a browser can be used
for testing it.
trunk
Melanie Thielker 2009-07-07 17:45:02 +00:00
parent 10d874fb27
commit fe1e9ac5c3
1 changed files with 21 additions and 3 deletions

View File

@ -68,10 +68,16 @@ namespace OpenSim.Server.Handlers.Asset
{ {
result = m_AssetService.GetData(p[0]); result = m_AssetService.GetData(p[0]);
if (result == null) if (result == null)
{
httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
httpResponse.ContentType = "text/plain";
result = new byte[0]; result = new byte[0];
}
httpResponse.StatusCode = (int)HttpStatusCode.OK; else
httpResponse.ContentType = "application/octet-stream"; {
httpResponse.StatusCode = (int)HttpStatusCode.OK;
httpResponse.ContentType = "application/octet-stream";
}
} }
else if (p.Length > 1 && p[1] == "metadata") else if (p.Length > 1 && p[1] == "metadata")
{ {
@ -87,6 +93,12 @@ namespace OpenSim.Server.Handlers.Asset
httpResponse.ContentType = httpResponse.ContentType =
ServerUtils.SLAssetTypeToContentType(metadata.Type); ServerUtils.SLAssetTypeToContentType(metadata.Type);
} }
else
{
httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
httpResponse.ContentType = "text/plain";
result = new byte[0];
}
} }
else else
{ {
@ -101,6 +113,12 @@ namespace OpenSim.Server.Handlers.Asset
httpResponse.ContentType = httpResponse.ContentType =
ServerUtils.SLAssetTypeToContentType(asset.Type); ServerUtils.SLAssetTypeToContentType(asset.Type);
} }
else
{
httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
httpResponse.ContentType = "text/plain";
result = new byte[0];
}
} }
return result; return result;
} }