using System;
using System.Net;
using System.Text;

namespace skyscraper5.Skyscraper.Webserver
{
    internal class NotFoundFallbackResource : ISkyscraperWebserverResource
    {
        public bool CanHandle(HttpListenerRequest request)
        {
            return true;
        }

        
        public void HandleRequest(HttpListenerContext context)
        {
            context.Response.StatusCode = 404;
            context.Response.ContentType = "text/plain";

            byte[] response = Encoding.UTF8.GetBytes(String.Format("Don't know what {0} {1} means.", context.Request.HttpMethod, context.Request.RawUrl));
            context.Response.Close(response, true);
        }
    }
}
