From 4bf4c76a64cd9b104d8d46c8058898660ef92304 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 11 May 2020 19:35:13 +0100 Subject: [PATCH] cosmetics --- OpenSim/Framework/RestClient.cs | 40 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/OpenSim/Framework/RestClient.cs b/OpenSim/Framework/RestClient.cs index 21b99cb30d..0fbcf99fb9 100644 --- a/OpenSim/Framework/RestClient.cs +++ b/OpenSim/Framework/RestClient.cs @@ -404,36 +404,34 @@ namespace OpenSim.Framework { await dst.WriteAsync(src, 0, src.Length).ConfigureAwait(false); } - _response = (HttpWebResponse)await _request.GetResponseAsync().ConfigureAwait(false); + + using(HttpWebResponse response = (HttpWebResponse)await _request.GetResponseAsync().ConfigureAwait(false)) + { + if (WebUtil.DebugLevel >= 5) + { + using (Stream responseStream = response.GetResponseStream()) + { + using (StreamReader reader = new StreamReader(responseStream)) + { + string responseStr = await reader.ReadToEndAsync().ConfigureAwait(false); + WebUtil.LogResponseDetail(reqnum, responseStr); + } + } + } + } } catch (WebException e) { - m_log.WarnFormat("[REST]: Request {0} {1} failed with status {2} and message {3}", - RequestMethod, _request.RequestUri, e.Status, e.Message); + m_log.WarnFormat("[REST]: AsyncPOST {0} failed with status {1} and message {2}", + _request.RequestUri, e.Status, e.Message); return; } catch (Exception e) { - m_log.WarnFormat( - "[REST]: Request {0} {1} failed with exception {2} {3}", - RequestMethod, _request.RequestUri, e.Message, e.StackTrace); + m_log.WarnFormat("[REST]: AsyncPOST {0} failed with exception {1} {2}", + _request.RequestUri, e.Message, e.StackTrace); return; } - - if (WebUtil.DebugLevel >= 5) - { - using (Stream responseStream = _response.GetResponseStream()) - { - using (StreamReader reader = new StreamReader(responseStream)) - { - string responseStr = await reader.ReadToEndAsync().ConfigureAwait(false); - WebUtil.LogResponseDetail(reqnum, responseStr); - } - } - } - - if (_response != null) - _response.Close(); } #region Async Invocation