|
|
@ -2,6 +2,7 @@ package seaweedfs.client; |
|
|
|
|
|
|
|
import org.apache.http.HttpEntity; |
|
|
|
import org.apache.http.HttpHeaders; |
|
|
|
import org.apache.http.client.entity.GzipDecompressingEntity; |
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
|
|
import org.apache.http.client.methods.HttpGet; |
|
|
|
import org.apache.http.util.EntityUtils; |
|
|
@ -78,7 +79,7 @@ public class SeaweedRead { |
|
|
|
HttpGet request = new HttpGet( |
|
|
|
String.format("http://%s/%s", locations.getLocations(0).getUrl(), chunkView.fileId)); |
|
|
|
|
|
|
|
request.setHeader(HttpHeaders.ACCEPT_ENCODING, ""); |
|
|
|
request.setHeader(HttpHeaders.ACCEPT_ENCODING, "gzip"); |
|
|
|
|
|
|
|
byte[] data = null; |
|
|
|
|
|
|
@ -87,6 +88,18 @@ public class SeaweedRead { |
|
|
|
try { |
|
|
|
HttpEntity entity = response.getEntity(); |
|
|
|
|
|
|
|
Header contentEncodingHeader = entity.getContentEncoding(); |
|
|
|
|
|
|
|
if (contentEncodingHeader != null) { |
|
|
|
HeaderElement[] encodings =contentEncodingHeader.getElements(); |
|
|
|
for (int i = 0; i < encodings.length; i++) { |
|
|
|
if (encodings[i].getName().equalsIgnoreCase("gzip")) { |
|
|
|
entity = new GzipDecompressingEntity(entity); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
data = EntityUtils.toByteArray(entity); |
|
|
|
|
|
|
|
EntityUtils.consume(entity); |
|
|
@ -96,10 +109,6 @@ public class SeaweedRead { |
|
|
|
request.releaseConnection(); |
|
|
|
} |
|
|
|
|
|
|
|
if (chunkView.isCompressed) { |
|
|
|
// data = Gzip.decompress(data); |
|
|
|
} |
|
|
|
|
|
|
|
if (chunkView.cipherKey != null && chunkView.cipherKey.length != 0) { |
|
|
|
try { |
|
|
|
data = SeaweedCipher.decrypt(data, chunkView.cipherKey); |
|
|
|