aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/WebUtil.cs
diff options
context:
space:
mode:
authorMelanie2013-06-13 02:49:43 +0100
committerMelanie2013-06-13 02:49:43 +0100
commit9975c5674c002be0e17db02b589c388b684f63a9 (patch)
treeaa727252685987781696db21f9eee58dd6b6d023 /OpenSim/Framework/WebUtil.cs
parentMerge branch 'master' into careminster (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-9975c5674c002be0e17db02b589c388b684f63a9.zip
opensim-SC_OLD-9975c5674c002be0e17db02b589c388b684f63a9.tar.gz
opensim-SC_OLD-9975c5674c002be0e17db02b589c388b684f63a9.tar.bz2
opensim-SC_OLD-9975c5674c002be0e17db02b589c388b684f63a9.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Framework/WebUtil.cs')
-rw-r--r--OpenSim/Framework/WebUtil.cs54
1 files changed, 52 insertions, 2 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index bf57fd4..312e9a9 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -151,6 +151,39 @@ namespace OpenSim.Framework
151 } 151 }
152 } 152 }
153 153
154 public static void LogOutgoingDetail(Stream outputStream)
155 {
156 using (StreamReader reader = new StreamReader(Util.Copy(outputStream), Encoding.UTF8))
157 {
158 string output;
159
160 if (DebugLevel == 5)
161 {
162 const int sampleLength = 80;
163 char[] sampleChars = new char[sampleLength];
164 reader.Read(sampleChars, 0, sampleLength);
165 output = new string(sampleChars);
166 }
167 else
168 {
169 output = reader.ReadToEnd();
170 }
171
172 LogOutgoingDetail(output);
173 }
174 }
175
176 public static void LogOutgoingDetail(string output)
177 {
178 if (DebugLevel == 5)
179 {
180 output = output.Substring(0, 80);
181 output = output + "...";
182 }
183
184 m_log.DebugFormat("[WEB UTIL]: {0}", output.Replace("\n", @"\n"));
185 }
186
154 private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) 187 private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed)
155 { 188 {
156 int reqnum = RequestNumber++; 189 int reqnum = RequestNumber++;
@@ -178,7 +211,11 @@ namespace OpenSim.Framework
178 // If there is some input, write it into the request 211 // If there is some input, write it into the request
179 if (data != null) 212 if (data != null)
180 { 213 {
181 strBuffer = OSDParser.SerializeJsonString(data); 214 strBuffer = OSDParser.SerializeJsonString(data);
215
216 if (DebugLevel >= 5)
217 LogOutgoingDetail(strBuffer);
218
182 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); 219 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer);
183 220
184 if (compressed) 221 if (compressed)
@@ -358,6 +395,10 @@ namespace OpenSim.Framework
358 if (data != null) 395 if (data != null)
359 { 396 {
360 queryString = BuildQueryString(data); 397 queryString = BuildQueryString(data);
398
399 if (DebugLevel >= 5)
400 LogOutgoingDetail(queryString);
401
361 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString); 402 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(queryString);
362 403
363 request.ContentLength = buffer.Length; 404 request.ContentLength = buffer.Length;
@@ -769,6 +810,9 @@ namespace OpenSim.Framework
769 int length = (int)buffer.Length; 810 int length = (int)buffer.Length;
770 request.ContentLength = length; 811 request.ContentLength = length;
771 812
813 if (WebUtil.DebugLevel >= 5)
814 WebUtil.LogOutgoingDetail(buffer);
815
772 request.BeginGetRequestStream(delegate(IAsyncResult res) 816 request.BeginGetRequestStream(delegate(IAsyncResult res)
773 { 817 {
774 Stream requestStream = request.EndGetRequestStream(res); 818 Stream requestStream = request.EndGetRequestStream(res);
@@ -966,6 +1010,9 @@ namespace OpenSim.Framework
966 length = (int)obj.Length; 1010 length = (int)obj.Length;
967 request.ContentLength = length; 1011 request.ContentLength = length;
968 1012
1013 if (WebUtil.DebugLevel >= 5)
1014 WebUtil.LogOutgoingDetail(buffer);
1015
969 Stream requestStream = null; 1016 Stream requestStream = null;
970 try 1017 try
971 { 1018 {
@@ -1111,6 +1158,9 @@ namespace OpenSim.Framework
1111 int length = (int)buffer.Length; 1158 int length = (int)buffer.Length;
1112 request.ContentLength = length; 1159 request.ContentLength = length;
1113 1160
1161 if (WebUtil.DebugLevel >= 5)
1162 WebUtil.LogOutgoingDetail(buffer);
1163
1114 Stream requestStream = null; 1164 Stream requestStream = null;
1115 try 1165 try
1116 { 1166 {
@@ -1213,4 +1263,4 @@ namespace OpenSim.Framework
1213 return deserial; 1263 return deserial;
1214 } 1264 }
1215 } 1265 }
1216} 1266} \ No newline at end of file