diff options
author | Diva Canto | 2009-10-02 20:35:15 -0700 |
---|---|---|
committer | Diva Canto | 2009-10-02 20:35:15 -0700 |
commit | 006dfd6d9a31127b5aad55b16b7f85f29faff620 (patch) | |
tree | 9b422ca9c8a749cf0f62b418a7009ae7a53b0d4b /OpenSim/Framework | |
parent | * Creates Util.UTF8 and switches some references of Encoding.UTF8 to Util.UTF... (diff) | |
download | opensim-SC-006dfd6d9a31127b5aad55b16b7f85f29faff620.zip opensim-SC-006dfd6d9a31127b5aad55b16b7f85f29faff620.tar.gz opensim-SC-006dfd6d9a31127b5aad55b16b7f85f29faff620.tar.bz2 opensim-SC-006dfd6d9a31127b5aad55b16b7f85f29faff620.tar.xz |
Closing another stream.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs | 23 |
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 | } |