diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 54 |
1 files changed, 13 insertions, 41 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 6b39345..c7f1bdb 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -265,10 +265,12 @@ namespace OpenSim.Framework | |||
265 | { | 265 | { |
266 | using (Stream responseStream = response.GetResponseStream()) | 266 | using (Stream responseStream = response.GetResponseStream()) |
267 | { | 267 | { |
268 | string responseStr = null; | 268 | using (StreamReader reader = new StreamReader(responseStream)) |
269 | responseStr = responseStream.GetStreamString(); | 269 | { |
270 | // m_log.DebugFormat("[WEB UTIL]: <{0}> response is <{1}>",reqnum,responseStr); | 270 | string responseStr = reader.ReadToEnd(); |
271 | return CanonicalizeResults(responseStr); | 271 | // m_log.DebugFormat("[WEB UTIL]: <{0}> response is <{1}>",reqnum,responseStr); |
272 | return CanonicalizeResults(responseStr); | ||
273 | } | ||
272 | } | 274 | } |
273 | } | 275 | } |
274 | } | 276 | } |
@@ -426,12 +428,14 @@ namespace OpenSim.Framework | |||
426 | { | 428 | { |
427 | using (Stream responseStream = response.GetResponseStream()) | 429 | using (Stream responseStream = response.GetResponseStream()) |
428 | { | 430 | { |
429 | string responseStr = null; | 431 | using (StreamReader reader = new StreamReader(responseStream)) |
432 | { | ||
433 | string responseStr = reader.ReadToEnd(); | ||
434 | OSD responseOSD = OSDParser.Deserialize(responseStr); | ||
430 | 435 | ||
431 | responseStr = responseStream.GetStreamString(); | 436 | if (responseOSD.Type == OSDType.Map) |
432 | OSD responseOSD = OSDParser.Deserialize(responseStr); | 437 | return (OSDMap)responseOSD; |
433 | if (responseOSD.Type == OSDType.Map) | 438 | } |
434 | return (OSDMap)responseOSD; | ||
435 | } | 439 | } |
436 | } | 440 | } |
437 | } | 441 | } |
@@ -645,38 +649,6 @@ namespace OpenSim.Framework | |||
645 | return totalCopiedBytes; | 649 | return totalCopiedBytes; |
646 | } | 650 | } |
647 | 651 | ||
648 | /// <summary> | ||
649 | /// Converts an entire stream to a string, regardless of current stream | ||
650 | /// position | ||
651 | /// </summary> | ||
652 | /// <param name="stream">The stream to convert to a string</param> | ||
653 | /// <returns></returns> | ||
654 | /// <remarks>When this method is done, the stream position will be | ||
655 | /// reset to its previous position before this method was called</remarks> | ||
656 | public static string GetStreamString(this Stream stream) | ||
657 | { | ||
658 | string value = null; | ||
659 | |||
660 | if (stream != null && stream.CanRead) | ||
661 | { | ||
662 | long rewindPos = -1; | ||
663 | |||
664 | if (stream.CanSeek) | ||
665 | { | ||
666 | rewindPos = stream.Position; | ||
667 | stream.Seek(0, SeekOrigin.Begin); | ||
668 | } | ||
669 | |||
670 | StreamReader reader = new StreamReader(stream); | ||
671 | value = reader.ReadToEnd(); | ||
672 | |||
673 | if (rewindPos >= 0) | ||
674 | stream.Seek(rewindPos, SeekOrigin.Begin); | ||
675 | } | ||
676 | |||
677 | return value; | ||
678 | } | ||
679 | |||
680 | #endregion Stream | 652 | #endregion Stream |
681 | 653 | ||
682 | public class QBasedComparer : IComparer | 654 | public class QBasedComparer : IComparer |