setting all protected methods on WizardStepPage as virtual
[castle.git] / MonoRail / Castle.MonoRail.Framework / Adapters / ResponseAdapter.cs
blob6c6058aa3d49190b1347202165c694467a3585b8
1 // Copyright 2004-2008 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.Adapters
17 using System;
18 using System.IO;
19 using System.Web;
20 using Castle.MonoRail.Framework;
21 using Internal;
22 using Routing;
23 using Services;
25 /// <summary>
26 /// Adapts the <see cref="IResponse"/> to
27 /// an <see cref="HttpResponse"/> instance.
28 /// </summary>
29 public class ResponseAdapter : BaseResponse
31 private readonly HttpResponse response;
33 /// <summary>
34 /// Initializes a new instance of the <see cref="ResponseAdapter"/> class.
35 /// </summary>
36 /// <param name="response">The response.</param>
37 /// <param name="currentUrl">The current URL.</param>
38 /// <param name="urlBuilder">The URL builder.</param>
39 /// <param name="serverUtility">The server utility.</param>
40 /// <param name="routeMatch">The route match.</param>
41 /// <param name="referrer">The referrer.</param>
42 public ResponseAdapter(HttpResponse response, UrlInfo currentUrl,
43 IUrlBuilder urlBuilder, IServerUtility serverUtility,
44 RouteMatch routeMatch, string referrer)
45 : base(currentUrl, urlBuilder, serverUtility, routeMatch, referrer)
47 this.response = response;
50 /// <summary>
51 /// Gets the caching policy (expiration time, privacy,
52 /// vary clauses) of a Web page.
53 /// </summary>
54 public override HttpCachePolicy CachePolicy
56 get { return response.Cache; }
57 set { throw new NotImplementedException(); }
60 /// <summary>
61 /// Sets the Cache-Control HTTP header to Public or Private.
62 /// </summary>
63 public override string CacheControlHeader
65 get { return response.CacheControl; }
66 set { response.CacheControl = value; }
69 /// <summary>
70 /// Gets or sets the HTTP character set of the output stream.
71 /// </summary>
72 public override string Charset
74 get { return response.Charset; }
75 set { response.Charset = value; }
78 /// <summary>
79 /// Gets or sets the status code.
80 /// </summary>
81 /// <value>The status code.</value>
82 public override int StatusCode
84 get { return response.StatusCode; }
85 set { response.StatusCode = value; }
88 /// <summary>
89 /// Gets or sets the status code.
90 /// </summary>
91 /// <value>The status code.</value>
92 public override string StatusDescription
94 get { return response.StatusDescription; }
95 set { response.StatusDescription = value; }
98 /// <summary>
99 /// Gets or sets the content type.
100 /// </summary>
101 /// <value>The type of the content.</value>
102 public override string ContentType
104 get { return response.ContentType; }
105 set { response.ContentType = value; }
108 /// <summary>
109 /// Appends the header.
110 /// </summary>
111 /// <param name="name">The name.</param>
112 /// <param name="headerValue">The header value.</param>
113 public override void AppendHeader(string name, string headerValue)
115 response.AppendHeader(name, headerValue);
118 /// <summary>
119 /// Gets the output.
120 /// </summary>
121 /// <value>The output.</value>
122 public override TextWriter Output
124 get { return response.Output; }
125 set { throw new NotImplementedException(); }
128 /// <summary>
129 /// Gets the output stream.
130 /// </summary>
131 /// <value>The output stream.</value>
132 public override Stream OutputStream
134 get { return response.OutputStream; }
137 /// <summary>
138 /// Writes the buffer to the browser
139 /// </summary>
140 /// <param name="buffer">The buffer.</param>
141 public override void BinaryWrite(byte[] buffer)
143 response.BinaryWrite(buffer);
146 /// <summary>
147 /// Writes the stream to the browser
148 /// </summary>
149 /// <param name="stream">The stream.</param>
150 public override void BinaryWrite(Stream stream)
152 byte[] buffer = new byte[stream.Length];
154 stream.Read(buffer, 0, buffer.Length);
156 BinaryWrite(buffer);
159 /// <summary>
160 /// Clears the response (only works if buffered)
161 /// </summary>
162 public override void Clear()
164 response.Clear();
167 /// <summary>
168 /// Clears the response content (only works if buffered).
169 /// </summary>
170 public override void ClearContent()
172 response.ClearContent();
175 /// <summary>
176 /// Writes the specified string.
177 /// </summary>
178 /// <param name="s">The string.</param>
179 public override void Write(string s)
181 response.Write(s);
184 /// <summary>
185 /// Writes the specified obj.
186 /// </summary>
187 /// <param name="obj">The obj.</param>
188 public override void Write(object obj)
190 response.Write(obj);
193 /// <summary>
194 /// Writes the specified char.
195 /// </summary>
196 /// <param name="ch">The char.</param>
197 public override void Write(char ch)
199 response.Write(ch);
202 /// <summary>
203 /// Writes the specified buffer.
204 /// </summary>
205 /// <param name="buffer">The buffer.</param>
206 /// <param name="index">The index.</param>
207 /// <param name="count">The count.</param>
208 public override void Write(char[] buffer, int index, int count)
210 response.Write(buffer, index, count);
213 /// <summary>
214 /// Writes the file.
215 /// </summary>
216 /// <param name="fileName">Name of the file.</param>
217 public override void WriteFile(string fileName)
219 response.WriteFile(fileName);
222 /// <summary>
223 /// Gets a value indicating whether this instance is client connected.
224 /// </summary>
225 /// <value>
226 /// <c>true</c> if this instance is client connected; otherwise, <c>false</c>.
227 /// </value>
228 public override bool IsClientConnected
230 get { return response.IsClientConnected; }
233 /// <summary>
234 /// Gets a value indicating whether the response sent a redirect.
235 /// </summary>
236 /// <value><c>true</c> if was redirected; otherwise, <c>false</c>.</value>
237 public override bool WasRedirected
239 get { return redirected; }
242 /// <summary>
243 /// Redirects to the specified url
244 /// </summary>
245 /// <param name="url">An relative or absolute URL to redirect the client to</param>
246 /// <param name="endProcess">if set to <c>true</c>, sends the redirect and
247 /// kills the current request process.</param>
248 public override void RedirectToUrl(string url, bool endProcess)
250 redirected = true;
251 response.Redirect(url, endProcess);
254 /// <summary>
255 /// Creates the cookie.
256 /// </summary>
257 /// <param name="cookie">The cookie.</param>
258 public override void CreateCookie(HttpCookie cookie)
260 response.Cookies.Add(cookie);