public override MiddlewareContinuation Invoke(ICurrentHttpRequest request, IHttpWriter writer)
        {
            if (request.IsNotHttpMethod("GET", "HEAD"))
            {
                return(MiddlewareContinuation.Continue());
            }

            var file = _files.Find(request.RelativeUrl());

            if (file == null)
            {
                return(MiddlewareContinuation.Continue());
            }

            if (_settings.DetermineStaticFileRights(file) != AuthorizationRight.Allow)
            {
                return(MiddlewareContinuation.Continue());
            }

            if (request.IsHead())
            {
                return(new WriteFileHeadContinuation(writer, file, HttpStatusCode.OK));
            }

            if (request.IfMatchHeaderDoesNotMatchEtag(file))
            {
                return(new WriteStatusCodeContinuation(writer, HttpStatusCode.PreconditionFailed, "If-Match test failed"));
            }

            if (request.IfNoneMatchHeaderMatchesEtag(file))
            {
                return(new WriteFileHeadContinuation(writer, file, HttpStatusCode.NotModified));
            }

            if (request.IfModifiedSinceHeaderAndNotModified(file))
            {
                return(new WriteFileHeadContinuation(writer, file, HttpStatusCode.NotModified));
            }

            if (request.IfUnModifiedSinceHeaderAndModifiedSince(file))
            {
                return(new WriteStatusCodeContinuation(writer, HttpStatusCode.PreconditionFailed, "File has been modified"));
            }

            return(new WriteFileContinuation(writer, file));
        }