View of /trunk/Utils.cs
Parent Directory
|
Revision Log
Revision 29 -
(download)
(annotate)
Fri Nov 21 03:19:28 2008 UTC (4 years, 5 months ago) by jhurliman
File size: 5933 byte(s)
Fri Nov 21 03:19:28 2008 UTC (4 years, 5 months ago) by jhurliman
File size: 5933 byte(s)
* Replaced AssetType in Metadata with ContentType (MIME type) * Added Logger.cs, HttpServer.cs, and HttpRequestSignature.cs since AssetServer no longer depends on OpenMetaverse.dll * Upgraded to the latest OpenMetaverse which splits OSD off into OpenMetaverse.StructuredData.dll * Force connection pooling off in MySQLStorage backend to attempt to fix resource leak * Added utility methods to convert from SL AssetType to Content-Type and back
/*
* Copyright (c) 2008 Intel Corporation
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -- Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* -- Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* -- Neither the name of the Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Specialized;
using System.Net;
using OpenMetaverse;
namespace AssetServer
{
public static class Utils
{
public static UUID GetAuthToken(HttpListenerRequest request)
{
UUID authToken = UUID.Zero;
string[] authHeader = request.Headers.GetValues("Authorization");
if (authHeader != null && authHeader.Length == 1)
{
// Example header:
// Authorization: OpenGrid 65fda0b5-4446-42f5-b828-aaf644293646
string[] authHeaderParts = authHeader[0].Split(' ');
if (authHeaderParts.Length == 2 && authHeaderParts[0] == "OpenGrid")
UUID.TryParse(authHeaderParts[1], out authToken);
}
if (authToken == UUID.Zero && request.Cookies.Count > 0)
{
// Check for an authToken cookie to logins browser-compatible
Cookie authCookie = request.Cookies["authToken"];
if (authCookie != null)
UUID.TryParse(authCookie.Value, out authToken);
}
return authToken;
}
public static string SLAssetTypeToContentType(int assetType)
{
switch (assetType)
{
case 0:
return "image/jp2";
case 1:
return "application/ogg";
case 2:
return "application/x-metaverse-callingcard";
case 3:
return "application/x-metaverse-landmark";
case 5:
return "application/x-metaverse-clothing";
case 6:
return "application/x-metaverse-primitive";
case 7:
return "application/x-metaverse-notecard";
case 10:
return "application/x-metaverse-lsl";
case 11:
return "application/x-metaverse-lso";
case 12:
return "image/tga";
case 13:
return "application/x-metaverse-bodypart";
case 17:
return "audio/x-wav";
case 19:
return "image/jpeg";
case 20:
return "application/x-metaverse-animation";
case 21:
return "application/x-metaverse-gesture";
case 22:
return "application/x-metaverse-simstate";
default:
return "application/octet-stream";
}
}
public static int ContentTypeToSLAssetType(string contentType)
{
switch (contentType)
{
case "image/jp2":
return 0;
case "application/ogg":
return 1;
case "application/x-metaverse-callingcard":
return 2;
case "application/x-metaverse-landmark":
return 3;
case "application/x-metaverse-clothing":
return 5;
case "application/x-metaverse-primitive":
return 6;
case "application/x-metaverse-notecard":
return 7;
case "application/x-metaverse-lsl":
return 10;
case "application/x-metaverse-lso":
return 11;
case "image/tga":
return 12;
case "application/x-metaverse-bodypart":
return 13;
case "audio/x-wav":
return 17;
case "image/jpeg":
return 19;
case "application/x-metaverse-animation":
return 20;
case "application/x-metaverse-gesture":
return 21;
case "application/x-metaverse-simstate":
return 22;
default:
return -1;
}
}
}
}
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

