-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
IResponse.cs
133 lines (110 loc) · 4.05 KB
/
IResponse.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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//Copyright (c) ServiceStack, Inc. All Rights Reserved.
//License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace ServiceStack.Web
{
/// <summary>
/// A thin wrapper around each host's Response e.g: ASP.NET, HttpListener, MQ, etc
/// </summary>
public interface IResponse
{
/// <summary>
/// The underlying ASP.NET, .NET Core or HttpListener HttpResponse
/// </summary>
object OriginalResponse { get; }
/// <summary>
/// The corresponding IRequest API for this Response
/// </summary>
IRequest Request { get; }
/// <summary>
/// The Response Status Code
/// </summary>
int StatusCode { get; set; }
/// <summary>
/// The Response Status Description
/// </summary>
string StatusDescription { get; set; }
/// <summary>
/// The Content-Type for this Response
/// </summary>
string ContentType { get; set; }
/// <summary>
/// Add a Header to this Response
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
void AddHeader(string name, string value);
/// <summary>
/// Remove an existing Header added on this Response
/// </summary>
/// <param name="name"></param>
void RemoveHeader(string name);
/// <summary>
/// Get an existing Header added to this Response
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
string GetHeader(string name);
/// <summary>
/// Return a Redirect Response to the URL specified
/// </summary>
/// <param name="url"></param>
void Redirect(string url);
/// <summary>
/// The Response Body Output Stream
/// </summary>
Stream OutputStream { get; }
/// <summary>
/// The Response DTO
/// </summary>
object Dto { get; set; }
/// <summary>
/// Buffer the Response OutputStream so it can be written in 1 batch
/// </summary>
bool UseBufferedStream { get; set; }
/// <summary>
/// Signal that this response has been handled and no more processing should be done.
/// When used in a request or response filter, no more filters or processing is done on this request.
/// </summary>
void Close();
/// <summary>
/// Close this Response Output Stream Async
/// </summary>
Task CloseAsync(CancellationToken token = default(CancellationToken));
/// <summary>
/// Calls Response.End() on ASP.NET HttpResponse otherwise is an alias for Close().
/// Useful when you want to prevent ASP.NET to provide it's own custom error page.
/// </summary>
void End();
/// <summary>
/// Response.Flush() and OutputStream.Flush() seem to have different behaviour in ASP.NET
/// </summary>
void Flush();
/// <summary>
/// Flush this Response Output Stream Async
/// </summary>
Task FlushAsync(CancellationToken token = default(CancellationToken));
/// <summary>
/// Gets a value indicating whether this instance is closed.
/// </summary>
bool IsClosed { get; }
/// <summary>
/// Set the Content Length in Bytes for this Response
/// </summary>
/// <param name="contentLength"></param>
void SetContentLength(long contentLength);
/// <summary>
/// Whether the underlying TCP Connection for this Response should remain open
/// </summary>
bool KeepAlive { get; set; }
/// <summary>
/// Whether the HTTP Response Headers have already been written.
/// </summary>
bool HasStarted { get; }
//Add Metadata to Response
Dictionary<string, object> Items { get; }
}
}