This commit is contained in:
Redkale
2018-05-30 19:47:21 +08:00
parent e79fdd887c
commit 7352d5b8ed

View File

@@ -1676,6 +1676,7 @@ public final class Utility {
public static ByteArrayOutputStream remoteHttpContent(SSLContext ctx, String method, String url, int timeout, Map<String, String> headers, String body) throws IOException {
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
try {
conn.setConnectTimeout(timeout > 0 ? timeout : 3000);
conn.setReadTimeout(timeout > 0 ? timeout : 3000);
if (conn instanceof HttpsURLConnection) {
@@ -1709,8 +1710,10 @@ public final class Utility {
while ((pos = in.read(bytes)) != -1) {
out.write(bytes, 0, pos);
}
conn.disconnect();
return out;
} finally {
conn.disconnect();
}
}
public static String read(InputStream in) throws IOException {