Ejemplo n.º 1
0
        private CachedResponse CacheGet(Location location)
        {
            if (cache.ContainsKey(location.FullPath))
            {
                return cache[location.FullPath];
            }

            return null;
        }
Ejemplo n.º 2
0
        protected override StaticResponse GetResponse(Location location)
        {
            if (!TestFilters(location))
                return null;

            var info = GetLocalFileInfo(location.Path, sources, indexFiles, allowHidden);
            if (info == null)
                return null;

            if (info is DirectoryInfo)
                return redirectIfFolder ? StaticResponse.Redirect(GetFolderRedirectLocation(location)) : null;

            var result = new StaticResponse(info.FullName.GetContentType(), GetFileStream(info.FullName));
            if (expires != DateTimeOffset.MinValue)
                result.Headers.Expires.Value = expires;
            if (maxAge != 0)
                result.Headers.CacheControl.MaxAge = maxAge;
            var fileInfo = info as FileInfo;
            if (fileInfo != null)
            {
                result.Headers.LastModified.Value = fileInfo.LastWriteTimeUtc;
                result.Headers.ContentLength.Value = fileInfo.Length;
            }

            return result;
        }
Ejemplo n.º 3
0
 private bool TestFilters(Location location)
 {
     return !((unixHidden.IsActive() && unixHidden.Contains(location.Path))
         || (include.IsActive() && !include.Contains(location.Path))
         || (exclude.IsActive() && exclude.Contains(location.Path)));
 }
Ejemplo n.º 4
0
 private static string GetFolderRedirectLocation(Location location)
 {
     return location.FullPath + "/";
 }
Ejemplo n.º 5
0
 protected abstract StaticResponse GetResponse(Location location);