aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs23
1 files changed, 19 insertions, 4 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
index ec9bd4f..eab463c 100644
--- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
@@ -58,6 +58,7 @@ namespace OpenSim.Framework.Servers.HttpServer
58 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj) 58 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj)
59 { 59 {
60 Type type = typeof (TRequest); 60 Type type = typeof (TRequest);
61 TResponse deserial = default(TResponse);
61 62
62 WebRequest request = WebRequest.Create(requestUrl); 63 WebRequest request = WebRequest.Create(requestUrl);
63 request.Method = verb; 64 request.Method = verb;
@@ -81,19 +82,33 @@ namespace OpenSim.Framework.Servers.HttpServer
81 int length = (int) buffer.Length; 82 int length = (int) buffer.Length;
82 request.ContentLength = length; 83 request.ContentLength = length;
83 84
84 Stream requestStream = request.GetRequestStream(); 85 Stream requestStream = null;
85 requestStream.Write(buffer.ToArray(), 0, length); 86 try
87 {
88 requestStream = request.GetRequestStream();
89 requestStream.Write(buffer.ToArray(), 0, length);
90 }
91 catch (Exception)
92 {
93 return deserial;
94 }
95 finally
96 {
97 if (requestStream != null)
98 requestStream.Close();
99 }
86 } 100 }
87 101
88 TResponse deserial = default(TResponse);
89 try 102 try
90 { 103 {
91 using (WebResponse resp = request.GetResponse()) 104 using (WebResponse resp = request.GetResponse())
92 { 105 {
93 if (resp.ContentLength > 0) 106 if (resp.ContentLength > 0)
94 { 107 {
108 Stream respStream = resp.GetResponseStream();
95 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); 109 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
96 deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); 110 deserial = (TResponse)deserializer.Deserialize(respStream);
111 respStream.Close();
97 } 112 }
98 } 113 }
99 } 114 }