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); }
private bool checkForMissingFiles(VirtualFileAssembler fileAssembler) { if (fileAssembler.MissingFiles.Count > 0) { this.Response.AddHeader("MissingFiles", String.Join(";", fileAssembler.MissingFiles)); return true; } return false; }
private bool checkForMissingFiles(VirtualFileAssembler fileAssembler) { if (fileAssembler.MissingFiles.Count > 0) { this.Response.AddHeader("MissingFiles", String.Join(";", fileAssembler.MissingFiles)); return(true); } return(false); }
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; }
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); }
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); }
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; }
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); }
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; }