diff options
Diffstat (limited to 'OpenSim/Framework')
19 files changed, 549 insertions, 367 deletions
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index c5d6b78..87bdacd 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs | |||
@@ -79,7 +79,11 @@ namespace OpenSim.Framework.Console | |||
79 | public List<CommandDelegate> fn; | 79 | public List<CommandDelegate> fn; |
80 | } | 80 | } |
81 | 81 | ||
82 | public const string GeneralHelpText = "For more information, type 'help <item>' where <item> is one of the following categories:"; | 82 | public const string GeneralHelpText |
83 | = "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n"; | ||
84 | |||
85 | public const string ItemHelpText | ||
86 | = "For more information, type 'help <item>' where <item> is one of the following:"; | ||
83 | 87 | ||
84 | /// <value> | 88 | /// <value> |
85 | /// Commands organized by keyword in a tree | 89 | /// Commands organized by keyword in a tree |
@@ -108,7 +112,9 @@ namespace OpenSim.Framework.Console | |||
108 | // General help | 112 | // General help |
109 | if (helpParts.Count == 0) | 113 | if (helpParts.Count == 0) |
110 | { | 114 | { |
115 | help.Add(""); // Will become a newline. | ||
111 | help.Add(GeneralHelpText); | 116 | help.Add(GeneralHelpText); |
117 | help.Add(ItemHelpText); | ||
112 | help.AddRange(CollectModulesHelp(tree)); | 118 | help.AddRange(CollectModulesHelp(tree)); |
113 | } | 119 | } |
114 | else | 120 | else |
@@ -132,7 +138,7 @@ namespace OpenSim.Framework.Console | |||
132 | // Check modules first to see if we just need to display a list of those commands | 138 | // Check modules first to see if we just need to display a list of those commands |
133 | if (TryCollectModuleHelp(originalHelpRequest, help)) | 139 | if (TryCollectModuleHelp(originalHelpRequest, help)) |
134 | { | 140 | { |
135 | help.Insert(0, GeneralHelpText); | 141 | help.Insert(0, ItemHelpText); |
136 | return help; | 142 | return help; |
137 | } | 143 | } |
138 | 144 | ||
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index 7c8626d..f65813b 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs | |||
@@ -296,6 +296,10 @@ namespace OpenSim.Framework.Console | |||
296 | matches[0].Groups["Category"].Value); | 296 | matches[0].Groups["Category"].Value); |
297 | System.Console.Write("]:"); | 297 | System.Console.Write("]:"); |
298 | } | 298 | } |
299 | else | ||
300 | { | ||
301 | outText = outText.Trim(); | ||
302 | } | ||
299 | } | 303 | } |
300 | 304 | ||
301 | if (level == "error") | 305 | if (level == "error") |
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 142b783..9020761 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs | |||
@@ -346,7 +346,7 @@ namespace OpenSim.Framework | |||
346 | l_EstateManagers.Remove(avatarID); | 346 | l_EstateManagers.Remove(avatarID); |
347 | } | 347 | } |
348 | 348 | ||
349 | public bool IsEstateManager(UUID avatarID) | 349 | public bool IsEstateManagerOrOwner(UUID avatarID) |
350 | { | 350 | { |
351 | if (IsEstateOwner(avatarID)) | 351 | if (IsEstateOwner(avatarID)) |
352 | return true; | 352 | return true; |
@@ -368,7 +368,7 @@ namespace OpenSim.Framework | |||
368 | if (ban.BannedUserID == avatarID) | 368 | if (ban.BannedUserID == avatarID) |
369 | return true; | 369 | return true; |
370 | 370 | ||
371 | if (!IsEstateManager(avatarID) && !HasAccess(avatarID)) | 371 | if (!IsEstateManagerOrOwner(avatarID) && !HasAccess(avatarID)) |
372 | { | 372 | { |
373 | if (DenyMinors) | 373 | if (DenyMinors) |
374 | { | 374 | { |
@@ -411,7 +411,7 @@ namespace OpenSim.Framework | |||
411 | 411 | ||
412 | public bool HasAccess(UUID user) | 412 | public bool HasAccess(UUID user) |
413 | { | 413 | { |
414 | if (IsEstateManager(user)) | 414 | if (IsEstateManagerOrOwner(user)) |
415 | return true; | 415 | return true; |
416 | 416 | ||
417 | return l_EstateAccess.Contains(user); | 417 | return l_EstateAccess.Contains(user); |
diff --git a/OpenSim/Framework/OSChatMessage.cs b/OpenSim/Framework/OSChatMessage.cs index 54fa275..455756d 100644 --- a/OpenSim/Framework/OSChatMessage.cs +++ b/OpenSim/Framework/OSChatMessage.cs | |||
@@ -51,10 +51,12 @@ namespace OpenSim.Framework | |||
51 | protected object m_senderObject; | 51 | protected object m_senderObject; |
52 | protected ChatTypeEnum m_type; | 52 | protected ChatTypeEnum m_type; |
53 | protected UUID m_fromID; | 53 | protected UUID m_fromID; |
54 | protected UUID m_toID; | ||
54 | 55 | ||
55 | public OSChatMessage() | 56 | public OSChatMessage() |
56 | { | 57 | { |
57 | m_position = new Vector3(); | 58 | m_position = new Vector3(); |
59 | m_toID = UUID.Zero; | ||
58 | } | 60 | } |
59 | 61 | ||
60 | /// <summary> | 62 | /// <summary> |
@@ -102,6 +104,15 @@ namespace OpenSim.Framework | |||
102 | set { m_from = value; } | 104 | set { m_from = value; } |
103 | } | 105 | } |
104 | 106 | ||
107 | /// <summary> | ||
108 | /// The name of the sender (needed for scripts) | ||
109 | /// </summary> | ||
110 | public string To | ||
111 | { | ||
112 | get { return m_from; } | ||
113 | set { m_from = value; } | ||
114 | } | ||
115 | |||
105 | #region IEventArgs Members | 116 | #region IEventArgs Members |
106 | 117 | ||
107 | /// TODO: Sender and SenderObject should just be Sender and of | 118 | /// TODO: Sender and SenderObject should just be Sender and of |
@@ -132,6 +143,15 @@ namespace OpenSim.Framework | |||
132 | } | 143 | } |
133 | 144 | ||
134 | /// <summary> | 145 | /// <summary> |
146 | /// The single recipient or all if not set. | ||
147 | /// </summary> | ||
148 | public UUID TargetUUID | ||
149 | { | ||
150 | get { return m_toID; } | ||
151 | set { m_toID = value; } | ||
152 | } | ||
153 | |||
154 | /// <summary> | ||
135 | /// | 155 | /// |
136 | /// </summary> | 156 | /// </summary> |
137 | public IScene Scene | 157 | public IScene Scene |
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index c6ccc9e..fcc9873 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs | |||
@@ -241,10 +241,14 @@ namespace OpenSim.Framework | |||
241 | 241 | ||
242 | m_textureEntry = prim.Textures.GetBytes(); | 242 | m_textureEntry = prim.Textures.GetBytes(); |
243 | 243 | ||
244 | SculptEntry = (prim.Sculpt.Type != OpenMetaverse.SculptType.None); | 244 | if (prim.Sculpt != null) |
245 | SculptData = prim.Sculpt.GetBytes(); | 245 | { |
246 | SculptTexture = prim.Sculpt.SculptTexture; | 246 | SculptEntry = (prim.Sculpt.Type != OpenMetaverse.SculptType.None); |
247 | SculptType = (byte)prim.Sculpt.Type; | 247 | SculptData = prim.Sculpt.GetBytes(); |
248 | SculptTexture = prim.Sculpt.SculptTexture; | ||
249 | SculptType = (byte)prim.Sculpt.Type; | ||
250 | } | ||
251 | else SculptType = (byte)OpenMetaverse.SculptType.None; | ||
248 | } | 252 | } |
249 | 253 | ||
250 | [XmlIgnore] | 254 | [XmlIgnore] |
diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index db4541e..537de7a 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs | |||
@@ -38,239 +38,189 @@ namespace OpenSim.Framework | |||
38 | public static class SLUtil | 38 | public static class SLUtil |
39 | { | 39 | { |
40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
42 | #region SL / file extension / content-type conversions | 42 | #region SL / file extension / content-type conversions |
43 | 43 | ||
44 | public static string SLAssetTypeToContentType(int assetType) | 44 | private class TypeMapping |
45 | { | 45 | { |
46 | switch ((AssetType)assetType) | 46 | private sbyte assetType; |
47 | private InventoryType inventoryType; | ||
48 | private string contentType; | ||
49 | private string contentType2; | ||
50 | private string extension; | ||
51 | |||
52 | public sbyte AssetTypeCode | ||
53 | { | ||
54 | get { return assetType; } | ||
55 | } | ||
56 | |||
57 | public object AssetType | ||
58 | { | ||
59 | get { | ||
60 | if (Enum.IsDefined(typeof(OpenMetaverse.AssetType), assetType)) | ||
61 | return (OpenMetaverse.AssetType)assetType; | ||
62 | else | ||
63 | return OpenMetaverse.AssetType.Unknown; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | public InventoryType InventoryType | ||
68 | { | ||
69 | get { return inventoryType; } | ||
70 | } | ||
71 | |||
72 | public string ContentType | ||
73 | { | ||
74 | get { return contentType; } | ||
75 | } | ||
76 | |||
77 | public string ContentType2 | ||
78 | { | ||
79 | get { return contentType2; } | ||
80 | } | ||
81 | |||
82 | public string Extension | ||
83 | { | ||
84 | get { return extension; } | ||
85 | } | ||
86 | |||
87 | private TypeMapping(sbyte assetType, InventoryType inventoryType, string contentType, string contentType2, string extension) | ||
88 | { | ||
89 | this.assetType = assetType; | ||
90 | this.inventoryType = inventoryType; | ||
91 | this.contentType = contentType; | ||
92 | this.contentType2 = contentType2; | ||
93 | this.extension = extension; | ||
94 | } | ||
95 | |||
96 | public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string contentType2, string extension) | ||
97 | : this((sbyte)assetType, inventoryType, contentType, contentType2, extension) | ||
98 | { | ||
99 | } | ||
100 | |||
101 | public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string extension) | ||
102 | : this((sbyte)assetType, inventoryType, contentType, null, extension) | ||
47 | { | 103 | { |
48 | case AssetType.Texture: | ||
49 | return "image/x-j2c"; | ||
50 | case AssetType.Sound: | ||
51 | return "audio/ogg"; | ||
52 | case AssetType.CallingCard: | ||
53 | return "application/vnd.ll.callingcard"; | ||
54 | case AssetType.Landmark: | ||
55 | return "application/vnd.ll.landmark"; | ||
56 | case AssetType.Clothing: | ||
57 | return "application/vnd.ll.clothing"; | ||
58 | case AssetType.Object: | ||
59 | return "application/vnd.ll.primitive"; | ||
60 | case AssetType.Notecard: | ||
61 | return "application/vnd.ll.notecard"; | ||
62 | case AssetType.Folder: | ||
63 | return "application/vnd.ll.folder"; | ||
64 | case AssetType.RootFolder: | ||
65 | return "application/vnd.ll.rootfolder"; | ||
66 | case AssetType.LSLText: | ||
67 | return "application/vnd.ll.lsltext"; | ||
68 | case AssetType.LSLBytecode: | ||
69 | return "application/vnd.ll.lslbyte"; | ||
70 | case AssetType.TextureTGA: | ||
71 | case AssetType.ImageTGA: | ||
72 | return "image/tga"; | ||
73 | case AssetType.Bodypart: | ||
74 | return "application/vnd.ll.bodypart"; | ||
75 | case AssetType.TrashFolder: | ||
76 | return "application/vnd.ll.trashfolder"; | ||
77 | case AssetType.SnapshotFolder: | ||
78 | return "application/vnd.ll.snapshotfolder"; | ||
79 | case AssetType.LostAndFoundFolder: | ||
80 | return "application/vnd.ll.lostandfoundfolder"; | ||
81 | case AssetType.SoundWAV: | ||
82 | return "audio/x-wav"; | ||
83 | case AssetType.ImageJPEG: | ||
84 | return "image/jpeg"; | ||
85 | case AssetType.Animation: | ||
86 | return "application/vnd.ll.animation"; | ||
87 | case AssetType.Gesture: | ||
88 | return "application/vnd.ll.gesture"; | ||
89 | case AssetType.Simstate: | ||
90 | return "application/x-metaverse-simstate"; | ||
91 | case AssetType.FavoriteFolder: | ||
92 | return "application/vnd.ll.favoritefolder"; | ||
93 | case AssetType.Link: | ||
94 | return "application/vnd.ll.link"; | ||
95 | case AssetType.LinkFolder: | ||
96 | return "application/vnd.ll.linkfolder"; | ||
97 | case AssetType.CurrentOutfitFolder: | ||
98 | return "application/vnd.ll.currentoutfitfolder"; | ||
99 | case AssetType.OutfitFolder: | ||
100 | return "application/vnd.ll.outfitfolder"; | ||
101 | case AssetType.MyOutfitsFolder: | ||
102 | return "application/vnd.ll.myoutfitsfolder"; | ||
103 | case AssetType.Unknown: | ||
104 | default: | ||
105 | return "application/octet-stream"; | ||
106 | } | 104 | } |
107 | } | 105 | } |
108 | 106 | ||
109 | public static string SLInvTypeToContentType(int invType) | 107 | /// <summary> |
108 | /// Maps between AssetType, InventoryType and Content-Type. | ||
109 | /// Where more than one possibility exists, the first one takes precedence. E.g.: | ||
110 | /// AssetType "AssetType.Texture" -> Content-Type "image-xj2c" | ||
111 | /// Content-Type "image/x-j2c" -> InventoryType "InventoryType.Texture" | ||
112 | /// </summary> | ||
113 | private static TypeMapping[] MAPPINGS = new TypeMapping[] { | ||
114 | new TypeMapping(AssetType.Unknown, InventoryType.Unknown, "application/octet-stream", "bin"), | ||
115 | new TypeMapping(AssetType.Texture, InventoryType.Texture, "image/x-j2c", "image/jp2", "j2c"), | ||
116 | new TypeMapping(AssetType.Texture, InventoryType.Snapshot, "image/x-j2c", "image/jp2", "j2c"), | ||
117 | new TypeMapping(AssetType.TextureTGA, InventoryType.Texture, "image/tga", "tga"), | ||
118 | new TypeMapping(AssetType.ImageTGA, InventoryType.Texture, "image/tga", "tga"), | ||
119 | new TypeMapping(AssetType.ImageJPEG, InventoryType.Texture, "image/jpeg", "jpg"), | ||
120 | new TypeMapping(AssetType.Sound, InventoryType.Sound, "audio/ogg", "application/ogg", "ogg"), | ||
121 | new TypeMapping(AssetType.SoundWAV, InventoryType.Sound, "audio/x-wav", "wav"), | ||
122 | new TypeMapping(AssetType.CallingCard, InventoryType.CallingCard, "application/vnd.ll.callingcard", "application/x-metaverse-callingcard", "callingcard"), | ||
123 | new TypeMapping(AssetType.Landmark, InventoryType.Landmark, "application/vnd.ll.landmark", "application/x-metaverse-landmark", "landmark"), | ||
124 | new TypeMapping(AssetType.Clothing, InventoryType.Wearable, "application/vnd.ll.clothing", "application/x-metaverse-clothing", "clothing"), | ||
125 | new TypeMapping(AssetType.Object, InventoryType.Object, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), | ||
126 | new TypeMapping(AssetType.Object, InventoryType.Attachment, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), | ||
127 | new TypeMapping(AssetType.Notecard, InventoryType.Notecard, "application/vnd.ll.notecard", "application/x-metaverse-notecard", "notecard"), | ||
128 | new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"), | ||
129 | new TypeMapping(AssetType.RootFolder, InventoryType.RootCategory, "application/vnd.ll.rootfolder", "rootfolder"), | ||
130 | new TypeMapping(AssetType.LSLText, InventoryType.LSL, "application/vnd.ll.lsltext", "application/x-metaverse-lsl", "lsl"), | ||
131 | new TypeMapping(AssetType.LSLBytecode, InventoryType.LSL, "application/vnd.ll.lslbyte", "application/x-metaverse-lso", "lso"), | ||
132 | new TypeMapping(AssetType.Bodypart, InventoryType.Wearable, "application/vnd.ll.bodypart", "application/x-metaverse-bodypart", "bodypart"), | ||
133 | new TypeMapping(AssetType.TrashFolder, InventoryType.Folder, "application/vnd.ll.trashfolder", "trashfolder"), | ||
134 | new TypeMapping(AssetType.SnapshotFolder, InventoryType.Folder, "application/vnd.ll.snapshotfolder", "snapshotfolder"), | ||
135 | new TypeMapping(AssetType.LostAndFoundFolder, InventoryType.Folder, "application/vnd.ll.lostandfoundfolder", "lostandfoundfolder"), | ||
136 | new TypeMapping(AssetType.Animation, InventoryType.Animation, "application/vnd.ll.animation", "application/x-metaverse-animation", "animation"), | ||
137 | new TypeMapping(AssetType.Gesture, InventoryType.Gesture, "application/vnd.ll.gesture", "application/x-metaverse-gesture", "gesture"), | ||
138 | new TypeMapping(AssetType.Simstate, InventoryType.Snapshot, "application/x-metaverse-simstate", "simstate"), | ||
139 | new TypeMapping(AssetType.FavoriteFolder, InventoryType.Unknown, "application/vnd.ll.favoritefolder", "favoritefolder"), | ||
140 | new TypeMapping(AssetType.Link, InventoryType.Unknown, "application/vnd.ll.link", "link"), | ||
141 | new TypeMapping(AssetType.LinkFolder, InventoryType.Unknown, "application/vnd.ll.linkfolder", "linkfolder"), | ||
142 | new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"), | ||
143 | new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"), | ||
144 | new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"), | ||
145 | new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm") | ||
146 | }; | ||
147 | |||
148 | private static Dictionary<sbyte, string> asset2Content; | ||
149 | private static Dictionary<sbyte, string> asset2Extension; | ||
150 | private static Dictionary<InventoryType, string> inventory2Content; | ||
151 | private static Dictionary<string, sbyte> content2Asset; | ||
152 | private static Dictionary<string, InventoryType> content2Inventory; | ||
153 | |||
154 | static SLUtil() | ||
110 | { | 155 | { |
111 | switch ((InventoryType)invType) | 156 | asset2Content = new Dictionary<sbyte, string>(); |
157 | asset2Extension = new Dictionary<sbyte, string>(); | ||
158 | inventory2Content = new Dictionary<InventoryType, string>(); | ||
159 | content2Asset = new Dictionary<string, sbyte>(); | ||
160 | content2Inventory = new Dictionary<string, InventoryType>(); | ||
161 | |||
162 | foreach (TypeMapping mapping in MAPPINGS) | ||
112 | { | 163 | { |
113 | case InventoryType.Animation: | 164 | sbyte assetType = mapping.AssetTypeCode; |
114 | return "application/vnd.ll.animation"; | 165 | if (!asset2Content.ContainsKey(assetType)) |
115 | case InventoryType.CallingCard: | 166 | asset2Content.Add(assetType, mapping.ContentType); |
116 | return "application/vnd.ll.callingcard"; | 167 | if (!asset2Extension.ContainsKey(assetType)) |
117 | case InventoryType.Folder: | 168 | asset2Extension.Add(assetType, mapping.Extension); |
118 | return "application/vnd.ll.folder"; | 169 | if (!inventory2Content.ContainsKey(mapping.InventoryType)) |
119 | case InventoryType.Gesture: | 170 | inventory2Content.Add(mapping.InventoryType, mapping.ContentType); |
120 | return "application/vnd.ll.gesture"; | 171 | if (!content2Asset.ContainsKey(mapping.ContentType)) |
121 | case InventoryType.Landmark: | 172 | content2Asset.Add(mapping.ContentType, assetType); |
122 | return "application/vnd.ll.landmark"; | 173 | if (!content2Inventory.ContainsKey(mapping.ContentType)) |
123 | case InventoryType.LSL: | 174 | content2Inventory.Add(mapping.ContentType, mapping.InventoryType); |
124 | return "application/vnd.ll.lsltext"; | 175 | |
125 | case InventoryType.Notecard: | 176 | if (mapping.ContentType2 != null) |
126 | return "application/vnd.ll.notecard"; | 177 | { |
127 | case InventoryType.Attachment: | 178 | if (!content2Asset.ContainsKey(mapping.ContentType2)) |
128 | case InventoryType.Object: | 179 | content2Asset.Add(mapping.ContentType2, assetType); |
129 | return "application/vnd.ll.primitive"; | 180 | if (!content2Inventory.ContainsKey(mapping.ContentType2)) |
130 | case InventoryType.Sound: | 181 | content2Inventory.Add(mapping.ContentType2, mapping.InventoryType); |
131 | return "audio/ogg"; | 182 | } |
132 | case InventoryType.Snapshot: | ||
133 | case InventoryType.Texture: | ||
134 | return "image/x-j2c"; | ||
135 | case InventoryType.Wearable: | ||
136 | return "application/vnd.ll.clothing"; | ||
137 | default: | ||
138 | return "application/octet-stream"; | ||
139 | } | 183 | } |
140 | } | 184 | } |
185 | |||
186 | public static string SLAssetTypeToContentType(int assetType) | ||
187 | { | ||
188 | string contentType; | ||
189 | if (!asset2Content.TryGetValue((sbyte)assetType, out contentType)) | ||
190 | contentType = asset2Content[(sbyte)AssetType.Unknown]; | ||
191 | return contentType; | ||
192 | } | ||
193 | |||
194 | public static string SLInvTypeToContentType(int invType) | ||
195 | { | ||
196 | string contentType; | ||
197 | if (!inventory2Content.TryGetValue((InventoryType)invType, out contentType)) | ||
198 | contentType = inventory2Content[InventoryType.Unknown]; | ||
199 | return contentType; | ||
200 | } | ||
141 | 201 | ||
142 | public static sbyte ContentTypeToSLAssetType(string contentType) | 202 | public static sbyte ContentTypeToSLAssetType(string contentType) |
143 | { | 203 | { |
144 | switch (contentType) | 204 | sbyte assetType; |
145 | { | 205 | if (!content2Asset.TryGetValue(contentType, out assetType)) |
146 | case "image/x-j2c": | 206 | assetType = (sbyte)AssetType.Unknown; |
147 | case "image/jp2": | 207 | return (sbyte)assetType; |
148 | return (sbyte)AssetType.Texture; | ||
149 | case "application/ogg": | ||
150 | case "audio/ogg": | ||
151 | return (sbyte)AssetType.Sound; | ||
152 | case "application/vnd.ll.callingcard": | ||
153 | case "application/x-metaverse-callingcard": | ||
154 | return (sbyte)AssetType.CallingCard; | ||
155 | case "application/vnd.ll.landmark": | ||
156 | case "application/x-metaverse-landmark": | ||
157 | return (sbyte)AssetType.Landmark; | ||
158 | case "application/vnd.ll.clothing": | ||
159 | case "application/x-metaverse-clothing": | ||
160 | return (sbyte)AssetType.Clothing; | ||
161 | case "application/vnd.ll.primitive": | ||
162 | case "application/x-metaverse-primitive": | ||
163 | return (sbyte)AssetType.Object; | ||
164 | case "application/vnd.ll.notecard": | ||
165 | case "application/x-metaverse-notecard": | ||
166 | return (sbyte)AssetType.Notecard; | ||
167 | case "application/vnd.ll.folder": | ||
168 | return (sbyte)AssetType.Folder; | ||
169 | case "application/vnd.ll.rootfolder": | ||
170 | return (sbyte)AssetType.RootFolder; | ||
171 | case "application/vnd.ll.lsltext": | ||
172 | case "application/x-metaverse-lsl": | ||
173 | return (sbyte)AssetType.LSLText; | ||
174 | case "application/vnd.ll.lslbyte": | ||
175 | case "application/x-metaverse-lso": | ||
176 | return (sbyte)AssetType.LSLBytecode; | ||
177 | case "image/tga": | ||
178 | // Note that AssetType.TextureTGA will be converted to AssetType.ImageTGA | ||
179 | return (sbyte)AssetType.ImageTGA; | ||
180 | case "application/vnd.ll.bodypart": | ||
181 | case "application/x-metaverse-bodypart": | ||
182 | return (sbyte)AssetType.Bodypart; | ||
183 | case "application/vnd.ll.trashfolder": | ||
184 | return (sbyte)AssetType.TrashFolder; | ||
185 | case "application/vnd.ll.snapshotfolder": | ||
186 | return (sbyte)AssetType.SnapshotFolder; | ||
187 | case "application/vnd.ll.lostandfoundfolder": | ||
188 | return (sbyte)AssetType.LostAndFoundFolder; | ||
189 | case "audio/x-wav": | ||
190 | return (sbyte)AssetType.SoundWAV; | ||
191 | case "image/jpeg": | ||
192 | return (sbyte)AssetType.ImageJPEG; | ||
193 | case "application/vnd.ll.animation": | ||
194 | case "application/x-metaverse-animation": | ||
195 | return (sbyte)AssetType.Animation; | ||
196 | case "application/vnd.ll.gesture": | ||
197 | case "application/x-metaverse-gesture": | ||
198 | return (sbyte)AssetType.Gesture; | ||
199 | case "application/x-metaverse-simstate": | ||
200 | return (sbyte)AssetType.Simstate; | ||
201 | case "application/vnd.ll.favoritefolder": | ||
202 | return (sbyte)AssetType.FavoriteFolder; | ||
203 | case "application/vnd.ll.link": | ||
204 | return (sbyte)AssetType.Link; | ||
205 | case "application/vnd.ll.linkfolder": | ||
206 | return (sbyte)AssetType.LinkFolder; | ||
207 | case "application/vnd.ll.currentoutfitfolder": | ||
208 | return (sbyte)AssetType.CurrentOutfitFolder; | ||
209 | case "application/vnd.ll.outfitfolder": | ||
210 | return (sbyte)AssetType.OutfitFolder; | ||
211 | case "application/vnd.ll.myoutfitsfolder": | ||
212 | return (sbyte)AssetType.MyOutfitsFolder; | ||
213 | case "application/octet-stream": | ||
214 | default: | ||
215 | return (sbyte)AssetType.Unknown; | ||
216 | } | ||
217 | } | 208 | } |
218 | 209 | ||
219 | public static sbyte ContentTypeToSLInvType(string contentType) | 210 | public static sbyte ContentTypeToSLInvType(string contentType) |
220 | { | 211 | { |
221 | switch (contentType) | 212 | InventoryType invType; |
222 | { | 213 | if (!content2Inventory.TryGetValue(contentType, out invType)) |
223 | case "image/x-j2c": | 214 | invType = InventoryType.Unknown; |
224 | case "image/jp2": | 215 | return (sbyte)invType; |
225 | case "image/tga": | 216 | } |
226 | case "image/jpeg": | 217 | |
227 | return (sbyte)InventoryType.Texture; | 218 | public static string SLAssetTypeToExtension(int assetType) |
228 | case "application/ogg": | 219 | { |
229 | case "audio/ogg": | 220 | string extension; |
230 | case "audio/x-wav": | 221 | if (!asset2Extension.TryGetValue((sbyte)assetType, out extension)) |
231 | return (sbyte)InventoryType.Sound; | 222 | extension = asset2Extension[(sbyte)AssetType.Unknown]; |
232 | case "application/vnd.ll.callingcard": | 223 | return extension; |
233 | case "application/x-metaverse-callingcard": | ||
234 | return (sbyte)InventoryType.CallingCard; | ||
235 | case "application/vnd.ll.landmark": | ||
236 | case "application/x-metaverse-landmark": | ||
237 | return (sbyte)InventoryType.Landmark; | ||
238 | case "application/vnd.ll.clothing": | ||
239 | case "application/x-metaverse-clothing": | ||
240 | case "application/vnd.ll.bodypart": | ||
241 | case "application/x-metaverse-bodypart": | ||
242 | return (sbyte)InventoryType.Wearable; | ||
243 | case "application/vnd.ll.primitive": | ||
244 | case "application/x-metaverse-primitive": | ||
245 | return (sbyte)InventoryType.Object; | ||
246 | case "application/vnd.ll.notecard": | ||
247 | case "application/x-metaverse-notecard": | ||
248 | return (sbyte)InventoryType.Notecard; | ||
249 | case "application/vnd.ll.folder": | ||
250 | return (sbyte)InventoryType.Folder; | ||
251 | case "application/vnd.ll.rootfolder": | ||
252 | return (sbyte)InventoryType.RootCategory; | ||
253 | case "application/vnd.ll.lsltext": | ||
254 | case "application/x-metaverse-lsl": | ||
255 | case "application/vnd.ll.lslbyte": | ||
256 | case "application/x-metaverse-lso": | ||
257 | return (sbyte)InventoryType.LSL; | ||
258 | case "application/vnd.ll.trashfolder": | ||
259 | case "application/vnd.ll.snapshotfolder": | ||
260 | case "application/vnd.ll.lostandfoundfolder": | ||
261 | return (sbyte)InventoryType.Folder; | ||
262 | case "application/vnd.ll.animation": | ||
263 | case "application/x-metaverse-animation": | ||
264 | return (sbyte)InventoryType.Animation; | ||
265 | case "application/vnd.ll.gesture": | ||
266 | case "application/x-metaverse-gesture": | ||
267 | return (sbyte)InventoryType.Gesture; | ||
268 | case "application/x-metaverse-simstate": | ||
269 | return (sbyte)InventoryType.Snapshot; | ||
270 | case "application/octet-stream": | ||
271 | default: | ||
272 | return (sbyte)InventoryType.Unknown; | ||
273 | } | ||
274 | } | 224 | } |
275 | 225 | ||
276 | #endregion SL / file extension / content-type conversions | 226 | #endregion SL / file extension / content-type conversions |
@@ -377,4 +327,4 @@ namespace OpenSim.Framework | |||
377 | return output; | 327 | return output; |
378 | } | 328 | } |
379 | } | 329 | } |
380 | } \ No newline at end of file | 330 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHTTPHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseHTTPHandler.cs index 2fe9769..9f8f4a8 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHTTPHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHTTPHandler.cs | |||
@@ -33,9 +33,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
33 | { | 33 | { |
34 | public abstract Hashtable Handle(string path, Hashtable Request); | 34 | public abstract Hashtable Handle(string path, Hashtable Request); |
35 | 35 | ||
36 | protected BaseHTTPHandler(string httpMethod, string path) | 36 | protected BaseHTTPHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} |
37 | : base(httpMethod, path) | 37 | |
38 | { | 38 | protected BaseHTTPHandler(string httpMethod, string path, string name, string description) |
39 | } | 39 | : base(httpMethod, path, name, description) {} |
40 | } | 40 | } |
41 | } | 41 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index ad5af1f..dfb09f4 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -156,7 +156,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | public List<string> GetStreamHandlerKeys() | 159 | public List<string> GetStreamHandlerKeys() |
160 | { | 160 | { |
161 | lock (m_streamHandlers) | 161 | lock (m_streamHandlers) |
162 | return new List<string>(m_streamHandlers.Keys); | 162 | return new List<string>(m_streamHandlers.Keys); |
@@ -410,6 +410,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
410 | // string reqnum = "unknown"; | 410 | // string reqnum = "unknown"; |
411 | int tickstart = Environment.TickCount; | 411 | int tickstart = Environment.TickCount; |
412 | 412 | ||
413 | IRequestHandler requestHandler = null; | ||
414 | |||
413 | try | 415 | try |
414 | { | 416 | { |
415 | // OpenSim.Framework.WebUtil.OSHeaderRequestID | 417 | // OpenSim.Framework.WebUtil.OSHeaderRequestID |
@@ -438,8 +440,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
438 | //response.KeepAlive = true; | 440 | //response.KeepAlive = true; |
439 | response.SendChunked = false; | 441 | response.SendChunked = false; |
440 | 442 | ||
441 | IRequestHandler requestHandler; | ||
442 | |||
443 | string path = request.RawUrl; | 443 | string path = request.RawUrl; |
444 | string handlerKey = GetHandlerKey(request.HttpMethod, path); | 444 | string handlerKey = GetHandlerKey(request.HttpMethod, path); |
445 | 445 | ||
@@ -662,11 +662,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
662 | } | 662 | } |
663 | catch (IOException e) | 663 | catch (IOException e) |
664 | { | 664 | { |
665 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e); | 665 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}{1}", e.Message, e.StackTrace); |
666 | } | 666 | } |
667 | catch (Exception e) | 667 | catch (Exception e) |
668 | { | 668 | { |
669 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e.StackTrace); | 669 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}{1}", e.Message, e.StackTrace); |
670 | SendHTML500(response); | 670 | SendHTML500(response); |
671 | } | 671 | } |
672 | finally | 672 | finally |
@@ -675,8 +675,16 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
675 | // since its just for reporting, tickdiff limit can be adjusted | 675 | // since its just for reporting, tickdiff limit can be adjusted |
676 | int tickdiff = Environment.TickCount - tickstart; | 676 | int tickdiff = Environment.TickCount - tickstart; |
677 | if (tickdiff > 3000) | 677 | if (tickdiff > 3000) |
678 | { | ||
678 | m_log.InfoFormat( | 679 | m_log.InfoFormat( |
679 | "[BASE HTTP SERVER]: slow {0} request for {1} from {2} took {3} ms", requestMethod, uriString, request.RemoteIPEndPoint.ToString(), tickdiff); | 680 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} from {4} took {5}ms", |
681 | requestMethod, | ||
682 | uriString, | ||
683 | requestHandler != null ? requestHandler.Name : "", | ||
684 | requestHandler != null ? requestHandler.Description : "", | ||
685 | request.RemoteIPEndPoint.ToString(), | ||
686 | tickdiff); | ||
687 | } | ||
680 | } | 688 | } |
681 | } | 689 | } |
682 | 690 | ||
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index a2135a3..ae7aaf2 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | |||
@@ -45,8 +45,16 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
45 | 45 | ||
46 | private readonly string m_path; | 46 | private readonly string m_path; |
47 | 47 | ||
48 | protected BaseRequestHandler(string httpMethod, string path) | 48 | public string Name { get; private set; } |
49 | |||
50 | public string Description { get; private set; } | ||
51 | |||
52 | protected BaseRequestHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} | ||
53 | |||
54 | protected BaseRequestHandler(string httpMethod, string path, string name, string description) | ||
49 | { | 55 | { |
56 | Name = name; | ||
57 | Description = description; | ||
50 | m_httpMethod = httpMethod; | 58 | m_httpMethod = httpMethod; |
51 | m_path = path; | 59 | m_path = path; |
52 | } | 60 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs index f1cde74..6342983 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs | |||
@@ -34,8 +34,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
34 | public abstract byte[] Handle(string path, Stream request, | 34 | public abstract byte[] Handle(string path, Stream request, |
35 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse); | 35 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse); |
36 | 36 | ||
37 | protected BaseStreamHandler(string httpMethod, string path) : base(httpMethod, path) | 37 | protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} |
38 | { | 38 | |
39 | } | 39 | protected BaseStreamHandler(string httpMethod, string path, string name, string description) |
40 | : base(httpMethod, path, name, description) {} | ||
40 | } | 41 | } |
41 | } | 42 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs index 1699233..b94bfb4 100644 --- a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs | |||
@@ -36,6 +36,15 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
36 | { | 36 | { |
37 | private BinaryMethod m_method; | 37 | private BinaryMethod m_method; |
38 | 38 | ||
39 | public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod) | ||
40 | : this(httpMethod, path, binaryMethod, null, null) {} | ||
41 | |||
42 | public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod, string name, string description) | ||
43 | : base(httpMethod, path, name, description) | ||
44 | { | ||
45 | m_method = binaryMethod; | ||
46 | } | ||
47 | |||
39 | public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 48 | public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
40 | { | 49 | { |
41 | byte[] data = ReadFully(request); | 50 | byte[] data = ReadFully(request); |
@@ -45,12 +54,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
45 | return Encoding.UTF8.GetBytes(responseString); | 54 | return Encoding.UTF8.GetBytes(responseString); |
46 | } | 55 | } |
47 | 56 | ||
48 | public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod) | ||
49 | : base(httpMethod, path) | ||
50 | { | ||
51 | m_method = binaryMethod; | ||
52 | } | ||
53 | |||
54 | private static byte[] ReadFully(Stream stream) | 57 | private static byte[] ReadFully(Stream stream) |
55 | { | 58 | { |
56 | byte[] buffer = new byte[1024]; | 59 | byte[] buffer = new byte[1024]; |
@@ -70,4 +73,4 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
70 | } | 73 | } |
71 | } | 74 | } |
72 | } | 75 | } |
73 | } | 76 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs index a449c2d..cb5cce5 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs | |||
@@ -32,6 +32,25 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
32 | { | 32 | { |
33 | public interface IRequestHandler | 33 | public interface IRequestHandler |
34 | { | 34 | { |
35 | |||
36 | /// <summary> | ||
37 | /// Name for this handler. | ||
38 | /// </summary> | ||
39 | /// <remarks> | ||
40 | /// Used for diagnostics. The path doesn't always describe what the handler does. Can be null if none | ||
41 | /// specified. | ||
42 | /// </remarks> | ||
43 | string Name { get; } | ||
44 | |||
45 | /// <summary> | ||
46 | /// Description for this handler. | ||
47 | /// </summary> | ||
48 | /// <remarks> | ||
49 | /// Used for diagnostics. The path doesn't always describe what the handler does. Can be null if none | ||
50 | /// specified. | ||
51 | /// </remarks> | ||
52 | string Description { get; } | ||
53 | |||
35 | // Return response content type | 54 | // Return response content type |
36 | string ContentType { get; } | 55 | string ContentType { get; } |
37 | 56 | ||
@@ -58,4 +77,4 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
58 | { | 77 | { |
59 | Hashtable Handle(string path, Hashtable request); | 78 | Hashtable Handle(string path, Hashtable request); |
60 | } | 79 | } |
61 | } | 80 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs index a467a83..07082a8 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs | |||
@@ -39,7 +39,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
39 | private RestDeserialiseMethod<TRequest, TResponse> m_method; | 39 | private RestDeserialiseMethod<TRequest, TResponse> m_method; |
40 | 40 | ||
41 | public RestDeserialiseHandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method) | 41 | public RestDeserialiseHandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method) |
42 | : base(httpMethod, path) | 42 | : this(httpMethod, path, method, null, null) {} |
43 | |||
44 | public RestDeserialiseHandler( | ||
45 | string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method, string name, string description) | ||
46 | : base(httpMethod, path, name, description) | ||
43 | { | 47 | { |
44 | m_method = method; | 48 | m_method = method; |
45 | } | 49 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/RestHTTPHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestHTTPHandler.cs index 1f23cac..7f89839 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestHTTPHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestHTTPHandler.cs | |||
@@ -38,19 +38,25 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
38 | get { return m_dhttpMethod; } | 38 | get { return m_dhttpMethod; } |
39 | } | 39 | } |
40 | 40 | ||
41 | public override Hashtable Handle(string path, Hashtable request) | 41 | public RestHTTPHandler(string httpMethod, string path, GenericHTTPMethod dhttpMethod) |
42 | : base(httpMethod, path) | ||
42 | { | 43 | { |
44 | m_dhttpMethod = dhttpMethod; | ||
45 | } | ||
46 | |||
47 | public RestHTTPHandler( | ||
48 | string httpMethod, string path, GenericHTTPMethod dhttpMethod, string name, string description) | ||
49 | : base(httpMethod, path, name, description) | ||
50 | { | ||
51 | m_dhttpMethod = dhttpMethod; | ||
52 | } | ||
43 | 53 | ||
54 | public override Hashtable Handle(string path, Hashtable request) | ||
55 | { | ||
44 | string param = GetParam(path); | 56 | string param = GetParam(path); |
45 | request.Add("param", param); | 57 | request.Add("param", param); |
46 | request.Add("path", path); | 58 | request.Add("path", path); |
47 | return m_dhttpMethod(request); | 59 | return m_dhttpMethod(request); |
48 | } | 60 | } |
49 | |||
50 | public RestHTTPHandler(string httpMethod, string path, GenericHTTPMethod dhttpMethod) | ||
51 | : base(httpMethod, path) | ||
52 | { | ||
53 | m_dhttpMethod = dhttpMethod; | ||
54 | } | ||
55 | } | 61 | } |
56 | } | 62 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs index d2c4002..1f17fee 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs | |||
@@ -39,6 +39,15 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
39 | get { return m_restMethod; } | 39 | get { return m_restMethod; } |
40 | } | 40 | } |
41 | 41 | ||
42 | public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) | ||
43 | : this(httpMethod, path, restMethod, null, null) {} | ||
44 | |||
45 | public RestStreamHandler(string httpMethod, string path, RestMethod restMethod, string name, string description) | ||
46 | : base(httpMethod, path, name, description) | ||
47 | { | ||
48 | m_restMethod = restMethod; | ||
49 | } | ||
50 | |||
42 | public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 51 | public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
43 | { | 52 | { |
44 | Encoding encoding = Encoding.UTF8; | 53 | Encoding encoding = Encoding.UTF8; |
@@ -52,10 +61,5 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
52 | 61 | ||
53 | return Encoding.UTF8.GetBytes(responseString); | 62 | return Encoding.UTF8.GetBytes(responseString); |
54 | } | 63 | } |
55 | |||
56 | public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base(httpMethod, path) | ||
57 | { | ||
58 | m_restMethod = restMethod; | ||
59 | } | ||
60 | } | 64 | } |
61 | } | 65 | } |
diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index 7ef8bf7..fb818ee 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs | |||
@@ -26,6 +26,8 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | ||
30 | using log4net; | ||
29 | using OpenMetaverse; | 31 | using OpenMetaverse; |
30 | 32 | ||
31 | namespace OpenSim.Framework | 33 | namespace OpenSim.Framework |
@@ -35,6 +37,8 @@ namespace OpenSim.Framework | |||
35 | /// </summary> | 37 | /// </summary> |
36 | public class TaskInventoryItem : ICloneable | 38 | public class TaskInventoryItem : ICloneable |
37 | { | 39 | { |
40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
41 | |||
38 | /// <summary> | 42 | /// <summary> |
39 | /// XXX This should really be factored out into some constants class. | 43 | /// XXX This should really be factored out into some constants class. |
40 | /// </summary> | 44 | /// </summary> |
@@ -334,12 +338,18 @@ namespace OpenSim.Framework | |||
334 | } | 338 | } |
335 | } | 339 | } |
336 | 340 | ||
337 | public bool OwnerChanged { | 341 | public bool OwnerChanged |
338 | get { | 342 | { |
343 | get | ||
344 | { | ||
339 | return _ownerChanged; | 345 | return _ownerChanged; |
340 | } | 346 | } |
341 | set { | 347 | set |
348 | { | ||
342 | _ownerChanged = value; | 349 | _ownerChanged = value; |
350 | // m_log.DebugFormat( | ||
351 | // "[TASK INVENTORY ITEM]: Owner changed set {0} for {1} {2} owned by {3}", | ||
352 | // _ownerChanged, Name, ItemID, OwnerID); | ||
343 | } | 353 | } |
344 | } | 354 | } |
345 | 355 | ||
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs index 34a3f15..6fde488 100644 --- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs +++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs | |||
@@ -227,10 +227,10 @@ namespace OpenSim.Framework.Tests | |||
227 | es.AddEstateManager(UUID.Zero); | 227 | es.AddEstateManager(UUID.Zero); |
228 | 228 | ||
229 | es.AddEstateManager(bannedUserId); | 229 | es.AddEstateManager(bannedUserId); |
230 | Assert.IsTrue(es.IsEstateManager(bannedUserId), "bannedUserId should be EstateManager but isn't."); | 230 | Assert.IsTrue(es.IsEstateManagerOrOwner(bannedUserId), "bannedUserId should be EstateManager but isn't."); |
231 | 231 | ||
232 | es.RemoveEstateManager(bannedUserId); | 232 | es.RemoveEstateManager(bannedUserId); |
233 | Assert.IsFalse(es.IsEstateManager(bannedUserId), "bannedUserID is estateManager but shouldn't be"); | 233 | Assert.IsFalse(es.IsEstateManagerOrOwner(bannedUserId), "bannedUserID is estateManager but shouldn't be"); |
234 | 234 | ||
235 | Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't"); | 235 | Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't"); |
236 | 236 | ||
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index 1ca35df..f0d2a3f 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs | |||
@@ -214,16 +214,13 @@ namespace OpenSim.Framework.Tests | |||
214 | 214 | ||
215 | for (int i = 0; i < contenttypes.Length; i++) | 215 | for (int i = 0; i < contenttypes.Length; i++) |
216 | { | 216 | { |
217 | if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18) | 217 | int expected; |
218 | { | 218 | if (contenttypes[i] == "image/tga") |
219 | Assert.That(contenttypes[i] == "image/tga"); | 219 | expected = 12; // if we know only the content-type "image/tga", then we assume the asset type is TextureTGA; not ImageTGA |
220 | } | ||
221 | else | 220 | else |
222 | { | 221 | expected = assettypes[i]; |
223 | Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i], | 222 | Assert.AreEqual(expected, SLUtil.ContentTypeToSLAssetType(contenttypes[i]), |
224 | "Expecting {0} but got {1}", assettypes[i], | 223 | String.Format("Incorrect AssetType mapped from Content-Type {0}", contenttypes[i])); |
225 | SLUtil.ContentTypeToSLAssetType(contenttypes[i])); | ||
226 | } | ||
227 | } | 224 | } |
228 | 225 | ||
229 | int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20}; | 226 | int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20}; |
@@ -237,7 +234,7 @@ namespace OpenSim.Framework.Tests | |||
237 | "application/vnd.ll.primitive", | 234 | "application/vnd.ll.primitive", |
238 | "application/vnd.ll.notecard", | 235 | "application/vnd.ll.notecard", |
239 | "application/vnd.ll.folder", | 236 | "application/vnd.ll.folder", |
240 | "application/octet-stream", | 237 | "application/vnd.ll.rootfolder", |
241 | "application/vnd.ll.lsltext", | 238 | "application/vnd.ll.lsltext", |
242 | "image/x-j2c", | 239 | "image/x-j2c", |
243 | "application/vnd.ll.primitive", | 240 | "application/vnd.ll.primitive", |
@@ -247,7 +244,8 @@ namespace OpenSim.Framework.Tests | |||
247 | 244 | ||
248 | for (int i=0;i<inventorytypes.Length;i++) | 245 | for (int i=0;i<inventorytypes.Length;i++) |
249 | { | 246 | { |
250 | Assert.That(SLUtil.SLInvTypeToContentType(inventorytypes[i]) == invcontenttypes[i], "Expected {0}, Got {1}", invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i])); | 247 | Assert.AreEqual(invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i]), |
248 | String.Format("Incorrect Content-Type mapped from InventoryType {0}", inventorytypes[i])); | ||
251 | } | 249 | } |
252 | 250 | ||
253 | invcontenttypes = new string[] | 251 | invcontenttypes = new string[] |
@@ -280,7 +278,8 @@ namespace OpenSim.Framework.Tests | |||
280 | 278 | ||
281 | for (int i = 0; i < invtypes.Length; i++) | 279 | for (int i = 0; i < invtypes.Length; i++) |
282 | { | 280 | { |
283 | Assert.That(SLUtil.ContentTypeToSLInvType(invcontenttypes[i]) == invtypes[i], "Expected {0}, Got {1}", invtypes[i], SLUtil.ContentTypeToSLInvType(invcontenttypes[i])); | 281 | Assert.AreEqual(invtypes[i], SLUtil.ContentTypeToSLInvType(invcontenttypes[i]), |
282 | String.Format("Incorrect InventoryType mapped from Content-Type {0}", invcontenttypes[i])); | ||
284 | } | 283 | } |
285 | } | 284 | } |
286 | } | 285 | } |
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index aac575c..6a40cd5 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -53,19 +53,36 @@ namespace OpenSim.Framework | |||
53 | LogManager.GetLogger( | 53 | LogManager.GetLogger( |
54 | MethodBase.GetCurrentMethod().DeclaringType); | 54 | MethodBase.GetCurrentMethod().DeclaringType); |
55 | 55 | ||
56 | private static int m_requestNumber = 0; | 56 | /// <summary> |
57 | /// Request number for diagnostic purposes. | ||
58 | /// </summary> | ||
59 | public static int RequestNumber = 0; | ||
57 | 60 | ||
58 | // this is the header field used to communicate the local request id | 61 | /// <summary> |
59 | // used for performance and debugging | 62 | /// this is the header field used to communicate the local request id |
63 | /// used for performance and debugging | ||
64 | /// </summary> | ||
60 | public const string OSHeaderRequestID = "opensim-request-id"; | 65 | public const string OSHeaderRequestID = "opensim-request-id"; |
61 | 66 | ||
62 | // number of milliseconds a call can take before it is considered | 67 | /// <summary> |
63 | // a "long" call for warning & debugging purposes | 68 | /// Number of milliseconds a call can take before it is considered |
64 | public const int LongCallTime = 500; | 69 | /// a "long" call for warning & debugging purposes |
70 | /// </summary> | ||
71 | public const int LongCallTime = 3000; | ||
65 | 72 | ||
66 | // dictionary of end points | 73 | /// <summary> |
74 | /// The maximum length of any data logged because of a long request time. | ||
75 | /// </summary> | ||
76 | /// <remarks> | ||
77 | /// This is to truncate any really large post data, such as an asset. In theory, the first section should | ||
78 | /// give us useful information about the call (which agent it relates to if applicable, etc.). | ||
79 | /// </remarks> | ||
80 | public const int MaxRequestDiagLength = 100; | ||
81 | |||
82 | /// <summary> | ||
83 | /// Dictionary of end points | ||
84 | /// </summary> | ||
67 | private static Dictionary<string,object> m_endpointSerializer = new Dictionary<string,object>(); | 85 | private static Dictionary<string,object> m_endpointSerializer = new Dictionary<string,object>(); |
68 | |||
69 | 86 | ||
70 | private static object EndPointLock(string url) | 87 | private static object EndPointLock(string url) |
71 | { | 88 | { |
@@ -86,8 +103,7 @@ namespace OpenSim.Framework | |||
86 | return eplock; | 103 | return eplock; |
87 | } | 104 | } |
88 | } | 105 | } |
89 | 106 | ||
90 | |||
91 | #region JSONRequest | 107 | #region JSONRequest |
92 | 108 | ||
93 | /// <summary> | 109 | /// <summary> |
@@ -129,12 +145,13 @@ namespace OpenSim.Framework | |||
129 | 145 | ||
130 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) | 146 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) |
131 | { | 147 | { |
132 | int reqnum = m_requestNumber++; | 148 | int reqnum = RequestNumber++; |
133 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 149 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); |
134 | 150 | ||
135 | string errorMessage = "unknown error"; | 151 | string errorMessage = "unknown error"; |
136 | int tickstart = Util.EnvironmentTickCount(); | 152 | int tickstart = Util.EnvironmentTickCount(); |
137 | int tickdata = 0; | 153 | int tickdata = 0; |
154 | string strBuffer = null; | ||
138 | 155 | ||
139 | try | 156 | try |
140 | { | 157 | { |
@@ -149,7 +166,7 @@ namespace OpenSim.Framework | |||
149 | // If there is some input, write it into the request | 166 | // If there is some input, write it into the request |
150 | if (data != null) | 167 | if (data != null) |
151 | { | 168 | { |
152 | string strBuffer = OSDParser.SerializeJsonString(data); | 169 | strBuffer = OSDParser.SerializeJsonString(data); |
153 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); | 170 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); |
154 | 171 | ||
155 | if (compressed) | 172 | if (compressed) |
@@ -210,14 +227,23 @@ namespace OpenSim.Framework | |||
210 | } | 227 | } |
211 | finally | 228 | finally |
212 | { | 229 | { |
213 | // This just dumps a warning for any operation that takes more than 100 ms | ||
214 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 230 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
215 | if (tickdiff > LongCallTime) | 231 | if (tickdiff > LongCallTime) |
216 | m_log.DebugFormat("[WEB UTIL]: osd request <{0}> (URI:{1}, METHOD:{2}) took {3}ms overall, {4}ms writing", | 232 | m_log.InfoFormat( |
217 | reqnum,url,method,tickdiff,tickdata); | 233 | "[OSD REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", |
234 | reqnum, | ||
235 | method, | ||
236 | url, | ||
237 | tickdiff, | ||
238 | tickdata, | ||
239 | strBuffer != null | ||
240 | ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) | ||
241 | : ""); | ||
218 | } | 242 | } |
219 | 243 | ||
220 | m_log.DebugFormat("[WEB UTIL]: <{0}> osd request for {1}, method {2} FAILED: {3}", reqnum, url, method, errorMessage); | 244 | m_log.DebugFormat( |
245 | "[WEB UTIL]: <{0}> osd request for {1}, method {2} FAILED: {3}", reqnum, url, method, errorMessage); | ||
246 | |||
221 | return ErrorResponseMap(errorMessage); | 247 | return ErrorResponseMap(errorMessage); |
222 | } | 248 | } |
223 | 249 | ||
@@ -290,17 +316,17 @@ namespace OpenSim.Framework | |||
290 | 316 | ||
291 | private static OSDMap ServiceFormRequestWorker(string url, NameValueCollection data, int timeout) | 317 | private static OSDMap ServiceFormRequestWorker(string url, NameValueCollection data, int timeout) |
292 | { | 318 | { |
293 | int reqnum = m_requestNumber++; | 319 | int reqnum = RequestNumber++; |
294 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; | 320 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; |
295 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); | 321 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); |
296 | 322 | ||
297 | string errorMessage = "unknown error"; | 323 | string errorMessage = "unknown error"; |
298 | int tickstart = Util.EnvironmentTickCount(); | 324 | int tickstart = Util.EnvironmentTickCount(); |
299 | int tickdata = 0; | 325 | int tickdata = 0; |
326 | string queryString = null; | ||
300 | 327 | ||
301 | try | 328 | try |
302 | { | 329 | { |
303 | |||
304 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); | 330 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); |
305 | request.Method = "POST"; | 331 | request.Method = "POST"; |
306 | request.Timeout = timeout; | 332 | request.Timeout = timeout; |
@@ -311,7 +337,7 @@ namespace OpenSim.Framework | |||
311 | 337 | ||
312 | if (data != null) | 338 | if (data != null) |
313 | { | 339 | { |
314 | string queryString = BuildQueryString(data); | 340 | queryString = BuildQueryString(data); |
315 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); | 341 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); |
316 | 342 | ||
317 | request.ContentLength = buffer.Length; | 343 | request.ContentLength = buffer.Length; |
@@ -354,11 +380,20 @@ namespace OpenSim.Framework | |||
354 | { | 380 | { |
355 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 381 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
356 | if (tickdiff > LongCallTime) | 382 | if (tickdiff > LongCallTime) |
357 | m_log.InfoFormat("[WEB UTIL]: form request <{0}> (URI:{1}, METHOD:{2}) took {3}ms overall, {4}ms writing", | 383 | m_log.InfoFormat( |
358 | reqnum,url,method,tickdiff,tickdata); | 384 | "[SERVICE FORM]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", |
385 | reqnum, | ||
386 | method, | ||
387 | url, | ||
388 | tickdiff, | ||
389 | tickdata, | ||
390 | queryString != null | ||
391 | ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString | ||
392 | : ""); | ||
359 | } | 393 | } |
360 | 394 | ||
361 | m_log.WarnFormat("[WEB UTIL]: <{0}> form request failed: {1}",reqnum,errorMessage); | 395 | m_log.WarnFormat("[SERVICE FORM]: <{0}> form request to {1} failed: {2}", reqnum, url, errorMessage); |
396 | |||
362 | return ErrorResponseMap(errorMessage); | 397 | return ErrorResponseMap(errorMessage); |
363 | } | 398 | } |
364 | 399 | ||
@@ -638,8 +673,6 @@ namespace OpenSim.Framework | |||
638 | 673 | ||
639 | return new string[0]; | 674 | return new string[0]; |
640 | } | 675 | } |
641 | |||
642 | |||
643 | } | 676 | } |
644 | 677 | ||
645 | public static class AsynchronousRestObjectRequester | 678 | public static class AsynchronousRestObjectRequester |
@@ -662,6 +695,12 @@ namespace OpenSim.Framework | |||
662 | public static void MakeRequest<TRequest, TResponse>(string verb, | 695 | public static void MakeRequest<TRequest, TResponse>(string verb, |
663 | string requestUrl, TRequest obj, Action<TResponse> action) | 696 | string requestUrl, TRequest obj, Action<TResponse> action) |
664 | { | 697 | { |
698 | int reqnum = WebUtil.RequestNumber++; | ||
699 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | ||
700 | |||
701 | int tickstart = Util.EnvironmentTickCount(); | ||
702 | int tickdata = 0; | ||
703 | |||
665 | // m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl); | 704 | // m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl); |
666 | 705 | ||
667 | Type type = typeof(TRequest); | 706 | Type type = typeof(TRequest); |
@@ -672,12 +711,13 @@ namespace OpenSim.Framework | |||
672 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); | 711 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); |
673 | 712 | ||
674 | request.Method = verb; | 713 | request.Method = verb; |
714 | MemoryStream buffer = null; | ||
675 | 715 | ||
676 | if (verb == "POST") | 716 | if (verb == "POST") |
677 | { | 717 | { |
678 | request.ContentType = "text/xml"; | 718 | request.ContentType = "text/xml"; |
679 | 719 | ||
680 | MemoryStream buffer = new MemoryStream(); | 720 | buffer = new MemoryStream(); |
681 | 721 | ||
682 | XmlWriterSettings settings = new XmlWriterSettings(); | 722 | XmlWriterSettings settings = new XmlWriterSettings(); |
683 | settings.Encoding = Encoding.UTF8; | 723 | settings.Encoding = Encoding.UTF8; |
@@ -699,6 +739,9 @@ namespace OpenSim.Framework | |||
699 | requestStream.Write(buffer.ToArray(), 0, length); | 739 | requestStream.Write(buffer.ToArray(), 0, length); |
700 | requestStream.Close(); | 740 | requestStream.Close(); |
701 | 741 | ||
742 | // capture how much time was spent writing | ||
743 | tickdata = Util.EnvironmentTickCountSubtract(tickstart); | ||
744 | |||
702 | request.BeginGetResponse(delegate(IAsyncResult ar) | 745 | request.BeginGetResponse(delegate(IAsyncResult ar) |
703 | { | 746 | { |
704 | response = request.EndGetResponse(ar); | 747 | response = request.EndGetResponse(ar); |
@@ -724,83 +767,108 @@ namespace OpenSim.Framework | |||
724 | 767 | ||
725 | }, null); | 768 | }, null); |
726 | }, null); | 769 | }, null); |
727 | |||
728 | |||
729 | return; | ||
730 | } | 770 | } |
731 | 771 | else | |
732 | request.BeginGetResponse(delegate(IAsyncResult res2) | ||
733 | { | 772 | { |
734 | try | 773 | request.BeginGetResponse(delegate(IAsyncResult res2) |
735 | { | 774 | { |
736 | // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't | ||
737 | // documented in MSDN | ||
738 | response = request.EndGetResponse(res2); | ||
739 | |||
740 | Stream respStream = null; | ||
741 | try | 775 | try |
742 | { | 776 | { |
743 | respStream = response.GetResponseStream(); | 777 | // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't |
744 | deserial = (TResponse)deserializer.Deserialize(respStream); | 778 | // documented in MSDN |
745 | } | 779 | response = request.EndGetResponse(res2); |
746 | catch (System.InvalidOperationException) | 780 | |
747 | { | 781 | Stream respStream = null; |
748 | } | 782 | try |
749 | finally | 783 | { |
750 | { | 784 | respStream = response.GetResponseStream(); |
751 | respStream.Close(); | 785 | deserial = (TResponse)deserializer.Deserialize(respStream); |
752 | response.Close(); | 786 | } |
787 | catch (System.InvalidOperationException) | ||
788 | { | ||
789 | } | ||
790 | finally | ||
791 | { | ||
792 | respStream.Close(); | ||
793 | response.Close(); | ||
794 | } | ||
753 | } | 795 | } |
754 | } | 796 | catch (WebException e) |
755 | catch (WebException e) | ||
756 | { | ||
757 | if (e.Status == WebExceptionStatus.ProtocolError) | ||
758 | { | 797 | { |
759 | if (e.Response is HttpWebResponse) | 798 | if (e.Status == WebExceptionStatus.ProtocolError) |
760 | { | 799 | { |
761 | HttpWebResponse httpResponse = (HttpWebResponse)e.Response; | 800 | if (e.Response is HttpWebResponse) |
762 | |||
763 | if (httpResponse.StatusCode != HttpStatusCode.NotFound) | ||
764 | { | 801 | { |
765 | // We don't appear to be handling any other status codes, so log these feailures to that | 802 | HttpWebResponse httpResponse = (HttpWebResponse)e.Response; |
766 | // people don't spend unnecessary hours hunting phantom bugs. | 803 | |
767 | m_log.DebugFormat( | 804 | if (httpResponse.StatusCode != HttpStatusCode.NotFound) |
768 | "[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}", | 805 | { |
769 | verb, requestUrl, httpResponse.StatusCode); | 806 | // We don't appear to be handling any other status codes, so log these feailures to that |
807 | // people don't spend unnecessary hours hunting phantom bugs. | ||
808 | m_log.DebugFormat( | ||
809 | "[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}", | ||
810 | verb, requestUrl, httpResponse.StatusCode); | ||
811 | } | ||
770 | } | 812 | } |
771 | } | 813 | } |
814 | else | ||
815 | { | ||
816 | m_log.ErrorFormat( | ||
817 | "[ASYNC REQUEST]: Request {0} {1} failed with status {2} and message {3}", | ||
818 | verb, requestUrl, e.Status, e.Message); | ||
819 | } | ||
772 | } | 820 | } |
773 | else | 821 | catch (Exception e) |
774 | { | 822 | { |
775 | m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with status {2} and message {3}", verb, requestUrl, e.Status, e.Message); | 823 | m_log.ErrorFormat( |
824 | "[ASYNC REQUEST]: Request {0} {1} failed with exception {2}{3}", | ||
825 | verb, requestUrl, e.Message, e.StackTrace); | ||
776 | } | 826 | } |
777 | } | 827 | |
778 | catch (Exception e) | 828 | // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString()); |
779 | { | ||
780 | m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with exception {2}", verb, requestUrl, e); | ||
781 | } | ||
782 | 829 | ||
783 | // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString()); | 830 | try |
831 | { | ||
832 | action(deserial); | ||
833 | } | ||
834 | catch (Exception e) | ||
835 | { | ||
836 | m_log.ErrorFormat( | ||
837 | "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}{3}", | ||
838 | verb, requestUrl, e.Message, e.StackTrace); | ||
839 | } | ||
840 | |||
841 | }, null); | ||
842 | } | ||
784 | 843 | ||
785 | try | 844 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
786 | { | 845 | if (tickdiff > WebUtil.LongCallTime) |
787 | action(deserial); | 846 | { |
788 | } | 847 | string originalRequest = null; |
789 | catch (Exception e) | 848 | |
849 | if (buffer != null) | ||
790 | { | 850 | { |
791 | m_log.ErrorFormat( | 851 | originalRequest = Encoding.UTF8.GetString(buffer.ToArray()); |
792 | "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}", verb, requestUrl, e); | 852 | |
853 | if (originalRequest.Length > WebUtil.MaxRequestDiagLength) | ||
854 | originalRequest = originalRequest.Remove(WebUtil.MaxRequestDiagLength); | ||
793 | } | 855 | } |
794 | 856 | ||
795 | }, null); | 857 | m_log.InfoFormat( |
858 | "[ASYNC REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | ||
859 | reqnum, | ||
860 | verb, | ||
861 | requestUrl, | ||
862 | tickdiff, | ||
863 | tickdata, | ||
864 | originalRequest); | ||
865 | } | ||
796 | } | 866 | } |
797 | } | 867 | } |
798 | 868 | ||
799 | public static class SynchronousRestFormsRequester | 869 | public static class SynchronousRestFormsRequester |
800 | { | 870 | { |
801 | private static readonly ILog m_log = | 871 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
802 | LogManager.GetLogger( | ||
803 | MethodBase.GetCurrentMethod().DeclaringType); | ||
804 | 872 | ||
805 | /// <summary> | 873 | /// <summary> |
806 | /// Perform a synchronous REST request. | 874 | /// Perform a synchronous REST request. |
@@ -814,6 +882,12 @@ namespace OpenSim.Framework | |||
814 | /// the request. You'll want to make sure you deal with this as they're not uncommon</exception> | 882 | /// the request. You'll want to make sure you deal with this as they're not uncommon</exception> |
815 | public static string MakeRequest(string verb, string requestUrl, string obj) | 883 | public static string MakeRequest(string verb, string requestUrl, string obj) |
816 | { | 884 | { |
885 | int reqnum = WebUtil.RequestNumber++; | ||
886 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | ||
887 | |||
888 | int tickstart = Util.EnvironmentTickCount(); | ||
889 | int tickdata = 0; | ||
890 | |||
817 | WebRequest request = WebRequest.Create(requestUrl); | 891 | WebRequest request = WebRequest.Create(requestUrl); |
818 | request.Method = verb; | 892 | request.Method = verb; |
819 | string respstring = String.Empty; | 893 | string respstring = String.Empty; |
@@ -842,12 +916,16 @@ namespace OpenSim.Framework | |||
842 | } | 916 | } |
843 | catch (Exception e) | 917 | catch (Exception e) |
844 | { | 918 | { |
845 | m_log.DebugFormat("[FORMS]: exception occured on sending request to {0}: " + e.ToString(), requestUrl); | 919 | m_log.DebugFormat( |
920 | "[FORMS]: exception occured {0} {1}: {2}{3}", verb, requestUrl, e.Message, e.StackTrace); | ||
846 | } | 921 | } |
847 | finally | 922 | finally |
848 | { | 923 | { |
849 | if (requestStream != null) | 924 | if (requestStream != null) |
850 | requestStream.Close(); | 925 | requestStream.Close(); |
926 | |||
927 | // capture how much time was spent writing | ||
928 | tickdata = Util.EnvironmentTickCountSubtract(tickstart); | ||
851 | } | 929 | } |
852 | } | 930 | } |
853 | 931 | ||
@@ -868,7 +946,9 @@ namespace OpenSim.Framework | |||
868 | } | 946 | } |
869 | catch (Exception e) | 947 | catch (Exception e) |
870 | { | 948 | { |
871 | m_log.DebugFormat("[FORMS]: exception occured on receiving reply " + e.ToString()); | 949 | m_log.DebugFormat( |
950 | "[FORMS]: Exception occured on receiving {0} {1}: {2}{3}", | ||
951 | verb, requestUrl, e.Message, e.StackTrace); | ||
872 | } | 952 | } |
873 | finally | 953 | finally |
874 | { | 954 | { |
@@ -881,9 +961,21 @@ namespace OpenSim.Framework | |||
881 | catch (System.InvalidOperationException) | 961 | catch (System.InvalidOperationException) |
882 | { | 962 | { |
883 | // This is what happens when there is invalid XML | 963 | // This is what happens when there is invalid XML |
884 | m_log.DebugFormat("[FORMS]: InvalidOperationException on receiving request"); | 964 | m_log.DebugFormat("[FORMS]: InvalidOperationException on receiving {0} {1}", verb, requestUrl); |
885 | } | 965 | } |
886 | } | 966 | } |
967 | |||
968 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | ||
969 | if (tickdiff > WebUtil.LongCallTime) | ||
970 | m_log.InfoFormat( | ||
971 | "[FORMS]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | ||
972 | reqnum, | ||
973 | verb, | ||
974 | requestUrl, | ||
975 | tickdiff, | ||
976 | tickdata, | ||
977 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); | ||
978 | |||
887 | return respstring; | 979 | return respstring; |
888 | } | 980 | } |
889 | } | 981 | } |
@@ -911,6 +1003,12 @@ namespace OpenSim.Framework | |||
911 | 1003 | ||
912 | public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout) | 1004 | public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout) |
913 | { | 1005 | { |
1006 | int reqnum = WebUtil.RequestNumber++; | ||
1007 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | ||
1008 | |||
1009 | int tickstart = Util.EnvironmentTickCount(); | ||
1010 | int tickdata = 0; | ||
1011 | |||
914 | Type type = typeof(TRequest); | 1012 | Type type = typeof(TRequest); |
915 | TResponse deserial = default(TResponse); | 1013 | TResponse deserial = default(TResponse); |
916 | 1014 | ||
@@ -918,12 +1016,13 @@ namespace OpenSim.Framework | |||
918 | request.Method = verb; | 1016 | request.Method = verb; |
919 | if (pTimeout != 0) | 1017 | if (pTimeout != 0) |
920 | request.Timeout = pTimeout * 1000; | 1018 | request.Timeout = pTimeout * 1000; |
1019 | MemoryStream buffer = null; | ||
921 | 1020 | ||
922 | if ((verb == "POST") || (verb == "PUT")) | 1021 | if ((verb == "POST") || (verb == "PUT")) |
923 | { | 1022 | { |
924 | request.ContentType = "text/xml"; | 1023 | request.ContentType = "text/xml"; |
925 | 1024 | ||
926 | MemoryStream buffer = new MemoryStream(); | 1025 | buffer = new MemoryStream(); |
927 | 1026 | ||
928 | XmlWriterSettings settings = new XmlWriterSettings(); | 1027 | XmlWriterSettings settings = new XmlWriterSettings(); |
929 | settings.Encoding = Encoding.UTF8; | 1028 | settings.Encoding = Encoding.UTF8; |
@@ -946,13 +1045,19 @@ namespace OpenSim.Framework | |||
946 | } | 1045 | } |
947 | catch (Exception e) | 1046 | catch (Exception e) |
948 | { | 1047 | { |
949 | m_log.DebugFormat("[SynchronousRestObjectRequester]: exception in sending data to {0}: {1}", requestUrl, e); | 1048 | m_log.DebugFormat( |
1049 | "[SynchronousRestObjectRequester]: Exception in making request {0} {1}: {2}{3}", | ||
1050 | verb, requestUrl, e.Message, e.StackTrace); | ||
1051 | |||
950 | return deserial; | 1052 | return deserial; |
951 | } | 1053 | } |
952 | finally | 1054 | finally |
953 | { | 1055 | { |
954 | if (requestStream != null) | 1056 | if (requestStream != null) |
955 | requestStream.Close(); | 1057 | requestStream.Close(); |
1058 | |||
1059 | // capture how much time was spent writing | ||
1060 | tickdata = Util.EnvironmentTickCountSubtract(tickstart); | ||
956 | } | 1061 | } |
957 | } | 1062 | } |
958 | 1063 | ||
@@ -968,7 +1073,11 @@ namespace OpenSim.Framework | |||
968 | respStream.Close(); | 1073 | respStream.Close(); |
969 | } | 1074 | } |
970 | else | 1075 | else |
971 | m_log.DebugFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", requestUrl, verb); | 1076 | { |
1077 | m_log.DebugFormat( | ||
1078 | "[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", | ||
1079 | verb, requestUrl); | ||
1080 | } | ||
972 | } | 1081 | } |
973 | } | 1082 | } |
974 | catch (WebException e) | 1083 | catch (WebException e) |
@@ -979,17 +1088,44 @@ namespace OpenSim.Framework | |||
979 | return deserial; | 1088 | return deserial; |
980 | else | 1089 | else |
981 | m_log.ErrorFormat( | 1090 | m_log.ErrorFormat( |
982 | "[SynchronousRestObjectRequester]: WebException {0} {1} {2} {3}", | 1091 | "[SynchronousRestObjectRequester]: WebException for {0} {1} {2}: {3} {4}", |
983 | requestUrl, typeof(TResponse).ToString(), e.Message, e.StackTrace); | 1092 | verb, requestUrl, typeof(TResponse).ToString(), e.Message, e.StackTrace); |
984 | } | 1093 | } |
985 | catch (System.InvalidOperationException) | 1094 | catch (System.InvalidOperationException) |
986 | { | 1095 | { |
987 | // This is what happens when there is invalid XML | 1096 | // This is what happens when there is invalid XML |
988 | m_log.DebugFormat("[SynchronousRestObjectRequester]: Invalid XML {0} {1}", requestUrl, typeof(TResponse).ToString()); | 1097 | m_log.DebugFormat( |
1098 | "[SynchronousRestObjectRequester]: Invalid XML from {0} {1} {2}", | ||
1099 | verb, requestUrl, typeof(TResponse).ToString()); | ||
989 | } | 1100 | } |
990 | catch (Exception e) | 1101 | catch (Exception e) |
991 | { | 1102 | { |
992 | m_log.DebugFormat("[SynchronousRestObjectRequester]: Exception on response from {0} {1}", requestUrl, e); | 1103 | m_log.DebugFormat( |
1104 | "[SynchronousRestObjectRequester]: Exception on response from {0} {1}: {2}{3}", | ||
1105 | verb, requestUrl, e.Message, e.StackTrace); | ||
1106 | } | ||
1107 | |||
1108 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | ||
1109 | if (tickdiff > WebUtil.LongCallTime) | ||
1110 | { | ||
1111 | string originalRequest = null; | ||
1112 | |||
1113 | if (buffer != null) | ||
1114 | { | ||
1115 | originalRequest = Encoding.UTF8.GetString(buffer.ToArray()); | ||
1116 | |||
1117 | if (originalRequest.Length > WebUtil.MaxRequestDiagLength) | ||
1118 | originalRequest = originalRequest.Remove(WebUtil.MaxRequestDiagLength); | ||
1119 | } | ||
1120 | |||
1121 | m_log.InfoFormat( | ||
1122 | "[SynchronousRestObjectRequester]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | ||
1123 | reqnum, | ||
1124 | verb, | ||
1125 | requestUrl, | ||
1126 | tickdiff, | ||
1127 | tickdata, | ||
1128 | originalRequest); | ||
993 | } | 1129 | } |
994 | 1130 | ||
995 | return deserial; | 1131 | return deserial; |