private void WriteFile(string responseType) { this.output = this.GetCache(); if (this.output != null) { this.Send(this.output, responseType); return; } this.sb = new StringBuilder(4096); using (this.stream) { StreamReader reader = new StreamReader(this.stream); this.sb.Append(reader.ReadToEnd()); reader.Close(); } string data = responseType == "text/css" ? this.sm.ParseCssWebResourceUrls(this.sb.ToString()) : this.sb.ToString(); byte[] content = this.compress ? CompressionUtils.GZip(data) : Encoding.UTF8.GetBytes(data); this.SetCache(content); this.Send(content, responseType); }
/// <summary> /// 输出文件 /// </summary> /// <param name="responseType"></param> private void WriteFile(string responseType) { this._output = this.GetCache(); if (this._output != null) { this.Send(this._output, responseType); return; } if (this._stream == null) { Response404(responseType); return; } this._sb = new StringBuilder(4096); using (this._stream) { var reader = new StreamReader(this._stream); this._sb.Append(reader.ReadToEnd()); } var data = _sb.ToString(); //压缩脚本与样式 if (IsMinify && !IsDebug) { data = ResourceHelper.MinHelper.MinJs(data); } var content = this.IsCompress ? CompressionUtils.GZip(data) : Encoding.UTF8.GetBytes(data); this.SetCache(content); this.Send(content, responseType); }
private void WriteFile(string responseType) { this.output = this.GetCache(); if (this.output != null) { CompressionUtils.Send(this.output, responseType); return; } this.sb = new StringBuilder(4096); using (this.stream) { StreamReader reader = new StreamReader(this.stream); this.sb.Append(reader.ReadToEnd()); reader.Close(); } byte[] gzip; if (responseType == "text/css") { gzip = CompressionUtils.GZip(this.sm.ParseCssWebResourceUrls(this.sb.ToString())); } else { gzip = CompressionUtils.GZip(this.sb.ToString()); } this.SetCache(gzip); CompressionUtils.Send(gzip, responseType); }
private void WriteImage(string responseType) { this.output = this.GetCache(); if (this.output != null) { CompressionUtils.Send(this.output, responseType); return; } this.length = Convert.ToInt32(this.stream.Length); this.image = new Byte[this.length]; this.stream.Read(this.image, 0, this.length); byte[] gzip = CompressionUtils.GZip(this.image); this.SetCache(gzip); CompressionUtils.Send(gzip, responseType); }