try {
errorStream = new GZIPInputStream(errorStream, 4096);
} catch (IOException e) {
}
} else if (encoding.toLowerCase().trim().equals("deflate")) {
errorStream = new InflaterInputStream(errorStream, new Inflater(true), 4096);
}
}
InputStreamReader reader = new InputStreamReader(errorStream);
char[] buffer = new char[4096];
int b;
while ((b = reader.read(buffer)) > -1) {
sb.append(buffer, 0, b);
}
reader.close();
errorContent = sb.toString();
} catch (IOException e) {
errorContent = "Unable to retrieve content: " + e.getMessage();
}
}
} else {
try {
errorStream.close();
} catch (IOException e) {
}
}
if (responseStream != null) {
try {
responseStream.close();
} catch (IOException e) {
}
}
return;
}
// get the stream length
String lengthStr = getHeader("Content-Length");
if (lengthStr != null) {
try {
length = new BigInteger(lengthStr);
} catch (NumberFormatException e) {
}
}
if (stream != null) {
String encoding = getContentEncoding();
if (encoding != null) {
if (encoding.toLowerCase().trim().equals("gzip")) {
// if the stream is gzip encoded, decode it
length = null;
try {
stream = new GZIPInputStream(stream, 4096);
} catch (IOException e) {
errorContent = e.getMessage();
stream = null;
try {
responseStream.close();
} catch (IOException ec) {
}
}
} else if (encoding.toLowerCase().trim().equals("deflate")) {
// if the stream is deflate encoded, decode it
length = null;
stream = new InflaterInputStream(stream, new Inflater(true), 4096);
}
}
String transferEncoding = getContentTransferEncoding();
if ((stream != null) && (transferEncoding != null)