feat: 新增307跳转支持

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-08-16 12:14:11 +08:00
parent 66c7508009
commit adea1e58e0

View File

@ -271,8 +271,8 @@ public class DownloadManager {
*/ */
private URLConnection reload(final CommandSender sender, final URLConnection uc) throws Exception { private URLConnection reload(final CommandSender sender, final URLConnection uc) throws Exception {
final HttpURLConnection huc = (HttpURLConnection) uc; final HttpURLConnection huc = (HttpURLConnection) uc;
// 302, 301 // 302, 301, 307
if (huc.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP || huc.getResponseCode() == HttpURLConnection.HTTP_MOVED_PERM) { if (huc.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP || huc.getResponseCode() == HttpURLConnection.HTTP_MOVED_PERM || huc.getResponseCode() == 307) {
final String url = huc.getHeaderField("Location"); final String url = huc.getHeaderField("Location");
sender.sendMessage("§6跳转至地址: §3" + url); sender.sendMessage("§6跳转至地址: §3" + url);
return reload(sender, new URL(url).openConnection()); return reload(sender, new URL(url).openConnection());