Skip to content

Commit

Permalink
Modified ResponseMessageWrapper to dispose the client
Browse files Browse the repository at this point in the history
  • Loading branch information
abnanda1 committed Apr 23, 2013
1 parent e22e588 commit 26a58c0
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;

namespace Microsoft.AspNet.SignalR.Client.Http
{
public class HttpResponseMessageWrapper : IResponse
{
private HttpResponseMessage _httpResponseMessage;
private HttpClient _client;

public HttpResponseMessageWrapper(HttpResponseMessage httpResponseMessage, HttpClient client)
{
_httpResponseMessage = httpResponseMessage;
_client = client;
}

public string ReadAsString()
{
return _httpResponseMessage.Content.ReadAsStringAsync().Result;
}

public Stream GetStream()
{
return _httpResponseMessage.Content.ReadAsStreamAsync().Result;
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_httpResponseMessage.Dispose();
_client.Dispose();
}
}

public void Dispose()
{
Dispose(true);
}
}
}

0 comments on commit 26a58c0

Please sign in to comment.