package org.bench4q.recorder.httpcapture.generator;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.GZIPOutputStream;

public class GzipEncoder extends ContentEncoder{

	public byte[] encoderContent(byte[] content){
		try {
			ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
			GZIPOutputStream gzipOutputStream = new GZIPOutputStream(outputStream);
			
			gzipOutputStream.write(content, 0, content.length);
			gzipOutputStream.finish();  
			  
			gzipOutputStream.flush();  
			gzipOutputStream.close(); 
			return outputStream.toByteArray();
		} catch (IOException e) {
			logger.error("decodeContent", e);
			return null;
		}
	}
}
