Click here to Skip to main content
15,897,704 members
Articles / Programming Languages / C#

MiniHttpd: an HTTP web server library

Rate me:
Please Sign up or sign in to vote.
4.86/5 (54 votes)
30 Dec 200514 min read 2M   9.9K   230  
A portable and flexible HTTP web server library written in 100% managed C#.
using System;
using MiniHttpd;

namespace MiniHttpdConsole
{
	/// <summary>
	/// Summary description for RedirectFile.
	/// </summary>
	[Serializable]
	public class RedirectFile : IFile
	{
		public RedirectFile(string name, string redirect, IDirectory parent)
		{
			this.name = name;
			this.redirect = redirect;
			this.parent = parent;
		}

		string name;
		string redirect;
		IDirectory parent;

		public string Redirect
		{
			get
			{
				return redirect;
			}
		}

		#region IFile Members

		public void OnFileRequested(HttpRequest request, IDirectory directory)
		{
			request.Response.ResponseCode = "302";
			request.Response.SetHeader("Location", redirect);
		}

		public string ContentType
		{
			get
			{
				return null;
			}
		}

		#endregion

		#region IResource Members

		public string Name
		{
			get
			{
				return name;
			}
		}

		public IDirectory Parent
		{
			get
			{
				return parent;
			}
		}

		#endregion

		#region IDisposable Members

		public void Dispose()
		{
			// TODO:  Add RedirectFile.Dispose implementation
		}

		#endregion

		public override string ToString()
		{
			return name;
		}

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Canada Canada
The cows are here to take me home now...

Comments and Discussions