Spring框架学习[Spring HTTP调用器实现远程调用](六)
Gzip压缩的,则需要先解压 if (isGzipResponse(con)) {
return new GZIPInputStream(con.getInputStream()); }
//正常的HTTP响应 else {
return con.getInputStream(); }
} //是否是Gzip格式压缩
protected boolean isGzipResponse(HttpURLConnection con) { //获取HTTP响应头信息中的压缩方式
String encodingHeader = con.getHeaderField(HTTP_HEADER_CONTENT_ENCODING); return (encodingHeader != null && encodingHeader.toLowerCase().indexOf(ENCODING_GZIP) != -1);
} }