diff options
author | Justin Clark-Casey (justincc) | 2014-01-31 00:51:22 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-01-31 00:51:22 +0000 |
commit | b2878eb77354ea54a0a5e92fc30c3cd3ba1984fa (patch) | |
tree | 55094e48f86a95630e3854c64898ce146df063ed /OpenSim/Region/CoreModules | |
parent | Merge branch 'justincc-master' (diff) | |
parent | Make sure Web streams are disposed after use (diff) | |
download | opensim-SC_OLD-b2878eb77354ea54a0a5e92fc30c3cd3ba1984fa.zip opensim-SC_OLD-b2878eb77354ea54a0a5e92fc30c3cd3ba1984fa.tar.gz opensim-SC_OLD-b2878eb77354ea54a0a5e92fc30c3cd3ba1984fa.tar.bz2 opensim-SC_OLD-b2878eb77354ea54a0a5e92fc30c3cd3ba1984fa.tar.xz |
Merge branch 'justincc-master'
Diffstat (limited to 'OpenSim/Region/CoreModules')
3 files changed, 39 insertions, 47 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 7e50cc6..2da0a74 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | |||
@@ -1290,9 +1290,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles | |||
1290 | webRequest.ContentType = "application/json-rpc"; | 1290 | webRequest.ContentType = "application/json-rpc"; |
1291 | webRequest.Method = "POST"; | 1291 | webRequest.Method = "POST"; |
1292 | 1292 | ||
1293 | Stream dataStream = webRequest.GetRequestStream(); | 1293 | using (Stream dataStream = webRequest.GetRequestStream()) |
1294 | dataStream.Write(content, 0, content.Length); | 1294 | dataStream.Write(content, 0, content.Length); |
1295 | dataStream.Close(); | ||
1296 | 1295 | ||
1297 | WebResponse webResponse = null; | 1296 | WebResponse webResponse = null; |
1298 | try | 1297 | try |
@@ -1306,26 +1305,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles | |||
1306 | return false; | 1305 | return false; |
1307 | } | 1306 | } |
1308 | 1307 | ||
1309 | Stream rstream = webResponse.GetResponseStream(); | 1308 | using (webResponse) |
1310 | 1309 | using (Stream rstream = webResponse.GetResponseStream()) | |
1311 | OSDMap mret = new OSDMap(); | ||
1312 | try | ||
1313 | { | ||
1314 | mret = (OSDMap)OSDParser.DeserializeJson(rstream); | ||
1315 | } | ||
1316 | catch (Exception e) | ||
1317 | { | 1310 | { |
1318 | m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message); | 1311 | OSDMap mret = (OSDMap)OSDParser.DeserializeJson(rstream); |
1319 | return false; | ||
1320 | } | ||
1321 | 1312 | ||
1313 | if (mret.ContainsKey("error")) | ||
1314 | return false; | ||
1322 | 1315 | ||
1323 | if (mret.ContainsKey("error")) | 1316 | // get params... |
1324 | return false; | 1317 | OSD.DeserializeMembers(ref parameters, (OSDMap)mret["result"]); |
1325 | 1318 | return true; | |
1326 | // get params... | 1319 | } |
1327 | OSD.DeserializeMembers(ref parameters, (OSDMap) mret["result"]); | ||
1328 | return true; | ||
1329 | } | 1320 | } |
1330 | 1321 | ||
1331 | /// <summary> | 1322 | /// <summary> |
@@ -1366,9 +1357,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles | |||
1366 | webRequest.ContentType = "application/json-rpc"; | 1357 | webRequest.ContentType = "application/json-rpc"; |
1367 | webRequest.Method = "POST"; | 1358 | webRequest.Method = "POST"; |
1368 | 1359 | ||
1369 | Stream dataStream = webRequest.GetRequestStream(); | 1360 | using (Stream dataStream = webRequest.GetRequestStream()) |
1370 | dataStream.Write(content, 0, content.Length); | 1361 | dataStream.Write(content, 0, content.Length); |
1371 | dataStream.Close(); | ||
1372 | 1362 | ||
1373 | WebResponse webResponse = null; | 1363 | WebResponse webResponse = null; |
1374 | try | 1364 | try |
@@ -1382,29 +1372,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles | |||
1382 | return false; | 1372 | return false; |
1383 | } | 1373 | } |
1384 | 1374 | ||
1385 | Stream rstream = webResponse.GetResponseStream(); | 1375 | using (webResponse) |
1386 | 1376 | using (Stream rstream = webResponse.GetResponseStream()) | |
1387 | OSDMap response = new OSDMap(); | ||
1388 | try | ||
1389 | { | ||
1390 | response = (OSDMap)OSDParser.DeserializeJson(rstream); | ||
1391 | } | ||
1392 | catch (Exception e) | ||
1393 | { | 1377 | { |
1394 | m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message); | 1378 | OSDMap response = new OSDMap(); |
1395 | return false; | 1379 | try |
1396 | } | 1380 | { |
1381 | response = (OSDMap)OSDParser.DeserializeJson(rstream); | ||
1382 | } | ||
1383 | catch (Exception e) | ||
1384 | { | ||
1385 | m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message); | ||
1386 | return false; | ||
1387 | } | ||
1397 | 1388 | ||
1398 | if(response.ContainsKey("error")) | 1389 | if (response.ContainsKey("error")) |
1399 | { | 1390 | { |
1400 | data = response["error"]; | 1391 | data = response["error"]; |
1401 | return false; | 1392 | return false; |
1402 | } | 1393 | } |
1403 | 1394 | ||
1404 | data = response; | 1395 | data = response; |
1405 | 1396 | ||
1406 | return true; | 1397 | return true; |
1398 | } | ||
1407 | } | 1399 | } |
1400 | |||
1408 | #endregion Web Util | 1401 | #endregion Web Util |
1409 | } | 1402 | } |
1410 | } \ No newline at end of file | 1403 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index c3a8afd..a7237ea 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | |||
@@ -488,9 +488,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
488 | byte[] data = Util.UTF8.GetBytes(OutboundBody); | 488 | byte[] data = Util.UTF8.GetBytes(OutboundBody); |
489 | 489 | ||
490 | Request.ContentLength = data.Length; | 490 | Request.ContentLength = data.Length; |
491 | Stream bstream = Request.GetRequestStream(); | 491 | using (Stream bstream = Request.GetRequestStream()) |
492 | bstream.Write(data, 0, data.Length); | 492 | bstream.Write(data, 0, data.Length); |
493 | bstream.Close(); | ||
494 | } | 493 | } |
495 | 494 | ||
496 | try | 495 | try |
@@ -584,4 +583,4 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
584 | Request.Abort(); | 583 | Request.Abort(); |
585 | } | 584 | } |
586 | } | 585 | } |
587 | } \ No newline at end of file | 586 | } |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index f57be83..a3b0f39 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -899,7 +899,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
899 | finally | 899 | finally |
900 | { | 900 | { |
901 | if (os != null) | 901 | if (os != null) |
902 | os.Close(); | 902 | os.Dispose(); |
903 | } | 903 | } |
904 | 904 | ||
905 | string response_mapItems_reply = null; | 905 | string response_mapItems_reply = null; |