in datahub/restclient.go [278:301]
func (client *RestClient) compressIfNeed(header map[string]string, reqBody *[]byte) {
if client.CompressorType == NOCOMPRESS {
return
}
compressor := getCompressor(client.CompressorType)
if compressor != nil {
header[httpHeaderAcceptEncoding] = client.CompressorType.String()
compressedReqBody, err := compressor.Compress(*reqBody)
if err != nil {
log.Warningf("compress failed, give up compression, error:%v", err)
} else if len(compressedReqBody) > len(*reqBody) {
if log.IsLevelEnabled(log.DebugLevel) {
log.Debugf("compress invalid, give up compression, rawSize:%d, compressSize:%d",
len(*reqBody), len(compressedReqBody))
}
} else {
header[httpHeaderContentEncoding] = client.CompressorType.String()
//header[httpHeaderAcceptEncoding] = client.CompressorType.String()
header[httpHeaderRawSize] = strconv.Itoa(len(*reqBody))
*reqBody = compressedReqBody
}
}
header[httpHeaderContentLength] = strconv.Itoa(len(*reqBody))
}