31 using System.Reflection;
34 using System.Xml.Serialization;
37 namespace OpenSim.ConsoleClient
39 public delegate
void ReplyDelegate(
string requestUrl,
string requestData,
string replyData);
43 public static void MakeRequest(
string requestUrl,
string data,
46 WebRequest request = WebRequest.Create(requestUrl);
48 request.Method =
"POST";
50 request.ContentType =
"application/x-www-form-urlencoded";
52 byte[] buffer = Encoding.ASCII.GetBytes(data);
53 int length = (int) buffer.Length;
54 request.ContentLength = length;
56 request.BeginGetRequestStream(delegate(IAsyncResult res)
58 Stream requestStream = request.EndGetRequestStream(res);
60 requestStream.Write(buffer, 0, length);
62 request.BeginGetResponse(delegate(IAsyncResult ar)
64 string reply = String.Empty;
66 using (WebResponse response = request.EndGetResponse(ar))
70 using (Stream s = response.GetResponseStream())
71 using (StreamReader r =
new StreamReader(s))
72 reply = r.ReadToEnd();
75 catch (System.InvalidOperationException)
80 action(requestUrl, data, reply);
delegate void ReplyDelegate(string requestUrl, string requestData, string replyData)
static void MakeRequest(string requestUrl, string data, ReplyDelegate action)