aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Capabilities')
-rw-r--r--OpenSim/Capabilities/Caps.cs13
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs2
-rw-r--r--OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs162
-rw-r--r--OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs225
-rw-r--r--OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs6
-rw-r--r--OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs4
-rw-r--r--OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs15
-rw-r--r--OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs4
-rw-r--r--OpenSim/Capabilities/LLSDAssetUploadComplete.cs3
-rw-r--r--OpenSim/Capabilities/LLSDAssetUploadRequest.cs15
-rw-r--r--OpenSim/Capabilities/LLSDAssetUploadResponse.cs33
11 files changed, 352 insertions, 130 deletions
diff --git a/OpenSim/Capabilities/Caps.cs b/OpenSim/Capabilities/Caps.cs
index bbf3b27..30a323e 100644
--- a/OpenSim/Capabilities/Caps.cs
+++ b/OpenSim/Capabilities/Caps.cs
@@ -30,6 +30,7 @@ using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.IO; 31using System.IO;
32using System.Reflection; 32using System.Reflection;
33using System.Threading;
33using log4net; 34using log4net;
34using Nini.Config; 35using Nini.Config;
35using OpenMetaverse; 36using OpenMetaverse;
@@ -72,6 +73,7 @@ namespace OpenSim.Framework.Capabilities
72 private IHttpServer m_httpListener; 73 private IHttpServer m_httpListener;
73 private UUID m_agentID; 74 private UUID m_agentID;
74 private string m_regionName; 75 private string m_regionName;
76 private ManualResetEvent m_capsActive = new ManualResetEvent(false);
75 77
76 public UUID AgentID 78 public UUID AgentID
77 { 79 {
@@ -252,5 +254,16 @@ namespace OpenSim.Framework.Capabilities
252 254
253 return caps; 255 return caps;
254 } 256 }
257
258 public void Activate()
259 {
260 m_capsActive.Set();
261 }
262
263 public bool WaitForActivation()
264 {
265 // Wait for 30s. If that elapses, return false and run without caps
266 return m_capsActive.WaitOne(30000);
267 }
255 } 268 }
256} \ No newline at end of file 269} \ No newline at end of file
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs
index 2c91328..d1503ee 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs
@@ -97,7 +97,7 @@ namespace OpenSim.Capabilities.Handlers
97 llsdItem.asset_id = invItem.AssetID; 97 llsdItem.asset_id = invItem.AssetID;
98 llsdItem.created_at = invItem.CreationDate; 98 llsdItem.created_at = invItem.CreationDate;
99 llsdItem.desc = invItem.Description; 99 llsdItem.desc = invItem.Description;
100 llsdItem.flags = (int)invItem.Flags; 100 llsdItem.flags = ((int)invItem.Flags) & 0xff;
101 llsdItem.item_id = invItem.ID; 101 llsdItem.item_id = invItem.ID;
102 llsdItem.name = invItem.Name; 102 llsdItem.name = invItem.Name;
103 llsdItem.parent_id = invItem.Folder; 103 llsdItem.parent_id = invItem.Folder;
diff --git a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
index 720640e..ec574a3 100644
--- a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs
@@ -45,16 +45,54 @@ namespace OpenSim.Capabilities.Handlers
45{ 45{
46 public class GetMeshHandler 46 public class GetMeshHandler
47 { 47 {
48// private static readonly ILog m_log = 48 private static readonly ILog m_log =
49// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 private IAssetService m_assetService; 51 private IAssetService m_assetService;
52 52
53 public const string DefaultFormat = "vnd.ll.mesh";
54
53 public GetMeshHandler(IAssetService assService) 55 public GetMeshHandler(IAssetService assService)
54 { 56 {
55 m_assetService = assService; 57 m_assetService = assService;
56 } 58 }
59 public Hashtable Handle(Hashtable request)
60 {
61 Hashtable ret = new Hashtable();
62 ret["int_response_code"] = (int)System.Net.HttpStatusCode.NotFound;
63 ret["content_type"] = "text/plain";
64 ret["keepalive"] = false;
65 ret["reusecontext"] = false;
66 ret["int_bytes"] = 0;
67 ret["int_lod"] = 0;
68 string MeshStr = (string)request["mesh_id"];
69
70
71 //m_log.DebugFormat("[GETMESH]: called {0}", MeshStr);
72
73 if (m_assetService == null)
74 {
75 m_log.Error("[GETMESH]: Cannot fetch mesh " + MeshStr + " without an asset service");
76 }
77
78 UUID meshID;
79 if (!String.IsNullOrEmpty(MeshStr) && UUID.TryParse(MeshStr, out meshID))
80 {
81 // m_log.DebugFormat("[GETMESH]: Received request for mesh id {0}", meshID);
57 82
83
84 ret = ProcessGetMesh(request, UUID.Zero, null);
85
86
87 }
88 else
89 {
90 m_log.Warn("[GETMESH]: Failed to parse a mesh_id from GetMesh request: " + (string)request["uri"]);
91 }
92
93
94 return ret;
95 }
58 public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap) 96 public Hashtable ProcessGetMesh(Hashtable request, UUID AgentId, Caps cap)
59 { 97 {
60 Hashtable responsedata = new Hashtable(); 98 Hashtable responsedata = new Hashtable();
@@ -62,6 +100,9 @@ namespace OpenSim.Capabilities.Handlers
62 responsedata["content_type"] = "text/plain"; 100 responsedata["content_type"] = "text/plain";
63 responsedata["keepalive"] = false; 101 responsedata["keepalive"] = false;
64 responsedata["str_response_string"] = "Request wasn't what was expected"; 102 responsedata["str_response_string"] = "Request wasn't what was expected";
103 responsedata["reusecontext"] = false;
104 responsedata["int_lod"] = 0;
105 responsedata["int_bytes"] = 0;
65 106
66 string meshStr = string.Empty; 107 string meshStr = string.Empty;
67 108
@@ -77,6 +118,7 @@ namespace OpenSim.Capabilities.Handlers
77 responsedata["content_type"] = "text/plain"; 118 responsedata["content_type"] = "text/plain";
78 responsedata["keepalive"] = false; 119 responsedata["keepalive"] = false;
79 responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh."; 120 responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh.";
121 responsedata["reusecontext"] = false;
80 return responsedata; 122 return responsedata;
81 } 123 }
82 124
@@ -86,9 +128,100 @@ namespace OpenSim.Capabilities.Handlers
86 { 128 {
87 if (mesh.Type == (SByte)AssetType.Mesh) 129 if (mesh.Type == (SByte)AssetType.Mesh)
88 { 130 {
89 responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); 131
90 responsedata["content_type"] = "application/vnd.ll.mesh"; 132 Hashtable headers = new Hashtable();
91 responsedata["int_response_code"] = 200; 133 responsedata["headers"] = headers;
134
135 string range = String.Empty;
136
137 if (((Hashtable)request["headers"])["range"] != null)
138 range = (string)((Hashtable)request["headers"])["range"];
139
140 else if (((Hashtable)request["headers"])["Range"] != null)
141 range = (string)((Hashtable)request["headers"])["Range"];
142
143 if (!String.IsNullOrEmpty(range)) // Mesh Asset LOD // Physics
144 {
145 // Range request
146 int start, end;
147 if (TryParseRange(range, out start, out end))
148 {
149 // Before clamping start make sure we can satisfy it in order to avoid
150 // sending back the last byte instead of an error status
151 if (start >= mesh.Data.Length)
152 {
153 responsedata["int_response_code"] = 404; //501; //410; //404;
154 responsedata["content_type"] = "text/plain";
155 responsedata["keepalive"] = false;
156 responsedata["str_response_string"] = "This range doesnt exist.";
157 responsedata["reusecontext"] = false;
158 responsedata["int_lod"] = 3;
159 return responsedata;
160 }
161 else
162 {
163 end = Utils.Clamp(end, 0, mesh.Data.Length - 1);
164 start = Utils.Clamp(start, 0, end);
165 int len = end - start + 1;
166
167 //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
168
169 if (start > 20000)
170 {
171 responsedata["int_lod"] = 3;
172 }
173 else if (start < 4097)
174 {
175 responsedata["int_lod"] = 1;
176 }
177 else
178 {
179 responsedata["int_lod"] = 2;
180 }
181
182
183 if (start == 0 && len == mesh.Data.Length) // well redudante maybe
184 {
185 responsedata["int_response_code"] = (int) System.Net.HttpStatusCode.OK;
186 responsedata["bin_response_data"] = mesh.Data;
187 responsedata["int_bytes"] = mesh.Data.Length;
188 responsedata["reusecontext"] = false;
189 responsedata["int_lod"] = 3;
190
191 }
192 else
193 {
194 responsedata["int_response_code"] =
195 (int) System.Net.HttpStatusCode.PartialContent;
196 headers["Content-Range"] = String.Format("bytes {0}-{1}/{2}", start, end,
197 mesh.Data.Length);
198
199 byte[] d = new byte[len];
200 Array.Copy(mesh.Data, start, d, 0, len);
201 responsedata["bin_response_data"] = d;
202 responsedata["int_bytes"] = len;
203 responsedata["reusecontext"] = false;
204 }
205 }
206 }
207 else
208 {
209 m_log.Warn("[GETMESH]: Failed to parse a range from GetMesh request, sending full asset: " + (string)request["uri"]);
210 responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data);
211 responsedata["content_type"] = "application/vnd.ll.mesh";
212 responsedata["int_response_code"] = 200;
213 responsedata["reusecontext"] = false;
214 responsedata["int_lod"] = 3;
215 }
216 }
217 else
218 {
219 responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data);
220 responsedata["content_type"] = "application/vnd.ll.mesh";
221 responsedata["int_response_code"] = 200;
222 responsedata["reusecontext"] = false;
223 responsedata["int_lod"] = 3;
224 }
92 } 225 }
93 // Optionally add additional mesh types here 226 // Optionally add additional mesh types here
94 else 227 else
@@ -97,6 +230,8 @@ namespace OpenSim.Capabilities.Handlers
97 responsedata["content_type"] = "text/plain"; 230 responsedata["content_type"] = "text/plain";
98 responsedata["keepalive"] = false; 231 responsedata["keepalive"] = false;
99 responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; 232 responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh.";
233 responsedata["reusecontext"] = false;
234 responsedata["int_lod"] = 1;
100 return responsedata; 235 return responsedata;
101 } 236 }
102 } 237 }
@@ -106,11 +241,28 @@ namespace OpenSim.Capabilities.Handlers
106 responsedata["content_type"] = "text/plain"; 241 responsedata["content_type"] = "text/plain";
107 responsedata["keepalive"] = false; 242 responsedata["keepalive"] = false;
108 responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!"; 243 responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!";
244 responsedata["reusecontext"] = false;
245 responsedata["int_lod"] = 0;
109 return responsedata; 246 return responsedata;
110 } 247 }
111 } 248 }
112 249
113 return responsedata; 250 return responsedata;
114 } 251 }
252 private bool TryParseRange(string header, out int start, out int end)
253 {
254 if (header.StartsWith("bytes="))
255 {
256 string[] rangeValues = header.Substring(6).Split('-');
257 if (rangeValues.Length == 2)
258 {
259 if (Int32.TryParse(rangeValues[0], out start) && Int32.TryParse(rangeValues[1], out end))
260 return true;
261 }
262 }
263
264 start = end = 0;
265 return false;
266 }
115 } 267 }
116} \ No newline at end of file 268} \ No newline at end of file
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
index 7b3124a..f3efb53 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
@@ -47,36 +47,36 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
47 47
48namespace OpenSim.Capabilities.Handlers 48namespace OpenSim.Capabilities.Handlers
49{ 49{
50 public class GetTextureHandler : BaseStreamHandler 50 public class GetTextureHandler
51 { 51 {
52 private static readonly ILog m_log = 52 private static readonly ILog m_log =
53 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54
54 private IAssetService m_assetService; 55 private IAssetService m_assetService;
55 56
56 public const string DefaultFormat = "x-j2c"; 57 public const string DefaultFormat = "x-j2c";
57 58
58 // TODO: Change this to a config option 59 public GetTextureHandler(IAssetService assService)
59 const string REDIRECT_URL = null;
60
61 public GetTextureHandler(string path, IAssetService assService, string name, string description)
62 : base("GET", path, name, description)
63 { 60 {
64 m_assetService = assService; 61 m_assetService = assService;
65 } 62 }
66 63
67 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 64 public Hashtable Handle(Hashtable request)
68 { 65 {
69 // Try to parse the texture ID from the request URL 66 Hashtable ret = new Hashtable();
70 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); 67 ret["int_response_code"] = (int)System.Net.HttpStatusCode.NotFound;
71 string textureStr = query.GetOne("texture_id"); 68 ret["content_type"] = "text/plain";
72 string format = query.GetOne("format"); 69 ret["keepalive"] = false;
70 ret["reusecontext"] = false;
71 ret["int_bytes"] = 0;
72 string textureStr = (string)request["texture_id"];
73 string format = (string)request["format"];
73 74
74 //m_log.DebugFormat("[GETTEXTURE]: called {0}", textureStr); 75 //m_log.DebugFormat("[GETTEXTURE]: called {0}", textureStr);
75 76
76 if (m_assetService == null) 77 if (m_assetService == null)
77 { 78 {
78 m_log.Error("[GETTEXTURE]: Cannot fetch texture " + textureStr + " without an asset service"); 79 m_log.Error("[GETTEXTURE]: Cannot fetch texture " + textureStr + " without an asset service");
79 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
80 } 80 }
81 81
82 UUID textureID; 82 UUID textureID;
@@ -91,30 +91,41 @@ namespace OpenSim.Capabilities.Handlers
91 } 91 }
92 else 92 else
93 { 93 {
94 formats = WebUtil.GetPreferredImageTypes(httpRequest.Headers.Get("Accept")); 94 formats = new string[1] { DefaultFormat }; // default
95 if (((Hashtable)request["headers"])["Accept"] != null)
96 formats = WebUtil.GetPreferredImageTypes((string)((Hashtable)request["headers"])["Accept"]);
95 if (formats.Length == 0) 97 if (formats.Length == 0)
96 formats = new string[1] { DefaultFormat }; // default 98 formats = new string[1] { DefaultFormat }; // default
97 99
98 } 100 }
99 // OK, we have an array with preferred formats, possibly with only one entry 101 // OK, we have an array with preferred formats, possibly with only one entry
100 102 bool foundtexture = false;
101 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
102 foreach (string f in formats) 103 foreach (string f in formats)
103 { 104 {
104 if (FetchTexture(httpRequest, httpResponse, textureID, f)) 105 foundtexture = FetchTexture(request, ret, textureID, f);
106 if (foundtexture)
105 break; 107 break;
106 } 108 }
109 if (!foundtexture)
110 {
111 ret["int_response_code"] = 404;
112 ret["error_status_text"] = "not found";
113 ret["str_response_string"] = "not found";
114 ret["content_type"] = "text/plain";
115 ret["keepalive"] = false;
116 ret["reusecontext"] = false;
117 ret["int_bytes"] = 0;
118 }
107 } 119 }
108 else 120 else
109 { 121 {
110 m_log.Warn("[GETTEXTURE]: Failed to parse a texture_id from GetTexture request: " + httpRequest.Url); 122 m_log.Warn("[GETTEXTURE]: Failed to parse a texture_id from GetTexture request: " + (string)request["uri"]);
111 } 123 }
112 124
113// m_log.DebugFormat( 125// m_log.DebugFormat(
114// "[GETTEXTURE]: For texture {0} sending back response {1}, data length {2}", 126// "[GETTEXTURE]: For texture {0} sending back response {1}, data length {2}",
115// textureID, httpResponse.StatusCode, httpResponse.ContentLength); 127// textureID, httpResponse.StatusCode, httpResponse.ContentLength);
116 128 return ret;
117 return null;
118 } 129 }
119 130
120 /// <summary> 131 /// <summary>
@@ -125,7 +136,7 @@ namespace OpenSim.Capabilities.Handlers
125 /// <param name="textureID"></param> 136 /// <param name="textureID"></param>
126 /// <param name="format"></param> 137 /// <param name="format"></param>
127 /// <returns>False for "caller try another codec"; true otherwise</returns> 138 /// <returns>False for "caller try another codec"; true otherwise</returns>
128 private bool FetchTexture(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID textureID, string format) 139 private bool FetchTexture(Hashtable request, Hashtable response, UUID textureID, string format)
129 { 140 {
130// m_log.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format); 141// m_log.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format);
131 AssetBase texture; 142 AssetBase texture;
@@ -134,85 +145,70 @@ namespace OpenSim.Capabilities.Handlers
134 if (format != DefaultFormat) 145 if (format != DefaultFormat)
135 fullID = fullID + "-" + format; 146 fullID = fullID + "-" + format;
136 147
137 if (!String.IsNullOrEmpty(REDIRECT_URL)) 148 // try the cache
149 texture = m_assetService.GetCached(fullID);
150
151 if (texture == null)
138 { 152 {
139 // Only try to fetch locally cached textures. Misses are redirected 153 //m_log.DebugFormat("[GETTEXTURE]: texture was not in the cache");
140 texture = m_assetService.GetCached(fullID); 154
155 // Fetch locally or remotely. Misses return a 404
156 texture = m_assetService.Get(textureID.ToString());
141 157
142 if (texture != null) 158 if (texture != null)
143 { 159 {
144 if (texture.Type != (sbyte)AssetType.Texture) 160 if (texture.Type != (sbyte)AssetType.Texture)
161 return true;
162
163 if (format == DefaultFormat)
145 { 164 {
146 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; 165 WriteTextureData(request, response, texture, format);
147 return true; 166 return true;
148 } 167 }
149 WriteTextureData(httpRequest, httpResponse, texture, format); 168 else
150 }
151 else
152 {
153 string textureUrl = REDIRECT_URL + textureID.ToString();
154 m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl);
155 httpResponse.RedirectLocation = textureUrl;
156 return true;
157 }
158 }
159 else // no redirect
160 {
161 // try the cache
162 texture = m_assetService.GetCached(fullID);
163
164 if (texture == null)
165 {
166// m_log.DebugFormat("[GETTEXTURE]: texture was not in the cache");
167
168 // Fetch locally or remotely. Misses return a 404
169 texture = m_assetService.Get(textureID.ToString());
170
171 if (texture != null)
172 { 169 {
173 if (texture.Type != (sbyte)AssetType.Texture) 170 AssetBase newTexture = new AssetBase(texture.ID + "-" + format, texture.Name, (sbyte)AssetType.Texture, texture.Metadata.CreatorID);
174 { 171 newTexture.Data = ConvertTextureData(texture, format);
175 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; 172 if (newTexture.Data.Length == 0)
176 return true; 173 return false; // !!! Caller try another codec, please!
177 } 174
178 if (format == DefaultFormat) 175 newTexture.Flags = AssetFlags.Collectable;
179 { 176 newTexture.Temporary = true;
180 WriteTextureData(httpRequest, httpResponse, texture, format); 177 newTexture.Local = true;
181 return true; 178 m_assetService.Store(newTexture);
182 } 179 WriteTextureData(request, response, newTexture, format);
183 else 180 return true;
184 {
185 AssetBase newTexture = new AssetBase(texture.ID + "-" + format, texture.Name, (sbyte)AssetType.Texture, texture.Metadata.CreatorID);
186 newTexture.Data = ConvertTextureData(texture, format);
187 if (newTexture.Data.Length == 0)
188 return false; // !!! Caller try another codec, please!
189
190 newTexture.Flags = AssetFlags.Collectable;
191 newTexture.Temporary = true;
192 newTexture.Local = true;
193 m_assetService.Store(newTexture);
194 WriteTextureData(httpRequest, httpResponse, newTexture, format);
195 return true;
196 }
197 } 181 }
198 } 182 }
199 else // it was on the cache 183 }
200 { 184 else // it was on the cache
201// m_log.DebugFormat("[GETTEXTURE]: texture was in the cache"); 185 {
202 WriteTextureData(httpRequest, httpResponse, texture, format); 186 //m_log.DebugFormat("[GETTEXTURE]: texture was in the cache");
203 return true; 187 WriteTextureData(request, response, texture, format);
204 } 188 return true;
205 } 189 }
206 190
191 //response = new Hashtable();
192
193
194 //WriteTextureData(request,response,null,format);
207 // not found 195 // not found
208// m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found"); 196 //m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found");
209 httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound; 197 return false;
210 return true;
211 } 198 }
212 199
213 private void WriteTextureData(IOSHttpRequest request, IOSHttpResponse response, AssetBase texture, string format) 200 private void WriteTextureData(Hashtable request, Hashtable response, AssetBase texture, string format)
214 { 201 {
215 string range = request.Headers.GetOne("Range"); 202 Hashtable headers = new Hashtable();
203 response["headers"] = headers;
204
205 string range = String.Empty;
206
207 if (((Hashtable)request["headers"])["range"] != null)
208 range = (string)((Hashtable)request["headers"])["range"];
209
210 else if (((Hashtable)request["headers"])["Range"] != null)
211 range = (string)((Hashtable)request["headers"])["Range"];
216 212
217 if (!String.IsNullOrEmpty(range)) // JP2's only 213 if (!String.IsNullOrEmpty(range)) // JP2's only
218 { 214 {
@@ -240,10 +236,8 @@ namespace OpenSim.Capabilities.Handlers
240 // However, if we return PartialContent (or OK) instead, the viewer will display that resolution. 236 // However, if we return PartialContent (or OK) instead, the viewer will display that resolution.
241 237
242// response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable; 238// response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable;
243// response.AddHeader("Content-Range", String.Format("bytes */{0}", texture.Data.Length)); 239 // viewers don't seem to handle RequestedRangeNotSatisfiable and keep retrying with same parameters
244// response.StatusCode = (int)System.Net.HttpStatusCode.OK; 240 response["int_response_code"] = (int)System.Net.HttpStatusCode.NotFound;
245 response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
246 response.ContentType = texture.Metadata.ContentType;
247 } 241 }
248 else 242 else
249 { 243 {
@@ -258,41 +252,46 @@ namespace OpenSim.Capabilities.Handlers
258 252
259// m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID); 253// m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
260 254
261 // Always return PartialContent, even if the range covered the entire data length 255 response["content-type"] = texture.Metadata.ContentType;
262 // We were accidentally sending back 404 before in this situation 256
263 // https://issues.apache.org/bugzilla/show_bug.cgi?id=51878 supports sending 206 even if the 257 if (start == 0 && len == texture.Data.Length) // well redudante maybe
264 // entire range is requested, and viewer 3.2.2 (and very probably earlier) seems fine with this. 258 {
265 // 259 response["int_response_code"] = (int)System.Net.HttpStatusCode.OK;
266 // We also do not want to send back OK even if the whole range was satisfiable since this causes 260 response["bin_response_data"] = texture.Data;
267 // HTTP textures on at least Imprudence 1.4.0-beta2 to never display the final texture quality. 261 response["int_bytes"] = texture.Data.Length;
268// if (end > maxEnd) 262 }
269// response.StatusCode = (int)System.Net.HttpStatusCode.OK; 263 else
270// else 264 {
271 response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent; 265 response["int_response_code"] = (int)System.Net.HttpStatusCode.PartialContent;
272 266 headers["Content-Range"] = String.Format("bytes {0}-{1}/{2}", start, end, texture.Data.Length);
273 response.ContentLength = len; 267
274 response.ContentType = texture.Metadata.ContentType; 268 byte[] d = new byte[len];
275 response.AddHeader("Content-Range", String.Format("bytes {0}-{1}/{2}", start, end, texture.Data.Length)); 269 Array.Copy(texture.Data, start, d, 0, len);
276 270 response["bin_response_data"] = d;
277 response.Body.Write(texture.Data, start, len); 271 response["int_bytes"] = len;
272 }
273// response.Body.Write(texture.Data, start, len);
278 } 274 }
279 } 275 }
280 else 276 else
281 { 277 {
282 m_log.Warn("[GETTEXTURE]: Malformed Range header: " + range); 278 m_log.Warn("[GETTEXTURE]: Malformed Range header: " + range);
283 response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; 279 response["int_response_code"] = (int)System.Net.HttpStatusCode.BadRequest;
284 } 280 }
285 } 281 }
286 else // JP2's or other formats 282 else // JP2's or other formats
287 { 283 {
288 // Full content request 284 // Full content request
289 response.StatusCode = (int)System.Net.HttpStatusCode.OK; 285 response["int_response_code"] = (int)System.Net.HttpStatusCode.OK;
290 response.ContentLength = texture.Data.Length;
291 if (format == DefaultFormat) 286 if (format == DefaultFormat)
292 response.ContentType = texture.Metadata.ContentType; 287 response["content_type"] = texture.Metadata.ContentType;
293 else 288 else
294 response.ContentType = "image/" + format; 289 response["content_type"] = "image/" + format;
295 response.Body.Write(texture.Data, 0, texture.Data.Length); 290
291 response["bin_response_data"] = texture.Data;
292 response["int_bytes"] = texture.Data.Length;
293
294// response.Body.Write(texture.Data, 0, texture.Data.Length);
296 } 295 }
297 296
298// if (response.StatusCode < 200 || response.StatusCode > 299) 297// if (response.StatusCode < 200 || response.StatusCode > 299)
@@ -424,4 +423,4 @@ namespace OpenSim.Capabilities.Handlers
424 return null; 423 return null;
425 } 424 }
426 } 425 }
427} \ No newline at end of file 426}
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs
index 71cf033..bf66acb 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs
@@ -33,6 +33,7 @@ using OpenSim.Framework.Servers.HttpServer;
33using OpenSim.Server.Handlers.Base; 33using OpenSim.Server.Handlers.Base;
34using OpenMetaverse; 34using OpenMetaverse;
35 35
36/*
36namespace OpenSim.Capabilities.Handlers 37namespace OpenSim.Capabilities.Handlers
37{ 38{
38 public class GetTextureServerConnector : ServiceConnector 39 public class GetTextureServerConnector : ServiceConnector
@@ -63,7 +64,8 @@ namespace OpenSim.Capabilities.Handlers
63 throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); 64 throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName));
64 65
65 server.AddStreamHandler( 66 server.AddStreamHandler(
66 new GetTextureHandler("/CAPS/GetTexture/" /*+ UUID.Random() */, m_AssetService, "GetTexture", null)); 67 new GetTextureHandler("/CAPS/GetTexture/", m_AssetService, "GetTexture", null));
67 } 68 }
68 } 69 }
69} \ No newline at end of file 70}
71*/
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs
index d4d6d10..217a265 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs
@@ -39,6 +39,7 @@ using OpenSim.Region.Framework.Scenes;
39using OpenSim.Tests.Common; 39using OpenSim.Tests.Common;
40using OpenSim.Tests.Common.Mock; 40using OpenSim.Tests.Common.Mock;
41 41
42/*
42namespace OpenSim.Capabilities.Handlers.GetTexture.Tests 43namespace OpenSim.Capabilities.Handlers.GetTexture.Tests
43{ 44{
44 [TestFixture] 45 [TestFixture]
@@ -60,4 +61,5 @@ namespace OpenSim.Capabilities.Handlers.GetTexture.Tests
60 Assert.That(resp.StatusCode, Is.EqualTo((int)System.Net.HttpStatusCode.NotFound)); 61 Assert.That(resp.StatusCode, Is.EqualTo((int)System.Net.HttpStatusCode.NotFound));
61 } 62 }
62 } 63 }
63} \ No newline at end of file 64}
65*/
diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
index 8849a59..5536564 100644
--- a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
30using System.Collections.Specialized; 31using System.Collections.Specialized;
31using System.Drawing; 32using System.Drawing;
32using System.Drawing.Imaging; 33using System.Drawing.Imaging;
@@ -50,6 +51,7 @@ namespace OpenSim.Capabilities.Handlers
50{ 51{
51 public class UploadBakedTextureHandler 52 public class UploadBakedTextureHandler
52 { 53 {
54
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 56
55 private Caps m_HostCapsObj; 57 private Caps m_HostCapsObj;
@@ -79,9 +81,9 @@ namespace OpenSim.Capabilities.Handlers
79 { 81 {
80 string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; 82 string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
81 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); 83 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
82 84
83 BakedTextureUploader uploader = 85 BakedTextureUploader uploader =
84 new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener); 86 new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_HostCapsObj.AgentID);
85 uploader.OnUpLoad += BakedTextureUploaded; 87 uploader.OnUpLoad += BakedTextureUploaded;
86 88
87 m_HostCapsObj.HttpListener.AddStreamHandler( 89 m_HostCapsObj.HttpListener.AddStreamHandler(
@@ -117,7 +119,7 @@ namespace OpenSim.Capabilities.Handlers
117 /// <param name="data"></param> 119 /// <param name="data"></param>
118 private void BakedTextureUploaded(UUID assetID, byte[] data) 120 private void BakedTextureUploaded(UUID assetID, byte[] data)
119 { 121 {
120// m_log.DebugFormat("[UPLOAD BAKED TEXTURE HANDLER]: Received baked texture {0}", assetID.ToString()); 122 m_log.DebugFormat("[UPLOAD BAKED TEXTURE HANDLER]: Received baked texture {0}", assetID.ToString());
121 123
122 AssetBase asset; 124 AssetBase asset;
123 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString()); 125 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString());
@@ -125,6 +127,7 @@ namespace OpenSim.Capabilities.Handlers
125 asset.Temporary = true; 127 asset.Temporary = true;
126 asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are 128 asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are
127 m_assetService.Store(asset); 129 m_assetService.Store(asset);
130
128 } 131 }
129 } 132 }
130 133
@@ -137,15 +140,19 @@ namespace OpenSim.Capabilities.Handlers
137 private string uploaderPath = String.Empty; 140 private string uploaderPath = String.Empty;
138 private UUID newAssetID; 141 private UUID newAssetID;
139 private IHttpServer httpListener; 142 private IHttpServer httpListener;
143 private UUID AgentId = UUID.Zero;
140 144
141 public BakedTextureUploader(string path, IHttpServer httpServer) 145 public BakedTextureUploader(string path, IHttpServer httpServer, UUID uUID)
142 { 146 {
143 newAssetID = UUID.Random(); 147 newAssetID = UUID.Random();
144 uploaderPath = path; 148 uploaderPath = path;
145 httpListener = httpServer; 149 httpListener = httpServer;
150 AgentId = uUID;
146 // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID); 151 // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID);
147 } 152 }
148 153
154
155
149 /// <summary> 156 /// <summary>
150 /// Handle raw uploaded baked texture data. 157 /// Handle raw uploaded baked texture data.
151 /// </summary> 158 /// </summary>
diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
index 9a6ca86..16e2f2d 100644
--- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
+++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
@@ -411,7 +411,7 @@ namespace OpenSim.Capabilities.Handlers
411 llsdItem.asset_id = invItem.AssetID; 411 llsdItem.asset_id = invItem.AssetID;
412 llsdItem.created_at = invItem.CreationDate; 412 llsdItem.created_at = invItem.CreationDate;
413 llsdItem.desc = invItem.Description; 413 llsdItem.desc = invItem.Description;
414 llsdItem.flags = (int)invItem.Flags; 414 llsdItem.flags = ((int)invItem.Flags) & 0xff;
415 llsdItem.item_id = invItem.ID; 415 llsdItem.item_id = invItem.ID;
416 llsdItem.name = invItem.Name; 416 llsdItem.name = invItem.Name;
417 llsdItem.parent_id = invItem.Folder; 417 llsdItem.parent_id = invItem.Folder;
@@ -435,4 +435,4 @@ namespace OpenSim.Capabilities.Handlers
435 return llsdItem; 435 return llsdItem;
436 } 436 }
437 } 437 }
438} \ No newline at end of file 438}
diff --git a/OpenSim/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs
index ab6cee5..ae8eb09 100644
--- a/OpenSim/Capabilities/LLSDAssetUploadComplete.cs
+++ b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs
@@ -30,12 +30,15 @@ using OpenMetaverse;
30 30
31namespace OpenSim.Framework.Capabilities 31namespace OpenSim.Framework.Capabilities
32{ 32{
33
33 [LLSDType("MAP")] 34 [LLSDType("MAP")]
34 public class LLSDAssetUploadComplete 35 public class LLSDAssetUploadComplete
35 { 36 {
36 public string new_asset = String.Empty; 37 public string new_asset = String.Empty;
37 public UUID new_inventory_item = UUID.Zero; 38 public UUID new_inventory_item = UUID.Zero;
39// public UUID new_texture_folder_id = UUID.Zero;
38 public string state = String.Empty; 40 public string state = String.Empty;
41 public LLSDAssetUploadError error = null;
39 //public bool success = false; 42 //public bool success = false;
40 43
41 public LLSDAssetUploadComplete() 44 public LLSDAssetUploadComplete()
diff --git a/OpenSim/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Capabilities/LLSDAssetUploadRequest.cs
index 6e66f0a..6779cc1 100644
--- a/OpenSim/Capabilities/LLSDAssetUploadRequest.cs
+++ b/OpenSim/Capabilities/LLSDAssetUploadRequest.cs
@@ -31,14 +31,27 @@ using OpenMetaverse;
31namespace OpenSim.Framework.Capabilities 31namespace OpenSim.Framework.Capabilities
32{ 32{
33 [OSDMap] 33 [OSDMap]
34 public class LLSDAssetResource
35 {
36 public OSDArray instance_list = new OSDArray();
37 public OSDArray texture_list = new OSDArray();
38 public OSDArray mesh_list = new OSDArray();
39 public string metric = String.Empty;
40 }
41
42 [OSDMap]
34 public class LLSDAssetUploadRequest 43 public class LLSDAssetUploadRequest
35 { 44 {
36 public string asset_type = String.Empty; 45 public string asset_type = String.Empty;
37 public string description = String.Empty; 46 public string description = String.Empty;
38 public UUID folder_id = UUID.Zero; 47 public UUID folder_id = UUID.Zero;
48 public UUID texture_folder_id = UUID.Zero;
49 public int next_owner_mask = 0;
50 public int group_mask = 0;
51 public int everyone_mask = 0;
39 public string inventory_type = String.Empty; 52 public string inventory_type = String.Empty;
40 public string name = String.Empty; 53 public string name = String.Empty;
41 54 public LLSDAssetResource asset_resources = new LLSDAssetResource();
42 public LLSDAssetUploadRequest() 55 public LLSDAssetUploadRequest()
43 { 56 {
44 } 57 }
diff --git a/OpenSim/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Capabilities/LLSDAssetUploadResponse.cs
index 0d6f7f9..7c4bc97 100644
--- a/OpenSim/Capabilities/LLSDAssetUploadResponse.cs
+++ b/OpenSim/Capabilities/LLSDAssetUploadResponse.cs
@@ -26,20 +26,51 @@
26 */ 26 */
27 27
28using System; 28using System;
29using OpenMetaverse;
29 30
30namespace OpenSim.Framework.Capabilities 31namespace OpenSim.Framework.Capabilities
31{ 32{
32 [OSDMap] 33 [OSDMap]
34 public class LLSDAssetUploadError
35 {
36 public string message = String.Empty;
37 public UUID identifier = UUID.Zero;
38 }
39
40 [OSDMap]
41 public class LLSDAssetUploadResponsePricebrkDown
42 {
43 public int mesh_streaming;
44 public int mesh_physics;
45 public int mesh_instance;
46 public int texture;
47 public int model;
48 }
49
50 [OSDMap]
51 public class LLSDAssetUploadResponseData
52 {
53 public double resource_cost;
54 public double model_streaming_cost;
55 public double simulation_cost;
56 public double physics_cost;
57 public LLSDAssetUploadResponsePricebrkDown upload_price_breakdown = new LLSDAssetUploadResponsePricebrkDown();
58 }
59
60 [OSDMap]
33 public class LLSDAssetUploadResponse 61 public class LLSDAssetUploadResponse
34 { 62 {
35 public string uploader = String.Empty; 63 public string uploader = String.Empty;
36 public string state = String.Empty; 64 public string state = String.Empty;
37 65 public int upload_price = 0;
66 public LLSDAssetUploadResponseData data = null;
67 public LLSDAssetUploadError error = null;
38 public LLSDAssetUploadResponse() 68 public LLSDAssetUploadResponse()
39 { 69 {
40 } 70 }
41 } 71 }
42 72
73
43 [OSDMap] 74 [OSDMap]
44 public class LLSDNewFileAngentInventoryVariablePriceReplyResponse 75 public class LLSDNewFileAngentInventoryVariablePriceReplyResponse
45 { 76 {