- gzip 配置源码:
public class Compression {
private boolean enabled = false;
private String[] mimeTypes = new String[]{"text/html", "text/xml", "text/plain", "text/css", "text/javascript", "application/javascript", "application/json", "application/xml"};
private String[] excludedUserAgents = null;
private DataSize minResponseSize = DataSize.ofKilobytes(2L);
......
}
- 服务端(provider):
server:
compression:
enabled: true
#mime-types: 按需配置
#min-response-size:默认2k(2048)按需配置
- 客户端(consume):
feign:
compression:
request:
enabled: true
response:
enabled: true
useGzipDecoder: true
如果有碰到类似以下响应报文解析异常,加上配置:response.useGzipDecoder:true
JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space