aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
authorOren Hurvitz2013-11-28 23:07:14 +0200
committerOren Hurvitz2014-03-25 09:36:53 +0100
commitf901a3820497e0d99accb6f5f60f6517e07c2c8f (patch)
treeced16f5b06d11e2ff109716c0682d27c8d3ed753 /OpenSim/Framework/Util.cs
parentFixed unit tests due to changes in the threadpool (diff)
downloadopensim-SC_OLD-f901a3820497e0d99accb6f5f60f6517e07c2c8f.zip
opensim-SC_OLD-f901a3820497e0d99accb6f5f60f6517e07c2c8f.tar.gz
opensim-SC_OLD-f901a3820497e0d99accb6f5f60f6517e07c2c8f.tar.bz2
opensim-SC_OLD-f901a3820497e0d99accb6f5f60f6517e07c2c8f.tar.xz
Improved logging of HTTP requests
- MemoryBuffer isn't seekable, so we can't log it. Log the string instead. - Handle compressed streams - Don't attempt to dump binary data. Either don't log it at all (if we know it's binary), or at least convert non-ASCII characters to ASCII. - Log responses to HTTP requests - Use the same log prefix for all of these log messages ("[LOGHTTP]"), to make them easy to see at a glance - Increased the snippet length to 200 (80 doesn't show enough), and add "..." only if the message was actually truncated Resolves http://opensimulator.org/mantis/view.php?id=6949
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index ae720f1..ce4af8b 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1510,6 +1510,46 @@ namespace OpenSim.Framework
1510 return result; 1510 return result;
1511 } 1511 }
1512 1512
1513 public static void BinaryToASCII(char[] chars)
1514 {
1515 for (int i = 0; i < chars.Length; i++)
1516 {
1517 char ch = chars[i];
1518 if (ch < 32 || ch > 127)
1519 chars[i] = '.';
1520 }
1521 }
1522
1523 public static string BinaryToASCII(string src)
1524 {
1525 char[] chars = src.ToCharArray();
1526 BinaryToASCII(chars);
1527 return new String(chars);
1528 }
1529
1530 /// <summary>
1531 /// Reads a known number of bytes from a stream.
1532 /// Throws EndOfStreamException if the stream doesn't contain enough data.
1533 /// </summary>
1534 /// <param name="stream">The stream to read data from</param>
1535 /// <param name="data">The array to write bytes into. The array
1536 /// will be completely filled from the stream, so an appropriate
1537 /// size must be given.</param>
1538 public static void ReadStream(Stream stream, byte[] data)
1539 {
1540 int offset = 0;
1541 int remaining = data.Length;
1542
1543 while (remaining > 0)
1544 {
1545 int read = stream.Read(data, offset, remaining);
1546 if (read <= 0)
1547 throw new EndOfStreamException(String.Format("End of stream reached with {0} bytes left to read", remaining));
1548 remaining -= read;
1549 offset += read;
1550 }
1551 }
1552
1513 public static Guid GetHashGuid(string data, string salt) 1553 public static Guid GetHashGuid(string data, string salt)
1514 { 1554 {
1515 byte[] hash = ComputeMD5Hash(data + salt); 1555 byte[] hash = ComputeMD5Hash(data + salt);