diff --git a/LearnositySDK/Request/Remote.cs b/LearnositySDK/Request/Remote.cs index 8472ee6..25e4bb3 100755 --- a/LearnositySDK/Request/Remote.cs +++ b/LearnositySDK/Request/Remote.cs @@ -182,24 +182,31 @@ private Remote request(string url, string post = null, JsonObject options = null { Stopwatch timer = new Stopwatch(); timer.Start(); - this.result = this.hr.GetResponse(); + using (this.result = this.hr.GetResponse()) + { + using (StreamReader sr = new StreamReader(this.result.GetResponseStream())) + { + this.responseBody = sr.ReadToEnd(); + } + } this.status = "200"; timer.Stop(); this.time = timer.Elapsed.Seconds; } catch (WebException e) { - this.result = e.Response; + using (this.result = e.Response) + { + using (StreamReader sr = new StreamReader(this.result.GetResponseStream())) + { + this.responseBody = sr.ReadToEnd(); + } + } this.status = e.Status.ToString(); this.errorCode = this.status; this.errorMessage = e.Message; } - using (StreamReader sr = new StreamReader(this.result.GetResponseStream())) - { - this.responseBody = sr.ReadToEnd(); - } - this.process(); return this; }