Skip to content

Commit

Permalink
minor refactoring in deflate related code
Browse files Browse the repository at this point in the history
  • Loading branch information
hrj committed Oct 3, 2015
1 parent a3d5dba commit e74aadc
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/Common/org/lobobrowser/util/io/IORoutines.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,32 +198,28 @@ public static java.util.List<String> loadStrings(final File file) throws IOExcep

public static InputStream getDecodedStream(final URLConnection connection) throws IOException {
final InputStream cis = connection.getInputStream();
final InputStream is;
if ("gzip".equals(connection.getContentEncoding())) {
is = new GZIPInputStream(cis);
return new GZIPInputStream(cis);
} else if ("deflate".equals(connection.getContentEncoding())) {
is = new InflaterInputStream(cis);
return new InflaterInputStream(cis);
} else {
is = cis;
return cis;
}
return is;
}

public static InputStream getDecodedErrorStream(final HttpURLConnection connection) throws IOException {
final InputStream cis = connection.getErrorStream();
final InputStream is;
if (cis != null) {
if ("gzip".equals(connection.getContentEncoding())) {
is = new GZIPInputStream(cis);
return new GZIPInputStream(cis);
} else if ("deflate".equals(connection.getContentEncoding())) {
is = new InflaterInputStream(cis);
return new InflaterInputStream(cis);
} else {
is = cis;
return cis;
}
} else {
is = null;
return null;
}
return is;
}

}

0 comments on commit e74aadc

Please sign in to comment.