Example #1
0
        private bool                    TransmitVirtualizedFileIfItExists()
        {
            Extension fileExtension = Extension.TrySelect(Path.GetExtension(this.Context.Request.Path).OrIfNullOrEmpty(Extension.html).ToLower(), null);

            VirtualFileAssembler fileAssembler = this.createFileAssembler(fileExtension);

            if (fileExtension == null || !fileAssembler.RequestedFileIsVirtual())
            {
                return(false);
            }

            fileAssembler.GetFileContents();

            if (this.checkForMissingFiles(fileAssembler))
            {
                return(false);
            }

            this.Response.AddHeader("content-type", fileExtension.MimeType);

            if (this.checkForIfNoneMatch(fileAssembler))
            {
                return(true);
            }

            this.respondWithContent(fileAssembler);

            return(true);
        }
Example #2
0
 private bool checkForMissingFiles(VirtualFileAssembler fileAssembler)
 {
     if (fileAssembler.MissingFiles.Count > 0)
     {
         this.Response.AddHeader("MissingFiles", String.Join(";", fileAssembler.MissingFiles));
         return true;
     }
     return false;
 }
Example #3
0
 private bool                    checkForMissingFiles(VirtualFileAssembler fileAssembler)
 {
     if (fileAssembler.MissingFiles.Count > 0)
     {
         this.Response.AddHeader("MissingFiles", String.Join(";", fileAssembler.MissingFiles));
         return(true);
     }
     return(false);
 }
Example #4
0
 private bool checkForIfNoneMatch(VirtualFileAssembler fileAssembler)
 {
     string  etag    = null;
     if (this.Context.Request.Headers.TryGetValue("If-None-Match", out etag) && etag == fileAssembler.CachedFile.etag)
     {
         this.Context.Response.StatusCode    = HttpStatusCodes.Redirection_NotModified;
         this.Context.Response.AddHeader("content-length", "0");
         return true;
     }
     return false;
 }
Example #5
0
        private     void                    respondWithContent(VirtualFileAssembler fileAssembler)
        {
            this.Context.Response.AddHeader("ETag", fileAssembler.CachedFile.etag);
            this.Context.Response.AddHeader("content-length", fileAssembler.CachedFile.contents.Length.ToString());
#if DEBUG
            this.stopWatch.Stop();
            this.Context.Response.AddHeader("x-content-load-time", this.stopWatch.ElapsedMilliseconds.ToString() + "ms");
#endif
            fileAssembler.CachedFile.contents.Position  = 0;
            fileAssembler.CachedFile.contents.CopyTo(this.Context.Response.OutputStream);
        }
Example #6
0
        private bool                    checkForIfNoneMatch(VirtualFileAssembler fileAssembler)
        {
            string etag = null;

            if (this.Context.Request.Headers.TryGetValue("If-None-Match", out etag) && etag == fileAssembler.CachedFile.etag)
            {
                this.Context.Response.StatusCode = HttpStatusCodes.Redirection_NotModified;
                this.Context.Response.AddHeader("content-length", "0");
                return(true);
            }
            return(false);
        }
Example #7
0
        private     bool                    checkForIfNoneMatch(VirtualFileAssembler fileAssembler)
        {
            string  etag    = null;
            if (this.Context.Request.Headers.TryGetValue("If-None-Match", out etag) && etag == fileAssembler.CachedFile.etag)
            {
                this.Context.Response.StatusCode    = HttpStatusCodes.Redirection_NotModified;
                this.Context.Response.AddHeader("content-length", "0");
#if DEBUG
            this.stopWatch.Stop();
            this.Context.Response.AddHeader("x-content-load-time", this.stopWatch.ElapsedMilliseconds.ToString() + "ms");
#endif
                return true;
            }
            return false;
        }
Example #8
0
 private void respondWithContent(VirtualFileAssembler fileAssembler)
 {
     this.Context.Response.AddHeader("ETag", fileAssembler.CachedFile.etag);
     this.Context.Response.AddHeader("content-length", fileAssembler.CachedFile.contents.Length.ToString());
     this.Context.Response.Write(fileAssembler.CachedFile.contents);
 }
Example #9
0
 private void                    respondWithContent(VirtualFileAssembler fileAssembler)
 {
     this.Context.Response.AddHeader("ETag", fileAssembler.CachedFile.etag);
     this.Context.Response.AddHeader("content-length", fileAssembler.CachedFile.contents.Length.ToString());
     this.Context.Response.Write(fileAssembler.CachedFile.contents);
 }
Example #10
0
        private     bool                    checkForMissingFiles(VirtualFileAssembler fileAssembler)
        {
            if (fileAssembler.MissingFiles.Count > 0)
            {
                this.Response.AddHeader("MissingFiles", String.Join(";", fileAssembler.MissingFiles));
#if DEBUG
            this.stopWatch.Stop();
            this.Context.Response.AddHeader("x-content-load-time", this.stopWatch.ElapsedMilliseconds.ToString() + "ms");
#endif
                return true;
            }
            return false;
        }