forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicResponse.cs
More file actions
89 lines (68 loc) · 2.01 KB
/
Copy pathBasicResponse.cs
File metadata and controls
89 lines (68 loc) · 2.01 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System.Collections.Generic;
using System.IO;
using ServiceStack.Text;
using ServiceStack.Web;
namespace ServiceStack.Host
{
public class BasicResponse : IResponse
{
private readonly BasicRequest requestContext;
private Dictionary<string, string> Headers { get; set; }
public BasicResponse(BasicRequest requestContext)
{
this.requestContext = requestContext;
this.Headers = new Dictionary<string, string>();
this.Items = new Dictionary<string, object>();
}
public object OriginalResponse { get; set; }
public IRequest Request
{
get { return requestContext; }
}
public int StatusCode { get; set; }
public string StatusDescription { get; set; }
public string ContentType
{
get { return requestContext.ResponseContentType; }
set { requestContext.ResponseContentType = value; }
}
public void AddHeader(string name, string value)
{
Headers[name] = value;
}
public void Redirect(string url)
{
}
private MemoryStream ms;
public Stream OutputStream
{
get { return ms ?? (ms = new MemoryStream()); }
}
public object Dto { get; set; }
public void Write(string text)
{
var bytes = text.ToUtf8Bytes();
ms.Write(bytes, 0, bytes.Length);
}
public bool UseBufferedStream { get; set; }
public void Close()
{
IsClosed = true;
if (ms != null && ms.CanWrite)
ms.Dispose();
}
public void End()
{
Close();
}
public void Flush()
{
}
public bool IsClosed { get; set; }
public void SetContentLength(long contentLength)
{
}
public bool KeepAlive { get; set; }
public Dictionary<string, object> Items { get; private set; }
}
}