aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJohn Hurliman2010-09-13 11:23:45 -0700
committerJohn Hurliman2010-09-13 11:23:45 -0700
commit5ef2da39d81c038c087b493330497856ed18325d (patch)
treec3244028f171e9805f9faa08651390e1804945b2
parentFix unit test SceneSetupHelpers to load the mock simulation data store (diff)
downloadopensim-SC-5ef2da39d81c038c087b493330497856ed18325d.zip
opensim-SC-5ef2da39d81c038c087b493330497856ed18325d.tar.gz
opensim-SC-5ef2da39d81c038c087b493330497856ed18325d.tar.bz2
opensim-SC-5ef2da39d81c038c087b493330497856ed18325d.tar.xz
* Fixing length calculations for HTTP texture downloads (the end byte is inclusive in Range: headers)
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs10
1 files changed, 6 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
index 8aa87fd..a3238df 100644
--- a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
@@ -187,18 +187,20 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
187 int start, end; 187 int start, end;
188 if (TryParseRange(range, out start, out end)) 188 if (TryParseRange(range, out start, out end))
189 { 189 {
190 end = Utils.Clamp(end, 1, texture.Data.Length); 190 end = Utils.Clamp(end, 1, texture.Data.Length - 1);
191 start = Utils.Clamp(start, 0, end - 1); 191 start = Utils.Clamp(start, 0, end - 1);
192 int len = end - start + 1;
192 193
193 //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID); 194 //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);
194 195
195 if (end - start < texture.Data.Length) 196 if (len < texture.Data.Length)
196 response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent; 197 response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
197 198
198 response.ContentLength = end - start; 199 response.ContentLength = len;
199 response.ContentType = texture.Metadata.ContentType; 200 response.ContentType = texture.Metadata.ContentType;
201 response.AddHeader("Content-Range", String.Format("bytes {0}-{1}/{2}", start, end, texture.Data.Length));
200 202
201 response.Body.Write(texture.Data, start, end - start); 203 response.Body.Write(texture.Data, start, len);
202 } 204 }
203 else 205 else
204 { 206 {