-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
HttpResponseMessageWrapper.cs
42 lines (36 loc) · 1.06 KB
/
HttpResponseMessageWrapper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.IO;
using System.Net.Http;
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.RequestMessage.Dispose();
_httpResponseMessage.Dispose();
_client.Dispose();
}
}
public void Dispose()
{
Dispose(true);
}
}
}