forked from bonesoul/uhttpsharp
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathHttpContext.cs
More file actions
47 lines (40 loc) · 1.13 KB
/
HttpContext.cs
File metadata and controls
47 lines (40 loc) · 1.13 KB
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
43
44
45
46
47
using System.Dynamic;
using System.Net;
using uhttpsharp.Clients;
using uhttpsharp.Headers;
namespace uhttpsharp
{
internal class HttpContext : IHttpContext
{
private readonly IHttpRequest _request;
private readonly IClient _client;
private readonly ICookiesStorage _cookies;
private readonly ExpandoObject _state = new ExpandoObject();
public HttpContext(IHttpRequest request, IClient client)
{
_request = request;
_client = client;
_cookies = new CookiesStorage(_request.Headers.GetByNameOrDefault("cookie", string.Empty));
}
public IHttpRequest Request
{
get { return _request; }
}
public IHttpResponse Response { get; set; }
public ICookiesStorage Cookies
{
get { return _cookies; }
}
public dynamic State
{
get { return _state; }
}
public IClient Client {
get { return _client; }
}
public EndPoint RemoteEndPoint
{
get { return _client.RemoteEndPoint; }
}
}
}