/// <summary> /// 输出响应报文流 /// </summary> /// <param name="response"></param> /// <param name="httpBodyStream"></param> /// <param name="enableGzip"></param> /// <returns></returns> public int ResponseToBrowser(Stream httpBodyStream, bool enableGzip = false) { if (httpBodyStream == null) { ContentLength64 = 0; ResponseBytes(null); return(0); } else { if (enableGzip) { Headers[HttpResponseHeader.ContentEncoding] = "gzip"; } byte[] buf = httpBodyStream.ReadAllBytes(); if (enableGzip) { buf = Gzip.GzipBytes(buf); } ContentLength64 = buf.Length;//统一设置报文长度 ResponseBytes(buf); return(buf.Length); } }