diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index b761dfe2a8..af25da9b04 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -63,77 +63,7 @@ namespace OpenSim.Framework // a "long" call for warning & debugging purposes public const int LongCallTime = 500; -// /// -// /// Send LLSD to an HTTP client in application/llsd+json form -// /// -// /// HTTP response to send the data in -// /// LLSD to send to the client -// public static void SendJSONResponse(OSHttpResponse response, OSDMap body) -// { -// byte[] responseData = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(body)); -// -// response.ContentEncoding = Encoding.UTF8; -// response.ContentLength = responseData.Length; -// response.ContentType = "application/llsd+json"; -// response.Body.Write(responseData, 0, responseData.Length); -// } -// -// /// -// /// Send LLSD to an HTTP client in application/llsd+xml form -// /// -// /// HTTP response to send the data in -// /// LLSD to send to the client -// public static void SendXMLResponse(OSHttpResponse response, OSDMap body) -// { -// byte[] responseData = OSDParser.SerializeLLSDXmlBytes(body); -// -// response.ContentEncoding = Encoding.UTF8; -// response.ContentLength = responseData.Length; -// response.ContentType = "application/llsd+xml"; -// response.Body.Write(responseData, 0, responseData.Length); -// } - - /// - /// Make a GET or GET-like request to a web service that returns LLSD - /// or JSON data - /// - public static OSDMap ServiceRequest(string url, string httpVerb) - { - string errorMessage; - - try - { - HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); - request.Method = httpVerb; - - using (WebResponse response = request.GetResponse()) - { - using (Stream responseStream = response.GetResponseStream()) - { - try - { - string responseStr = responseStream.GetStreamString(); - OSD responseOSD = OSDParser.Deserialize(responseStr); - if (responseOSD.Type == OSDType.Map) - return (OSDMap)responseOSD; - else - errorMessage = "Response format was invalid."; - } - catch - { - errorMessage = "Failed to parse the response."; - } - } - } - } - catch (Exception ex) - { - m_log.Warn(httpVerb + " on URL " + url + " failed: " + ex.Message); - errorMessage = ex.Message; - } - - return new OSDMap { { "Message", OSD.FromString("Service request failed. " + errorMessage) } }; - } + #region JSONRequest /// /// PUT JSON-encoded data to a web service that returns LLSD or @@ -303,6 +233,10 @@ namespace OpenSim.Framework return result; } + #endregion JSONRequest + + #region FormRequest + /// /// POST URL-encoded form data to a web service that returns LLSD or /// JSON data @@ -397,6 +331,8 @@ namespace OpenSim.Framework result["Message"] = OSD.FromString("Service request failed: " + msg); return result; } + + #endregion FormRequest #region Uri