Castle.MonoRail.Framework.ViewEngineBase.AdjustContentType C# (CSharp) Method

AdjustContentType() protected method

Sets the HTTP Content-Type header appropriately.
protected AdjustContentType ( IRailsEngineContext context ) : void
context IRailsEngineContext
return void
		protected virtual void AdjustContentType(IRailsEngineContext context)
		{
			if (xhtmlRendering)
			{
				//Find out what they'll accept
				String httpAccept = context.Request.Headers["Accept"];

				//TODO: Evaluate the q-values of the Accept header

				//Do they accept application/xhtml+xml?
				if (httpAccept != null && httpAccept.IndexOf("application/xhtml+xml") != -1)
				{
					//Send them the proper content type
					context.Response.ContentType = "application/xhtml+xml";

					//TODO: Add the xml prolog for browsers that support it
					//response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
				}
				else
				{
					//Fall back to text/html for older folk
					context.Response.ContentType = "text/html";
				}

				//Fix up the proxy
				context.Response.AppendHeader("Vary", "Accept");
			}
			else if (context.Response.ContentType == null)
			{
				//Just use HTML
				context.Response.ContentType = "text/html";
			}
		}