📄 resourcedownloaderurlimpl.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: ResourceDownloaderURLImpl.java
package org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader;
import com.aelitis.azureus.core.util.DeleteFileOnCloseInputStream;
import com.aelitis.azureus.core.util.Java15Utils;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.zip.*;
import javax.net.ssl.*;
import org.gudy.azureus2.core3.security.SEPasswordListener;
import org.gudy.azureus2.core3.security.SESecurityManager;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloaderCancelledException;
import org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloaderException;
// Referenced classes of package org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader:
// ResourceDownloaderBaseImpl
public class ResourceDownloaderURLImpl extends ResourceDownloaderBaseImpl
implements SEPasswordListener
{
private static final int BUFFER_SIZE = 32768;
private static final int MAX_IN_MEM_READ_SIZE = 0x40000;
protected URL original_url;
protected boolean auth_supplied;
protected String user_name;
protected String password;
protected InputStream input_stream;
protected boolean cancel_download;
protected boolean download_initiated;
protected long size;
protected boolean force_no_proxy;
private final String post_data;
public ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, URL _url)
{
this(_parent, _url, false, null, null);
}
public ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, URL _url, String _user_name, String _password)
{
this(_parent, _url, true, _user_name, _password);
}
public ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, URL _url, boolean _auth_supplied, String _user_name, String _password)
{
this(_parent, _url, null, _auth_supplied, _user_name, _password);
}
public ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, URL _url, String _data, boolean _auth_supplied, String _user_name, String _password)
{
super(_parent);
cancel_download = false;
size = -2L;
force_no_proxy = false;
original_url = _url;
post_data = _data;
auth_supplied = _auth_supplied;
user_name = _user_name;
password = _password;
}
protected void setForceNoProxy(boolean force_no_proxy)
{
this.force_no_proxy = force_no_proxy;
}
protected URL getURL()
{
return original_url;
}
public String getName()
{
return original_url.toString();
}
public long getSize()
throws ResourceDownloaderException
{
if (size != -2L)
break MISSING_BLOCK_LABEL_80;
ResourceDownloaderURLImpl c = (ResourceDownloaderURLImpl)getClone(this);
addReportListener(c);
size = c.getSizeSupport();
setProperties(c);
if (size == -2L)
size = -1L;
break MISSING_BLOCK_LABEL_80;
Exception exception;
exception;
if (size == -2L)
size = -1L;
throw exception;
return size;
}
protected void setSize(long l)
{
size = l;
}
public void setProperty(String name, Object value)
throws ResourceDownloaderException
{
setPropertySupport(name, value);
}
protected long getSizeSupport()
throws ResourceDownloaderException
{
String protocol = original_url.getProtocol().toLowerCase();
if (protocol.equals("magnet") || protocol.equals("dht"))
return -1L;
reportActivity(this, (new StringBuilder()).append("Getting size of ").append(original_url).toString());
URL url;
url = new URL(original_url.toString().replaceAll(" ", "%20"));
url = AddressUtils.adjustURL(url);
int i;
if (auth_supplied)
SESecurityManager.setPasswordHandler(url, this);
i = 0;
_L1:
if (i >= 2)
break MISSING_BLOCK_LABEL_336;
long l;
HttpURLConnection con;
if (url.getProtocol().equalsIgnoreCase("https"))
{
HttpsURLConnection ssl_con = (HttpsURLConnection)openConnection(url);
ssl_con.setHostnameVerifier(new HostnameVerifier() {
final ResourceDownloaderURLImpl this$0;
public boolean verify(String host, SSLSession session)
{
return true;
}
{
this$0 = ResourceDownloaderURLImpl.this;
super();
}
});
con = ssl_con;
} else
{
con = (HttpURLConnection)openConnection(url);
}
con.setRequestMethod("HEAD");
con.setRequestProperty("User-Agent", "Azureus 4.2.0.0");
setRequestProperties(con, false);
con.connect();
int response = con.getResponseCode();
if (response != 202 && response != 200)
{
setProperty("URL_HTTP_Response", new Long(response));
throw new ResourceDownloaderException((new StringBuilder()).append("Error on connect for '").append(trimForDisplay(url)).append("': ").append(Integer.toString(response)).append(" ").append(con.getResponseMessage()).toString());
}
getRequestProperties(con);
l = con.getContentLength();
if (auth_supplied)
SESecurityManager.setPasswordHandler(url, null);
return l;
SSLException e;
e;
if (i != 0 || SESecurityManager.installServerCertificates(url) == null)
throw e;
i++;
goto _L1
throw new ResourceDownloaderException("Should never get here");
Exception exception;
exception;
if (auth_supplied)
SESecurityManager.setPasswordHandler(url, null);
throw exception;
MalformedURLException e;
e;
throw new ResourceDownloaderException((new StringBuilder()).append("Exception while parsing URL '").append(original_url).append("':").append(e.getMessage()).toString(), e);
e;
throw new ResourceDownloaderException((new StringBuilder()).append("Exception while initializing download of '").append(trimForDisplay(original_url)).append("': Unknown Host '").append(e.getMessage()).append("'").toString(), e);
e;
throw new ResourceDownloaderException((new StringBuilder()).append("I/O Exception while downloading '").append(trimForDisplay(original_url)).append("'").toString(), e);
Throwable e;
e;
ResourceDownloaderException rde;
if (e instanceof ResourceDownloaderException)
rde = (ResourceDownloaderException)e;
else
rde = new ResourceDownloaderException("Unexpected error", e);
throw rde;
}
public ResourceDownloaderBaseImpl getClone(ResourceDownloaderBaseImpl parent)
{
ResourceDownloaderURLImpl c = new ResourceDownloaderURLImpl(parent, original_url, post_data, auth_supplied, user_name, password);
c.setSize(size);
c.setProperties(this);
c.setForceNoProxy(force_no_proxy);
return c;
}
public void asyncDownload()
{
Object parent_tls = TorrentUtils.getTLS();
AEThread2 t = new AEThread2(true, parent_tls) {
final Object val$parent_tls;
final ResourceDownloaderURLImpl this$0;
public void run()
{
label0:
{
Object child_tls = TorrentUtils.getTLS();
TorrentUtils.setTLS(parent_tls);
try
{
download();
}
catch (ResourceDownloaderException e)
{
TorrentUtils.setTLS(child_tls);
break label0;
}
finally
{
TorrentUtils.setTLS(child_tls);
throw exception;
}
TorrentUtils.setTLS(child_tls);
break label0;
}
}
{
this$0 = ResourceDownloaderURLImpl.this;
parent_tls = obj;
super(x0, x1);
}
};
t.start();
}
public InputStream download()
throws ResourceDownloaderException
{
reportActivity(this, (new StringBuilder()).append(getLogIndent()).append("Downloading: ").append(trimForDisplay(original_url)).toString());
this_mon.enter();
if (download_initiated)
throw new ResourceDownloaderException("Download already initiated");
download_initiated = true;
this_mon.exit();
break MISSING_BLOCK_LABEL_87;
MalformedURLException e;
e;
this_mon.exit();
throw e;
URL url;
url = new URL(original_url.toString().replaceAll(" ", "%20"));
String protocol = url.getProtocol().toLowerCase();
if (url.getPort() == -1 && !protocol.equals("magnet") && !protocol.equals("dht"))
{
int target_port;
if (protocol.equals("http"))
target_port = 80;
else
target_port = 443;
try
{
String str = original_url.toString().replaceAll(" ", "%20");
int pos = str.indexOf("://");
pos = str.indexOf("/", pos + 4);
if (pos == -1)
url = new URL((new StringBuilder()).append(str).append(":").append(target_port).append("/").toString());
else
url = new URL((new StringBuilder()).append(str.substring(0, pos)).append(":").append(target_port).append(str.substring(pos)).toString());
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
}
url = AddressUtils.adjustURL(url);
boolean use_compression;
boolean follow_redirect;
int redirect_loop;
if (auth_supplied)
SESecurityManager.setPasswordHandler(url, this);
use_compression = true;
follow_redirect = true;
redirect_loop = 0;
_L4:
int ssl_loop;
if (redirect_loop >= 2 || !follow_redirect)
break MISSING_BLOCK_LABEL_1433;
follow_redirect = false;
ssl_loop = 0;
_L3:
File temp_file;
if (ssl_loop >= 2)
break MISSING_BLOCK_LABEL_1427;
temp_file = null;
HttpURLConnection con;
int response;
String move_to;
if (url.getProtocol().equalsIgnoreCase("https"))
{
HttpsURLConnection ssl_con = (HttpsURLConnection)openConnection(url);
ssl_con.setHostnameVerifier(new HostnameVerifier() {
final ResourceDownloaderURLImpl this$0;
public boolean verify(String host, SSLSession session)
{
return true;
}
{
this$0 = ResourceDownloaderURLImpl.this;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -