Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 向页面输出内容
 /// </summary>
 /// <param name="data"></param>
 /// <param name="responseType"></param>
 public void Send(byte[] data, string responseType)
 {
     if (this.IsCompress)
     {
         CompressionUtils.Send(data, responseType);
     }
     else
     {
         HttpResponse response = HttpContext.Current.Response;
         response.Charset     = "utf-8";
         response.ContentType = responseType;
         response.BinaryWrite(data);
     }
 }
Ejemplo n.º 3
0
        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);
        }