1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
18 using System
.Collections
;
19 using System
.Collections
.Specialized
;
23 /// Represents the response data and operations
25 public interface IResponse
28 /// Gets or sets the status code.
30 /// <value>The status code.</value>
31 int StatusCode { get; set; }
34 /// Gets or sets the type of the content.
36 /// <value>The type of the content.</value>
37 String ContentType { get; set; }
40 /// Gets the caching policy (expiration time, privacy,
41 /// vary clauses) of a Web page.
43 HttpCachePolicy CachePolicy { get; }
46 /// Sets the Cache-Control HTTP header to Public or Private.
48 String CacheControlHeader { get; set; }
51 /// Gets or sets the HTTP character set of the output stream.
53 String Charset { get; set; }
58 /// <value>The output.</value>
59 System
.IO
.TextWriter Output { get; }
62 /// Gets the output stream.
64 /// <value>The output stream.</value>
65 System
.IO
.Stream OutputStream { get; }
68 /// Appends the header.
70 /// <param name="name">The name.</param>
71 /// <param name="value">The value.</param>
72 void AppendHeader(String name
, String
value);
75 /// Writes the buffer to the browser
77 /// <param name="buffer">The buffer.</param>
78 void BinaryWrite(byte[] buffer
);
81 /// Writes the stream to the browser
83 /// <param name="stream">The stream.</param>
84 void BinaryWrite(System
.IO
.Stream stream
);
87 /// Clears the response (only works if buffered)
92 /// Clears the response content (only works if buffered).
97 /// Writes the specified string.
99 /// <param name="s">The string.</param>
100 void Write(String s
);
103 /// Writes the specified obj.
105 /// <param name="obj">The obj.</param>
106 void Write(object obj
);
109 /// Writes the specified char.
111 /// <param name="ch">The char.</param>
115 /// Writes the specified buffer.
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
);
125 /// <param name="fileName">Name of the file.</param>
126 void WriteFile(String fileName
);
129 /// Redirects the specified controller.
131 /// <param name="controller">The controller.</param>
132 /// <param name="action">The action.</param>
133 void Redirect(String controller
, String action
);
136 /// Redirects the specified area.
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
);
144 /// Redirects to another controller and action with the specified paramters.
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
);
152 /// Redirects to another controller and action with the specified paramters.
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
);
161 /// Redirects to another controller and action with the specified paramters.
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
);
169 /// Redirects to another controller and action with the specified paramters.
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
);
178 /// Redirects the specified URL.
180 /// <param name="url">The URL.</param>
181 void Redirect(String url
);
184 /// Redirects the specified URL.
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
);
191 /// Gets a value indicating whether the response sent a redirect.
193 /// <value><c>true</c> if was redirected; otherwise, <c>false</c>.</value>
194 bool WasRedirected { get; }
197 /// Gets a value indicating whether this instance is client connected.
200 /// <c>true</c> if this instance is client connected; otherwise, <c>false</c>.
202 bool IsClientConnected { get; }
205 /// Creates a cookie.
207 /// <param name="name">The name.</param>
208 /// <param name="value">The value.</param>
209 void CreateCookie(String name
, String
value);
212 /// Creates a cookie.
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
);
220 /// Creates a cookie.
222 /// <param name="cookie">The cookie.</param>
223 void CreateCookie(HttpCookie cookie
);
226 /// Removes a cookie.
228 /// <param name="name">The name.</param>
229 void RemoveCookie(string name
);