mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	内容压缩支持对已压缩内容重新压缩
This commit is contained in:
		
							
								
								
									
										30
									
								
								internal/compressions/reader_gzip.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								internal/compressions/reader_gzip.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
			
		||||
 | 
			
		||||
package compressions
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"compress/gzip"
 | 
			
		||||
	"io"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GzipReader struct {
 | 
			
		||||
	reader *gzip.Reader
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGzipReader(reader io.Reader) (Reader, error) {
 | 
			
		||||
	r, err := gzip.NewReader(reader)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return &GzipReader{
 | 
			
		||||
		reader: r,
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *GzipReader) Read(p []byte) (n int, err error) {
 | 
			
		||||
	return this.reader.Read(p)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *GzipReader) Close() error {
 | 
			
		||||
	return this.reader.Close()
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user