diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 5 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | 6 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs | 175 | ||||
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 24 | ||||
-rw-r--r-- | OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | 10 |
5 files changed, 94 insertions, 126 deletions
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index cc4c5b0..e301bbe 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs | |||
@@ -634,8 +634,6 @@ namespace OpenSim.Data.MySQL | |||
634 | { | 634 | { |
635 | if(reader.HasRows) | 635 | if(reader.HasRows) |
636 | { | 636 | { |
637 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
638 | ": Getting data for {0}.", props.UserId); | ||
639 | reader.Read(); | 637 | reader.Read(); |
640 | props.WebUrl = (string)reader["profileURL"]; | 638 | props.WebUrl = (string)reader["profileURL"]; |
641 | UUID.TryParse((string)reader["profileImage"], out props.ImageId); | 639 | UUID.TryParse((string)reader["profileImage"], out props.ImageId); |
@@ -651,9 +649,6 @@ namespace OpenSim.Data.MySQL | |||
651 | } | 649 | } |
652 | else | 650 | else |
653 | { | 651 | { |
654 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
655 | ": No data for {0}", props.UserId); | ||
656 | |||
657 | props.WebUrl = string.Empty; | 652 | props.WebUrl = string.Empty; |
658 | props.ImageId = UUID.Zero; | 653 | props.ImageId = UUID.Zero; |
659 | props.AboutText = string.Empty; | 654 | props.AboutText = string.Empty; |
diff --git a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs index 0f5b4c8..5494091 100644 --- a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | |||
@@ -584,9 +584,6 @@ namespace OpenSim.Data.SQLite | |||
584 | } | 584 | } |
585 | if(reader != null && reader.Read()) | 585 | if(reader != null && reader.Read()) |
586 | { | 586 | { |
587 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
588 | ": Getting data for {0}.", props.UserId); | ||
589 | |||
590 | props.WebUrl = (string)reader["profileURL"]; | 587 | props.WebUrl = (string)reader["profileURL"]; |
591 | UUID.TryParse((string)reader["profileImage"], out props.ImageId); | 588 | UUID.TryParse((string)reader["profileImage"], out props.ImageId); |
592 | props.AboutText = (string)reader["profileAboutText"]; | 589 | props.AboutText = (string)reader["profileAboutText"]; |
@@ -601,9 +598,6 @@ namespace OpenSim.Data.SQLite | |||
601 | } | 598 | } |
602 | else | 599 | else |
603 | { | 600 | { |
604 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
605 | ": No data for {0}", props.UserId); | ||
606 | |||
607 | props.WebUrl = string.Empty; | 601 | props.WebUrl = string.Empty; |
608 | props.ImageId = UUID.Zero; | 602 | props.ImageId = UUID.Zero; |
609 | props.AboutText = string.Empty; | 603 | props.AboutText = string.Empty; |
diff --git a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs index a44f471..ed6a14c 100644 --- a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs | |||
@@ -48,7 +48,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | #region Web Util | ||
52 | /// <summary> | 51 | /// <summary> |
53 | /// Sends json-rpc request with a serializable type. | 52 | /// Sends json-rpc request with a serializable type. |
54 | /// </summary> | 53 | /// </summary> |
@@ -70,64 +69,62 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
70 | public bool JsonRpcRequest(ref object parameters, string method, string uri, string jsonId) | 69 | public bool JsonRpcRequest(ref object parameters, string method, string uri, string jsonId) |
71 | { | 70 | { |
72 | if (jsonId == null) | 71 | if (jsonId == null) |
73 | throw new ArgumentNullException ("jsonId"); | 72 | throw new ArgumentNullException("jsonId"); |
74 | if (uri == null) | 73 | if (uri == null) |
75 | throw new ArgumentNullException ("uri"); | 74 | throw new ArgumentNullException("uri"); |
76 | if (method == null) | 75 | if (method == null) |
77 | throw new ArgumentNullException ("method"); | 76 | throw new ArgumentNullException("method"); |
78 | if (parameters == null) | 77 | if (parameters == null) |
79 | throw new ArgumentNullException ("parameters"); | 78 | throw new ArgumentNullException("parameters"); |
80 | 79 | ||
81 | // Prep our payload | 80 | OSDMap request = new OSDMap(); |
82 | OSDMap json = new OSDMap(); | 81 | request.Add("jsonrpc", OSD.FromString("2.0")); |
83 | 82 | request.Add("id", OSD.FromString(jsonId)); | |
84 | json.Add("jsonrpc", OSD.FromString("2.0")); | 83 | request.Add("method", OSD.FromString(method)); |
85 | json.Add("id", OSD.FromString(jsonId)); | 84 | request.Add("params", OSD.SerializeMembers(parameters)); |
86 | json.Add("method", OSD.FromString(method)); | 85 | |
87 | 86 | OSDMap response; | |
88 | json.Add("params", OSD.SerializeMembers(parameters)); | ||
89 | |||
90 | string jsonRequestData = OSDParser.SerializeJsonString(json); | ||
91 | byte[] content = Encoding.UTF8.GetBytes(jsonRequestData); | ||
92 | |||
93 | HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
94 | |||
95 | webRequest.ContentType = "application/json-rpc"; | ||
96 | webRequest.Method = "POST"; | ||
97 | |||
98 | //Stream dataStream = webRequest.GetRequestStream(); | ||
99 | //dataStream.Write(content, 0, content.Length); | ||
100 | //dataStream.Close(); | ||
101 | |||
102 | using (Stream dataStream = webRequest.GetRequestStream()) | ||
103 | dataStream.Write(content, 0, content.Length); | ||
104 | |||
105 | WebResponse webResponse = null; | ||
106 | try | 87 | try |
107 | { | 88 | { |
108 | webResponse = webRequest.GetResponse(); | 89 | response = WebUtil.PostToService(uri, request, 10000, true); |
90 | } | ||
91 | catch (Exception e) | ||
92 | { | ||
93 | m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e); | ||
94 | return false; | ||
95 | } | ||
96 | |||
97 | if (!response.ContainsKey("_Result")) | ||
98 | { | ||
99 | m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", | ||
100 | method, OSDParser.SerializeJsonString(response)); | ||
101 | return false; | ||
109 | } | 102 | } |
110 | catch (WebException e) | 103 | response = (OSDMap)response["_Result"]; |
104 | |||
105 | OSD data; | ||
106 | |||
107 | if (response.ContainsKey("error")) | ||
111 | { | 108 | { |
112 | Console.WriteLine("Web Error" + e.Message); | 109 | data = response["error"]; |
113 | Console.WriteLine ("Please check input"); | 110 | m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}", |
111 | method, OSDParser.SerializeJsonString(data)); | ||
114 | return false; | 112 | return false; |
115 | } | 113 | } |
116 | 114 | ||
117 | using (webResponse) | 115 | if (!response.ContainsKey("result")) |
118 | using (Stream rstream = webResponse.GetResponseStream()) | ||
119 | { | 116 | { |
120 | OSDMap mret = (OSDMap)OSDParser.DeserializeJson(rstream); | 117 | m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", |
121 | 118 | method, OSDParser.SerializeJsonString(response)); | |
122 | if (mret.ContainsKey("error")) | 119 | return false; |
123 | return false; | ||
124 | |||
125 | // get params... | ||
126 | OSD.DeserializeMembers(ref parameters, (OSDMap)mret["result"]); | ||
127 | return true; | ||
128 | } | 120 | } |
121 | |||
122 | data = response["result"]; | ||
123 | OSD.DeserializeMembers(ref parameters, (OSDMap)data); | ||
124 | |||
125 | return true; | ||
129 | } | 126 | } |
130 | 127 | ||
131 | /// <summary> | 128 | /// <summary> |
132 | /// Sends json-rpc request with OSD parameter. | 129 | /// Sends json-rpc request with OSD parameter. |
133 | /// </summary> | 130 | /// </summary> |
@@ -135,7 +132,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
135 | /// The rpc request. | 132 | /// The rpc request. |
136 | /// </returns> | 133 | /// </returns> |
137 | /// <param name='data'> | 134 | /// <param name='data'> |
138 | /// data - incoming as parameters, outgong as result/error | 135 | /// data - incoming as parameters, outgoing as result/error |
139 | /// </param> | 136 | /// </param> |
140 | /// <param name='method'> | 137 | /// <param name='method'> |
141 | /// Json-rpc method to call. | 138 | /// Json-rpc method to call. |
@@ -148,64 +145,46 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
148 | /// </param> | 145 | /// </param> |
149 | public bool JsonRpcRequest(ref OSD data, string method, string uri, string jsonId) | 146 | public bool JsonRpcRequest(ref OSD data, string method, string uri, string jsonId) |
150 | { | 147 | { |
151 | OSDMap map = new OSDMap(); | 148 | if (string.IsNullOrEmpty(jsonId)) |
152 | 149 | jsonId = UUID.Random().ToString(); | |
153 | map["jsonrpc"] = "2.0"; | 150 | |
154 | if(string.IsNullOrEmpty(jsonId)) | 151 | OSDMap request = new OSDMap(); |
155 | map["id"] = UUID.Random().ToString(); | 152 | request.Add("jsonrpc", OSD.FromString("2.0")); |
156 | else | 153 | request.Add("id", OSD.FromString(jsonId)); |
157 | map["id"] = jsonId; | 154 | request.Add("method", OSD.FromString(method)); |
158 | 155 | request.Add("params", data); | |
159 | map["method"] = method; | 156 | |
160 | map["params"] = data; | 157 | OSDMap response; |
161 | |||
162 | string jsonRequestData = OSDParser.SerializeJsonString(map); | ||
163 | byte[] content = Encoding.UTF8.GetBytes(jsonRequestData); | ||
164 | |||
165 | HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
166 | webRequest.ContentType = "application/json-rpc"; | ||
167 | webRequest.Method = "POST"; | ||
168 | |||
169 | using (Stream dataStream = webRequest.GetRequestStream()) | ||
170 | dataStream.Write(content, 0, content.Length); | ||
171 | |||
172 | WebResponse webResponse = null; | ||
173 | try | 158 | try |
174 | { | 159 | { |
175 | webResponse = webRequest.GetResponse(); | 160 | response = WebUtil.PostToService(uri, request, 10000, true); |
176 | } | 161 | } |
177 | catch (WebException e) | 162 | catch (Exception e) |
178 | { | 163 | { |
179 | Console.WriteLine("Web Error" + e.Message); | 164 | m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e); |
180 | Console.WriteLine ("Please check input"); | ||
181 | return false; | 165 | return false; |
182 | } | 166 | } |
183 | 167 | ||
184 | using (webResponse) | 168 | if (!response.ContainsKey("_Result")) |
185 | using (Stream rstream = webResponse.GetResponseStream()) | ||
186 | { | 169 | { |
187 | OSDMap response = new OSDMap(); | 170 | m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", |
188 | try | 171 | method, OSDParser.SerializeJsonString(response)); |
189 | { | 172 | return false; |
190 | response = (OSDMap)OSDParser.DeserializeJson(rstream); | ||
191 | } | ||
192 | catch (Exception e) | ||
193 | { | ||
194 | m_log.DebugFormat("[JSONRPC]: JsonRpcRequest Error {0}", e.Message); | ||
195 | return false; | ||
196 | } | ||
197 | |||
198 | if (response.ContainsKey("error")) | ||
199 | { | ||
200 | data = response["error"]; | ||
201 | return false; | ||
202 | } | ||
203 | |||
204 | data = response; | ||
205 | |||
206 | return true; | ||
207 | } | 173 | } |
174 | response = (OSDMap)response["_Result"]; | ||
175 | |||
176 | if (response.ContainsKey("error")) | ||
177 | { | ||
178 | data = response["error"]; | ||
179 | m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}", | ||
180 | method, OSDParser.SerializeJsonString(data)); | ||
181 | return false; | ||
182 | } | ||
183 | |||
184 | data = response; | ||
185 | |||
186 | return true; | ||
208 | } | 187 | } |
209 | #endregion Web Util | 188 | |
210 | } | 189 | } |
211 | } | 190 | } |
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 768ff16..8f5bc0c 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -127,41 +127,41 @@ namespace OpenSim.Framework | |||
127 | /// </summary> | 127 | /// </summary> |
128 | public static OSDMap PutToServiceCompressed(string url, OSDMap data, int timeout) | 128 | public static OSDMap PutToServiceCompressed(string url, OSDMap data, int timeout) |
129 | { | 129 | { |
130 | return ServiceOSDRequest(url,data, "PUT", timeout, true); | 130 | return ServiceOSDRequest(url,data, "PUT", timeout, true, false); |
131 | } | 131 | } |
132 | 132 | ||
133 | public static OSDMap PutToService(string url, OSDMap data, int timeout) | 133 | public static OSDMap PutToService(string url, OSDMap data, int timeout) |
134 | { | 134 | { |
135 | return ServiceOSDRequest(url,data, "PUT", timeout, false); | 135 | return ServiceOSDRequest(url,data, "PUT", timeout, false, false); |
136 | } | 136 | } |
137 | 137 | ||
138 | public static OSDMap PostToService(string url, OSDMap data, int timeout) | 138 | public static OSDMap PostToService(string url, OSDMap data, int timeout, bool rpc) |
139 | { | 139 | { |
140 | return ServiceOSDRequest(url, data, "POST", timeout, false); | 140 | return ServiceOSDRequest(url, data, "POST", timeout, false, rpc); |
141 | } | 141 | } |
142 | 142 | ||
143 | public static OSDMap PostToServiceCompressed(string url, OSDMap data, int timeout) | 143 | public static OSDMap PostToServiceCompressed(string url, OSDMap data, int timeout) |
144 | { | 144 | { |
145 | return ServiceOSDRequest(url, data, "POST", timeout, true); | 145 | return ServiceOSDRequest(url, data, "POST", timeout, true, false); |
146 | } | 146 | } |
147 | 147 | ||
148 | public static OSDMap GetFromService(string url, int timeout) | 148 | public static OSDMap GetFromService(string url, int timeout) |
149 | { | 149 | { |
150 | return ServiceOSDRequest(url, null, "GET", timeout, false); | 150 | return ServiceOSDRequest(url, null, "GET", timeout, false, false); |
151 | } | 151 | } |
152 | 152 | ||
153 | public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed) | 153 | public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc) |
154 | { | 154 | { |
155 | if (SerializeOSDRequestsPerEndpoint) | 155 | if (SerializeOSDRequestsPerEndpoint) |
156 | { | 156 | { |
157 | lock (EndPointLock(url)) | 157 | lock (EndPointLock(url)) |
158 | { | 158 | { |
159 | return ServiceOSDRequestWorker(url, data, method, timeout, compressed); | 159 | return ServiceOSDRequestWorker(url, data, method, timeout, compressed, rpc); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | else | 162 | else |
163 | { | 163 | { |
164 | return ServiceOSDRequestWorker(url, data, method, timeout, compressed); | 164 | return ServiceOSDRequestWorker(url, data, method, timeout, compressed, rpc); |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
@@ -217,7 +217,7 @@ namespace OpenSim.Framework | |||
217 | LogOutgoingDetail("RESPONSE: ", input); | 217 | LogOutgoingDetail("RESPONSE: ", input); |
218 | } | 218 | } |
219 | 219 | ||
220 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) | 220 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed, bool rpc) |
221 | { | 221 | { |
222 | int reqnum = RequestNumber++; | 222 | int reqnum = RequestNumber++; |
223 | 223 | ||
@@ -251,7 +251,7 @@ namespace OpenSim.Framework | |||
251 | 251 | ||
252 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); | 252 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strBuffer); |
253 | 253 | ||
254 | request.ContentType = "application/json"; | 254 | request.ContentType = rpc ? "application/json-rpc" : "application/json"; |
255 | 255 | ||
256 | if (compressed) | 256 | if (compressed) |
257 | { | 257 | { |
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index a5520c4..d9fe5a0 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | |||
@@ -136,7 +136,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
136 | } | 136 | } |
137 | 137 | ||
138 | // Try the old version, uncompressed | 138 | // Try the old version, uncompressed |
139 | result = WebUtil.PostToService(uri, args, 30000); | 139 | result = WebUtil.PostToService(uri, args, 30000, false); |
140 | 140 | ||
141 | if (result["Success"].AsBoolean()) | 141 | if (result["Success"].AsBoolean()) |
142 | { | 142 | { |
@@ -302,7 +302,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
302 | 302 | ||
303 | try | 303 | try |
304 | { | 304 | { |
305 | OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false); | 305 | OSDMap result = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false); |
306 | bool success = result["success"].AsBoolean(); | 306 | bool success = result["success"].AsBoolean(); |
307 | if (result.ContainsKey("_Result")) | 307 | if (result.ContainsKey("_Result")) |
308 | { | 308 | { |
@@ -365,7 +365,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
365 | 365 | ||
366 | try | 366 | try |
367 | { | 367 | { |
368 | WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); | 368 | WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false, false); |
369 | } | 369 | } |
370 | catch (Exception e) | 370 | catch (Exception e) |
371 | { | 371 | { |
@@ -384,7 +384,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
384 | 384 | ||
385 | try | 385 | try |
386 | { | 386 | { |
387 | WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); | 387 | WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false, false); |
388 | } | 388 | } |
389 | catch (Exception e) | 389 | catch (Exception e) |
390 | { | 390 | { |
@@ -431,7 +431,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
431 | args["destination_name"] = OSD.FromString(destination.RegionName); | 431 | args["destination_name"] = OSD.FromString(destination.RegionName); |
432 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | 432 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); |
433 | 433 | ||
434 | OSDMap result = WebUtil.PostToService(uri, args, 40000); | 434 | OSDMap result = WebUtil.PostToService(uri, args, 40000, false); |
435 | 435 | ||
436 | if (result == null) | 436 | if (result == null) |
437 | return false; | 437 | return false; |