コード例 #1
0
ファイル: ETagHandler.cs プロジェクト: rmueller/fubumvc
        public FubuContinuation Matches(ETaggedRequest request)
        {
            var current = _cache.Current(request.ResourceHash);

            return(current.IsNotEmpty() && current == request.IfNoneMatch
                       ? FubuContinuation.EndWithStatusCode(HttpStatusCode.NotModified)
                       : FubuContinuation.NextBehavior());
        }
コード例 #2
0
        public DoNext Filter(ServiceArguments arguments)
        {
            string etag = null;

            arguments.Get <AggregateDictionary>().Value(RequestDataSource.Header.ToString(), HttpRequestHeaders.IfNoneMatch, (key, value) => etag = (string)value);

            if (etag == null)
            {
                return(DoNext.Continue);
            }

            var resourceHash = arguments.Get <ICurrentChain>().ResourceHash();
            var currentEtag  = _cache.Current(resourceHash);

            if (etag != currentEtag)
            {
                return(DoNext.Continue);
            }


            arguments.Get <IHttpWriter>().WriteResponseCode(HttpStatusCode.NotModified);
            return(DoNext.Stop);
        }