mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-29 18:34:42 +00:00
format proxy code, allow to change swf on the fly
This commit is contained in:
@@ -10,143 +10,118 @@ import java.util.Vector;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Https extends Http {
|
||||
/* XXX - more than 1 should work now. */
|
||||
/* XXX - more than 1 should work now. */
|
||||
|
||||
static final int MAX_PENDING_REQUESTS = 1;
|
||||
|
||||
static Hashtable cache = new Hashtable(33);
|
||||
private static Object httpLock = new Object();
|
||||
|
||||
public Https(String host, int port) throws IOException
|
||||
{
|
||||
this(host, port, false);
|
||||
public Https(String host, int port) throws IOException {
|
||||
this(host, port, false);
|
||||
}
|
||||
|
||||
public Https(String host, int port, boolean isProxy) throws IOException
|
||||
{
|
||||
super(host, port,isProxy);
|
||||
public Https(String host, int port, boolean isProxy) throws IOException {
|
||||
super(host, port, isProxy);
|
||||
}
|
||||
|
||||
private static String cacheKey(String host, int port)
|
||||
{
|
||||
return host.toLowerCase() + ":" + port;
|
||||
private static String cacheKey(String host, int port) {
|
||||
return host.toLowerCase() + ":" + port;
|
||||
}
|
||||
|
||||
private static Vector cacheLookup(String host, int port)
|
||||
{
|
||||
Vector v = (Vector) cache.get(cacheKey(host, port));
|
||||
return v;
|
||||
private static Vector cacheLookup(String host, int port) {
|
||||
Vector v = (Vector) cache.get(cacheKey(host, port));
|
||||
return v;
|
||||
}
|
||||
|
||||
private static boolean cacheContains(Https http)
|
||||
{
|
||||
Vector v = (Vector) cache.get(cacheKey(http.host, http.port));
|
||||
return v != null ? v.contains(http) : false;
|
||||
private static boolean cacheContains(Https http) {
|
||||
Vector v = (Vector) cache.get(cacheKey(http.host, http.port));
|
||||
return v != null ? v.contains(http) : false;
|
||||
}
|
||||
|
||||
private static void cacheInsert(String host, int port, Https http)
|
||||
{
|
||||
String key = cacheKey(host, port);
|
||||
Vector v = (Vector) cache.get(key);
|
||||
if (v == null)
|
||||
{
|
||||
v = new Vector();
|
||||
}
|
||||
v.addElement(http);
|
||||
cache.put(key, v);
|
||||
private static void cacheInsert(String host, int port, Https http) {
|
||||
String key = cacheKey(host, port);
|
||||
Vector v = (Vector) cache.get(key);
|
||||
if (v == null) {
|
||||
v = new Vector();
|
||||
}
|
||||
v.addElement(http);
|
||||
cache.put(key, v);
|
||||
}
|
||||
|
||||
private static void cacheRemove(String host, int port, Https http)
|
||||
{
|
||||
Vector v = (Vector) cache.get(cacheKey(host, port));
|
||||
if (v != null)
|
||||
{
|
||||
v.removeElement(http);
|
||||
if (v.isEmpty())
|
||||
{
|
||||
cache.remove(cacheKey(host, port));
|
||||
}
|
||||
}
|
||||
private static void cacheRemove(String host, int port, Https http) {
|
||||
Vector v = (Vector) cache.get(cacheKey(host, port));
|
||||
if (v != null) {
|
||||
v.removeElement(http);
|
||||
if (v.isEmpty()) {
|
||||
cache.remove(cacheKey(host, port));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void cacheClean()
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
Enumeration e = cache.keys();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Vector v = (Vector) cache.get(e.nextElement());
|
||||
for (int i = 0; i < v.size(); i++)
|
||||
{
|
||||
Https http = (Https) v.elementAt(i);
|
||||
if (http.idle > 0 && now - http.idle > 30000) /* 30 seconds */
|
||||
{
|
||||
http.persistent = false;
|
||||
http.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void cacheClean() {
|
||||
long now = System.currentTimeMillis();
|
||||
Enumeration e = cache.keys();
|
||||
while (e.hasMoreElements()) {
|
||||
Vector v = (Vector) cache.get(e.nextElement());
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
Https http = (Https) v.elementAt(i);
|
||||
if (http.idle > 0 && now - http.idle > 30000) /* 30 seconds */ {
|
||||
http.persistent = false;
|
||||
http.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Https open(String host, int port, boolean isProxy)
|
||||
throws IOException
|
||||
{
|
||||
Https http = null;
|
||||
throws IOException {
|
||||
Https http = null;
|
||||
|
||||
synchronized (httpLock)
|
||||
{
|
||||
Vector v = cacheLookup(host, port);
|
||||
if (v != null)
|
||||
{
|
||||
for (int i = 0; i < v.size(); i++)
|
||||
{
|
||||
Https pick = (Https) v.elementAt(i);
|
||||
synchronized (httpLock) {
|
||||
Vector v = cacheLookup(host, port);
|
||||
if (v != null) {
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
Https pick = (Https) v.elementAt(i);
|
||||
|
||||
/* find an http connection that isn't busy */
|
||||
if (pick.isPersistent() && !pick.isBusy())
|
||||
{
|
||||
http = pick;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* find an http connection that isn't busy */
|
||||
if (pick.isPersistent() && !pick.isBusy()) {
|
||||
http = pick;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (http != null)
|
||||
{
|
||||
http.idle = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (http != null) {
|
||||
http.idle = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (http == null)
|
||||
{
|
||||
http = new Https(host, port, isProxy);
|
||||
cacheInsert(host, port, http);
|
||||
}
|
||||
if (http == null) {
|
||||
http = new Https(host, port, isProxy);
|
||||
cacheInsert(host, port, http);
|
||||
}
|
||||
|
||||
return http;
|
||||
return http;
|
||||
}
|
||||
|
||||
static Https open(String host, int port) throws IOException
|
||||
{
|
||||
return open(host, port, false);
|
||||
static Https open(String host, int port) throws IOException {
|
||||
return open(host, port, false);
|
||||
}
|
||||
|
||||
static Enumeration enumerate()
|
||||
{
|
||||
Vector list = new Vector();
|
||||
Enumeration e = cache.keys();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Vector v = (Vector) cache.get(e.nextElement());
|
||||
for (int i = 0; i < v.size(); i++)
|
||||
{
|
||||
list.addElement(v.elementAt(i));
|
||||
}
|
||||
}
|
||||
return list.elements();
|
||||
static Enumeration enumerate() {
|
||||
Vector list = new Vector();
|
||||
Enumeration e = cache.keys();
|
||||
while (e.hasMoreElements()) {
|
||||
Vector v = (Vector) cache.get(e.nextElement());
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
list.addElement(v.elementAt(i));
|
||||
}
|
||||
}
|
||||
return list.elements();
|
||||
}
|
||||
|
||||
static synchronized void clean()
|
||||
{
|
||||
cacheClean();
|
||||
static synchronized void clean() {
|
||||
cacheClean();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user