diff options
Diffstat (limited to 'OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs')
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index b3a4d61..6437d0b 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | |||
@@ -68,7 +68,7 @@ namespace OpenSim.Capabilities.Handlers | |||
68 | ret["content_type"] = "text/plain"; | 68 | ret["content_type"] = "text/plain"; |
69 | ret["keepalive"] = false; | 69 | ret["keepalive"] = false; |
70 | ret["reusecontext"] = false; | 70 | ret["reusecontext"] = false; |
71 | 71 | ret["int_bytes"] = 0; | |
72 | string textureStr = (string)request["texture_id"]; | 72 | string textureStr = (string)request["texture_id"]; |
73 | string format = (string)request["format"]; | 73 | string format = (string)request["format"]; |
74 | 74 | ||
@@ -200,11 +200,25 @@ namespace OpenSim.Capabilities.Handlers | |||
200 | int start, end; | 200 | int start, end; |
201 | if (TryParseRange(range, out start, out end)) | 201 | if (TryParseRange(range, out start, out end)) |
202 | { | 202 | { |
203 | |||
204 | // Before clamping start make sure we can satisfy it in order to avoid | 203 | // Before clamping start make sure we can satisfy it in order to avoid |
205 | // sending back the last byte instead of an error status | 204 | // sending back the last byte instead of an error status |
206 | if (start >= texture.Data.Length) | 205 | if (start >= texture.Data.Length) |
207 | { | 206 | { |
207 | // m_log.DebugFormat( | ||
208 | // "[GETTEXTURE]: Client requested range for texture {0} starting at {1} but texture has end of {2}", | ||
209 | // texture.ID, start, texture.Data.Length); | ||
210 | |||
211 | // Stricly speaking, as per http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, we should be sending back | ||
212 | // Requested Range Not Satisfiable (416) here. However, it appears that at least recent implementations | ||
213 | // of the Linden Lab viewer (3.2.1 and 3.3.4 and probably earlier), a viewer that has previously | ||
214 | // received a very small texture may attempt to fetch bytes from the server past the | ||
215 | // range of data that it received originally. Whether this happens appears to depend on whether | ||
216 | // the viewer's estimation of how large a request it needs to make for certain discard levels | ||
217 | // (http://wiki.secondlife.com/wiki/Image_System#Discard_Level_and_Mip_Mapping), chiefly discard | ||
218 | // level 2. If this estimate is greater than the total texture size, returning a RequestedRangeNotSatisfiable | ||
219 | // here will cause the viewer to treat the texture as bad and never display the full resolution | ||
220 | // However, if we return PartialContent (or OK) instead, the viewer will display that resolution. | ||
221 | |||
208 | // response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable; | 222 | // response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable; |
209 | // viewers don't seem to handle RequestedRangeNotSatisfiable and keep retrying with same parameters | 223 | // viewers don't seem to handle RequestedRangeNotSatisfiable and keep retrying with same parameters |
210 | response["int_response_code"] = (int)System.Net.HttpStatusCode.NotFound; | 224 | response["int_response_code"] = (int)System.Net.HttpStatusCode.NotFound; |
@@ -215,7 +229,7 @@ namespace OpenSim.Capabilities.Handlers | |||
215 | start = Utils.Clamp(start, 0, end); | 229 | start = Utils.Clamp(start, 0, end); |
216 | int len = end - start + 1; | 230 | int len = end - start + 1; |
217 | 231 | ||
218 | //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID); | 232 | // m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID); |
219 | 233 | ||
220 | response["content-type"] = texture.Metadata.ContentType; | 234 | response["content-type"] = texture.Metadata.ContentType; |
221 | 235 | ||
@@ -223,6 +237,7 @@ namespace OpenSim.Capabilities.Handlers | |||
223 | { | 237 | { |
224 | response["int_response_code"] = (int)System.Net.HttpStatusCode.OK; | 238 | response["int_response_code"] = (int)System.Net.HttpStatusCode.OK; |
225 | response["bin_response_data"] = texture.Data; | 239 | response["bin_response_data"] = texture.Data; |
240 | response["int_bytes"] = texture.Data.Length; | ||
226 | } | 241 | } |
227 | else | 242 | else |
228 | { | 243 | { |
@@ -232,6 +247,7 @@ namespace OpenSim.Capabilities.Handlers | |||
232 | byte[] d = new byte[len]; | 247 | byte[] d = new byte[len]; |
233 | Array.Copy(texture.Data, start, d, 0, len); | 248 | Array.Copy(texture.Data, start, d, 0, len); |
234 | response["bin_response_data"] = d; | 249 | response["bin_response_data"] = d; |
250 | response["int_bytes"] = len; | ||
235 | } | 251 | } |
236 | // response.Body.Write(texture.Data, start, len); | 252 | // response.Body.Write(texture.Data, start, len); |
237 | } | 253 | } |
@@ -252,6 +268,8 @@ namespace OpenSim.Capabilities.Handlers | |||
252 | response["content_type"] = "image/" + format; | 268 | response["content_type"] = "image/" + format; |
253 | 269 | ||
254 | response["bin_response_data"] = texture.Data; | 270 | response["bin_response_data"] = texture.Data; |
271 | response["int_bytes"] = texture.Data.Length; | ||
272 | |||
255 | // response.Body.Write(texture.Data, 0, texture.Data.Length); | 273 | // response.Body.Write(texture.Data, 0, texture.Data.Length); |
256 | } | 274 | } |
257 | 275 | ||