Minor changes to improve testability of helpers
[castle.git] / MonoRail / Castle.MonoRail.Framework / IResponse.cs
blobd35c3a2141bb10f59f8787ca56108ee73fed4593
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.MonoRail.Framework
17 using System;
18 using System.Collections;
19 using System.Collections.Specialized;
20 using System.Web;
22 /// <summary>
23 /// Represents the response data and operations
24 /// </summary>
25 public interface IResponse
27 /// <summary>
28 /// Gets or sets the status code.
29 /// </summary>
30 /// <value>The status code.</value>
31 int StatusCode { get; set; }
33 /// <summary>
34 /// Gets or sets the type of the content.
35 /// </summary>
36 /// <value>The type of the content.</value>
37 String ContentType { get; set; }
39 /// <summary>
40 /// Gets the caching policy (expiration time, privacy,
41 /// vary clauses) of a Web page.
42 /// </summary>
43 HttpCachePolicy CachePolicy { get; }
45 /// <summary>
46 /// Sets the Cache-Control HTTP header to Public or Private.
47 /// </summary>
48 String CacheControlHeader { get; set; }
50 /// <summary>
51 /// Gets or sets the HTTP character set of the output stream.
52 /// </summary>
53 String Charset { get; set; }
55 /// <summary>
56 /// Gets the output.
57 /// </summary>
58 /// <value>The output.</value>
59 System.IO.TextWriter Output { get; }
61 /// <summary>
62 /// Gets the output stream.
63 /// </summary>
64 /// <value>The output stream.</value>
65 System.IO.Stream OutputStream { get; }
67 /// <summary>
68 /// Appends the header.
69 /// </summary>
70 /// <param name="name">The name.</param>
71 /// <param name="value">The value.</param>
72 void AppendHeader(String name, String value);
74 /// <summary>
75 /// Writes the buffer to the browser
76 /// </summary>
77 /// <param name="buffer">The buffer.</param>
78 void BinaryWrite(byte[] buffer);
80 /// <summary>
81 /// Writes the stream to the browser
82 /// </summary>
83 /// <param name="stream">The stream.</param>
84 void BinaryWrite(System.IO.Stream stream);
86 /// <summary>
87 /// Clears the response (only works if buffered)
88 /// </summary>
89 void Clear();
91 /// <summary>
92 /// Clears the response content (only works if buffered).
93 /// </summary>
94 void ClearContent();
96 /// <summary>
97 /// Writes the specified string.
98 /// </summary>
99 /// <param name="s">The string.</param>
100 void Write(String s);
102 /// <summary>
103 /// Writes the specified obj.
104 /// </summary>
105 /// <param name="obj">The obj.</param>
106 void Write(object obj);
108 /// <summary>
109 /// Writes the specified char.
110 /// </summary>
111 /// <param name="ch">The char.</param>
112 void Write(char ch);
114 /// <summary>
115 /// Writes the specified buffer.
116 /// </summary>
117 /// <param name="buffer">The buffer.</param>
118 /// <param name="index">The index.</param>
119 /// <param name="count">The count.</param>
120 void Write(char[] buffer, int index, int count);
122 /// <summary>
123 /// Writes the file.
124 /// </summary>
125 /// <param name="fileName">Name of the file.</param>
126 void WriteFile(String fileName);
128 /// <summary>
129 /// Redirects the specified controller.
130 /// </summary>
131 /// <param name="controller">The controller.</param>
132 /// <param name="action">The action.</param>
133 void Redirect(String controller, String action);
135 /// <summary>
136 /// Redirects the specified area.
137 /// </summary>
138 /// <param name="area">The area.</param>
139 /// <param name="controller">The controller.</param>
140 /// <param name="action">The action.</param>
141 void Redirect(String area, String controller, String action);
143 /// <summary>
144 /// Redirects to another controller and action with the specified paramters.
145 /// </summary>
146 /// <param name="controller">Controller name</param>
147 /// <param name="action">Action name</param>
148 /// <param name="parameters">Key/value pairings</param>
149 void Redirect(string controller, string action, NameValueCollection parameters);
151 /// <summary>
152 /// Redirects to another controller and action with the specified paramters.
153 /// </summary>
154 /// <param name="area">Area name</param>
155 /// <param name="controller">Controller name</param>
156 /// <param name="action">Action name</param>
157 /// <param name="parameters">Key/value pairings</param>
158 void Redirect(string area, string controller, string action, NameValueCollection parameters);
160 /// <summary>
161 /// Redirects to another controller and action with the specified paramters.
162 /// </summary>
163 /// <param name="controller">Controller name</param>
164 /// <param name="action">Action name</param>
165 /// <param name="parameters">Key/value pairings</param>
166 void Redirect(string controller, string action, IDictionary parameters);
168 /// <summary>
169 /// Redirects to another controller and action with the specified paramters.
170 /// </summary>
171 /// <param name="area">Area name</param>
172 /// <param name="controller">Controller name</param>
173 /// <param name="action">Action name</param>
174 /// <param name="parameters">Key/value pairings</param>
175 void Redirect(string area, string controller, string action, IDictionary parameters);
177 /// <summary>
178 /// Redirects the specified URL.
179 /// </summary>
180 /// <param name="url">The URL.</param>
181 void Redirect(String url);
183 /// <summary>
184 /// Redirects the specified URL.
185 /// </summary>
186 /// <param name="url">The URL.</param>
187 /// <param name="endProcess">if set to <c>true</c> [end process].</param>
188 void Redirect(String url, bool endProcess);
190 /// <summary>
191 /// Gets a value indicating whether the response sent a redirect.
192 /// </summary>
193 /// <value><c>true</c> if was redirected; otherwise, <c>false</c>.</value>
194 bool WasRedirected { get; }
196 /// <summary>
197 /// Gets a value indicating whether this instance is client connected.
198 /// </summary>
199 /// <value>
200 /// <c>true</c> if this instance is client connected; otherwise, <c>false</c>.
201 /// </value>
202 bool IsClientConnected { get; }
204 /// <summary>
205 /// Creates a cookie.
206 /// </summary>
207 /// <param name="name">The name.</param>
208 /// <param name="value">The value.</param>
209 void CreateCookie(String name, String value);
211 /// <summary>
212 /// Creates a cookie.
213 /// </summary>
214 /// <param name="name">The name.</param>
215 /// <param name="value">The value.</param>
216 /// <param name="expiration">The expiration.</param>
217 void CreateCookie(String name, String value, DateTime expiration);
219 /// <summary>
220 /// Creates a cookie.
221 /// </summary>
222 /// <param name="cookie">The cookie.</param>
223 void CreateCookie(HttpCookie cookie);
225 /// <summary>
226 /// Removes a cookie.
227 /// </summary>
228 /// <param name="name">The name.</param>
229 void RemoveCookie(string name);