From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- OpenSim/Framework/RestClient.cs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/RestClient.cs') diff --git a/OpenSim/Framework/RestClient.cs b/OpenSim/Framework/RestClient.cs index 7080ca5..4939cf7 100644 --- a/OpenSim/Framework/RestClient.cs +++ b/OpenSim/Framework/RestClient.cs @@ -156,7 +156,7 @@ namespace OpenSim.Framework public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); + GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) @@ -388,10 +388,10 @@ namespace OpenSim.Framework m_log.Error(string.Format("[REST CLIENT] Error fetching resource from server: {0} ", _request.Address.ToString()), e); } } - return null; } + if (_asyncException != null) throw _asyncException; @@ -413,7 +413,7 @@ namespace OpenSim.Framework _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; _request.ContentType = "application/xml"; - _request.Timeout = 900000; + _request.Timeout = 90000; _request.Method = RequestMethod; _asyncException = null; _request.ContentLength = src.Length; @@ -428,18 +428,23 @@ namespace OpenSim.Framework if (WebUtil.DebugLevel >= 5) WebUtil.LogOutgoingDetail(string.Format("SEND {0}: ", reqnum), src); - Stream dst = _request.GetRequestStream(); - - byte[] buf = new byte[1024]; - int length = src.Read(buf, 0, 1024); - while (length > 0) - { - dst.Write(buf, 0, length); - length = src.Read(buf, 0, 1024); - } - + try { + using (Stream dst = _request.GetRequestStream()) + { +// m_log.Debug("[REST]: GetRequestStream is ok"); + + byte[] buf = new byte[1024]; + int length = src.Read(buf, 0, 1024); +// m_log.Debug("[REST]: First Read is ok"); + while (length > 0) + { + dst.Write(buf, 0, length); + length = src.Read(buf, 0, 1024); + } + } + _response = (HttpWebResponse)_request.GetResponse(); } catch (WebException e) @@ -468,7 +473,8 @@ namespace OpenSim.Framework } } - _response.Close(); + if (_response != null) + _response.Close(); // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); @@ -673,4 +679,4 @@ namespace OpenSim.Framework } } -} \ No newline at end of file +} -- cgit v1.1