func newCompressedResponseWriter(writer http.ResponseWriter, req *http.Request) *compressedResponseWriter {
	encodings := strings.Split(req.Header.Get(acceptEncodingHeader), ",")
	for _, encoding := range encodings {
		switch strings.TrimSpace(encoding) {
		case gzipEncoding:
			writer.Header().Set(contentEncodingHeader, gzipEncoding)
			return &compressedResponseWriter{
				ResponseWriter: writer,
				writer:         gzip.NewWriter(writer),
			}
		case deflateEncoding:
			writer.Header().Set(contentEncodingHeader, deflateEncoding)
			return &compressedResponseWriter{
				ResponseWriter: writer,
				writer:         zlib.NewWriter(writer),
			}
		}
	}
	return &compressedResponseWriter{
		ResponseWriter: writer,
		writer:         writer,
	}
}
func newCompressedResponseWriter(writer http.ResponseWriter, req *http.Request) *compressedResponseWriter {
	encodings := strings.Split(req.Header.Get(acceptEncodingHeader), ",")
	for _, encoding := range encodings {
		switch strings.TrimSpace(encoding) {
		case gzipEncoding:
			writer.Header().Set(contentEncodingHeader, gzipEncoding)
			return &compressedResponseWriter{
				ResponseWriter: writer,
				writer:         gzip.NewWriter(writer),
			}
		case deflateEncoding:
			writer.Header().Set(contentEncodingHeader, deflateEncoding)
			return &compressedResponseWriter{
				ResponseWriter: writer,
				writer:         zlib.NewWriter(writer),
			}
		}
	}
	return &compressedResponseWriter{
		ResponseWriter: writer,
		writer:         writer,
	}
}
func newCompressedResponseWriter ( writer http . ResponseWriter , req * http . Request ) * compressedResponseWriter { encodings := strings . Split ( req . Header . Get ( acceptEncodingHeader ) , " " ) for _ , encoding := range encodings { switch strings . TrimSpace ( encoding ) { case gzipEncoding : writer . Header ( ) . Set ( contentEncodingHeader , gzipEncoding ) return & compressedResponseWriter { ResponseWriter : writer , writer : gzip . NewWriter ( writer ) , } case deflateEncoding : writer . Header ( ) . Set ( contentEncodingHeader , deflateEncoding ) return & compressedResponseWriter { ResponseWriter : writer , writer : zlib . NewWriter ( writer ) , } } } return & compressedResponseWriter { ResponseWriter : writer , writer : writer , } }
// Constructs a new compressedResponseWriter based on client request headers.
Constructs a new compressedResponseWriter based on client request headers .