diff options
author | Mic Bowman | 2012-02-27 15:15:03 -0800 |
---|---|---|
committer | Mic Bowman | 2012-02-27 15:15:03 -0800 |
commit | 4268427ac36410452bcfee9fe51d7deeb0ef303d (patch) | |
tree | f3f78f3c81b19a00e9aab4ef86090d7b46eda4cf /OpenSim/Framework/WebUtil.cs | |
parent | HG: Remove async in posting assets to foreign grid. Mono hates concurrency th... (diff) | |
download | opensim-SC-4268427ac36410452bcfee9fe51d7deeb0ef303d.zip opensim-SC-4268427ac36410452bcfee9fe51d7deeb0ef303d.tar.gz opensim-SC-4268427ac36410452bcfee9fe51d7deeb0ef303d.tar.bz2 opensim-SC-4268427ac36410452bcfee9fe51d7deeb0ef303d.tar.xz |
Some clean up in WebUtil, remove unused ServiceRequest function.
Diffstat (limited to 'OpenSim/Framework/WebUtil.cs')
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 78 |
1 files changed, 7 insertions, 71 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index b761dfe..af25da9 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -63,77 +63,7 @@ namespace OpenSim.Framework | |||
63 | // a "long" call for warning & debugging purposes | 63 | // a "long" call for warning & debugging purposes |
64 | public const int LongCallTime = 500; | 64 | public const int LongCallTime = 500; |
65 | 65 | ||
66 | // /// <summary> | 66 | #region JSONRequest |
67 | // /// Send LLSD to an HTTP client in application/llsd+json form | ||
68 | // /// </summary> | ||
69 | // /// <param name="response">HTTP response to send the data in</param> | ||
70 | // /// <param name="body">LLSD to send to the client</param> | ||
71 | // public static void SendJSONResponse(OSHttpResponse response, OSDMap body) | ||
72 | // { | ||
73 | // byte[] responseData = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(body)); | ||
74 | // | ||
75 | // response.ContentEncoding = Encoding.UTF8; | ||
76 | // response.ContentLength = responseData.Length; | ||
77 | // response.ContentType = "application/llsd+json"; | ||
78 | // response.Body.Write(responseData, 0, responseData.Length); | ||
79 | // } | ||
80 | // | ||
81 | // /// <summary> | ||
82 | // /// Send LLSD to an HTTP client in application/llsd+xml form | ||
83 | // /// </summary> | ||
84 | // /// <param name="response">HTTP response to send the data in</param> | ||
85 | // /// <param name="body">LLSD to send to the client</param> | ||
86 | // public static void SendXMLResponse(OSHttpResponse response, OSDMap body) | ||
87 | // { | ||
88 | // byte[] responseData = OSDParser.SerializeLLSDXmlBytes(body); | ||
89 | // | ||
90 | // response.ContentEncoding = Encoding.UTF8; | ||
91 | // response.ContentLength = responseData.Length; | ||
92 | // response.ContentType = "application/llsd+xml"; | ||
93 | // response.Body.Write(responseData, 0, responseData.Length); | ||
94 | // } | ||
95 | |||
96 | /// <summary> | ||
97 | /// Make a GET or GET-like request to a web service that returns LLSD | ||
98 | /// or JSON data | ||
99 | /// </summary> | ||
100 | public static OSDMap ServiceRequest(string url, string httpVerb) | ||
101 | { | ||
102 | string errorMessage; | ||
103 | |||
104 | try | ||
105 | { | ||
106 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); | ||
107 | request.Method = httpVerb; | ||
108 | |||
109 | using (WebResponse response = request.GetResponse()) | ||
110 | { | ||
111 | using (Stream responseStream = response.GetResponseStream()) | ||
112 | { | ||
113 | try | ||
114 | { | ||
115 | string responseStr = responseStream.GetStreamString(); | ||
116 | OSD responseOSD = OSDParser.Deserialize(responseStr); | ||
117 | if (responseOSD.Type == OSDType.Map) | ||
118 | return (OSDMap)responseOSD; | ||
119 | else | ||
120 | errorMessage = "Response format was invalid."; | ||
121 | } | ||
122 | catch | ||
123 | { | ||
124 | errorMessage = "Failed to parse the response."; | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | catch (Exception ex) | ||
130 | { | ||
131 | m_log.Warn(httpVerb + " on URL " + url + " failed: " + ex.Message); | ||
132 | errorMessage = ex.Message; | ||
133 | } | ||
134 | |||
135 | return new OSDMap { { "Message", OSD.FromString("Service request failed. " + errorMessage) } }; | ||
136 | } | ||
137 | 67 | ||
138 | /// <summary> | 68 | /// <summary> |
139 | /// PUT JSON-encoded data to a web service that returns LLSD or | 69 | /// PUT JSON-encoded data to a web service that returns LLSD or |
@@ -303,6 +233,10 @@ namespace OpenSim.Framework | |||
303 | return result; | 233 | return result; |
304 | } | 234 | } |
305 | 235 | ||
236 | #endregion JSONRequest | ||
237 | |||
238 | #region FormRequest | ||
239 | |||
306 | /// <summary> | 240 | /// <summary> |
307 | /// POST URL-encoded form data to a web service that returns LLSD or | 241 | /// POST URL-encoded form data to a web service that returns LLSD or |
308 | /// JSON data | 242 | /// JSON data |
@@ -397,6 +331,8 @@ namespace OpenSim.Framework | |||
397 | result["Message"] = OSD.FromString("Service request failed: " + msg); | 331 | result["Message"] = OSD.FromString("Service request failed: " + msg); |
398 | return result; | 332 | return result; |
399 | } | 333 | } |
334 | |||
335 | #endregion FormRequest | ||
400 | 336 | ||
401 | #region Uri | 337 | #region Uri |
402 | 338 | ||