home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2001 February / maximum-cd-2001-02.iso / PowerWare / Opera / Opera5_final_java.exe / OPERA.JAR / opera / OperaURLConnection.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-08-08  |  3.8 KB  |  162 lines

  1. package opera;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.io.OutputStream;
  6. import java.net.HttpURLConnection;
  7. import java.net.URL;
  8. import java.util.Enumeration;
  9. import java.util.Hashtable;
  10.  
  11. public class OperaURLConnection extends HttpURLConnection {
  12.    // $FF: renamed from: is opera.OperaInputStream
  13.    private OperaInputStream field_0 = null;
  14.    private int istream_id = -1;
  15.    // $FF: renamed from: os opera.OperaOutputStream
  16.    private OperaOutputStream field_1 = null;
  17.    private int ostream_id = -1;
  18.    private Hashtable req_props = new Hashtable();
  19.  
  20.    protected OperaURLConnection(URL var1) {
  21.       super(var1);
  22.    }
  23.  
  24.    public void connect() throws IOException {
  25.       if (!super.connected) {
  26.          SecurityManager var1 = System.getSecurityManager();
  27.          if (var1 != null) {
  28.             var1.checkConnect(super.url.getHost(), super.url.getPort());
  29.          }
  30.  
  31.          try {
  32.             this.field_0 = new OperaInputStream(this);
  33.             this.field_1 = new OperaOutputStream(this);
  34.             this.istream_id = OperaInputStream.addStream(this.field_0);
  35.             this.ostream_id = OperaOutputStream.addStream(this.field_1);
  36.             this.field_1.istream_id = this.istream_id;
  37.             if (super.method.compareTo("POST") == 0) {
  38.                Object var2 = PluginContext.opera_mutex;
  39.                synchronized(var2){}
  40.  
  41.                try {
  42.                   this.nativeConnect(super.url.toString(), super.method, this.ostream_id);
  43.                } catch (Throwable var21) {
  44.                   throw var21;
  45.                }
  46.  
  47.                super.connected = true;
  48.             } else {
  49.                Object var23 = PluginContext.opera_mutex;
  50.                synchronized(var23){}
  51.  
  52.                try {
  53.                   this.nativeConnect(super.url.toString(), super.method, this.istream_id);
  54.                } catch (Throwable var20) {
  55.                   throw var20;
  56.                }
  57.  
  58.                try {
  59.                   OperaInputStream var24 = this.field_0;
  60.                   synchronized(var24){}
  61.  
  62.                   try {
  63.                      this.field_0.wait();
  64.                   } catch (Throwable var18) {
  65.                      throw var18;
  66.                   }
  67.                } catch (InterruptedException var19) {
  68.                   Thread.currentThread().interrupt();
  69.                }
  70.  
  71.                if (this.field_0.getResponse() != 200) {
  72.                   super.connected = false;
  73.                } else {
  74.                   super.connected = true;
  75.                }
  76.             }
  77.          } catch (Exception var22) {
  78.             ((Throwable)var22).printStackTrace(System.err);
  79.          }
  80.  
  81.          if (!super.connected) {
  82.             throw new IOException("Connection failed.");
  83.          }
  84.       }
  85.  
  86.    }
  87.  
  88.    public void disconnect() {
  89.    }
  90.  
  91.    protected void finalize() throws Throwable {
  92.       if (this.field_0 != null) {
  93.          this.field_0 = null;
  94.          OperaInputStream.removeStream(this.istream_id);
  95.       }
  96.  
  97.       if (this.field_1 != null) {
  98.          this.field_1 = null;
  99.          OperaOutputStream.removeStream(this.ostream_id);
  100.       }
  101.  
  102.       super.finalize();
  103.    }
  104.  
  105.    public int getContentLength() {
  106.       return this.field_0 != null ? this.field_0.getContentLength() : 0;
  107.    }
  108.  
  109.    public String getHeaderField(String var1) {
  110.       return super.getHeaderField(var1);
  111.    }
  112.  
  113.    public InputStream getInputStream() throws IOException {
  114.       if (!super.connected) {
  115.          this.connect();
  116.       }
  117.  
  118.       return this.field_0;
  119.    }
  120.  
  121.    public OutputStream getOutputStream() throws IOException {
  122.       super.method = "POST";
  123.       if (!super.connected) {
  124.          this.connect();
  125.       }
  126.  
  127.       return this.field_1;
  128.    }
  129.  
  130.    public String getRequestProperty(String var1) {
  131.       return (String)this.req_props.get(var1);
  132.    }
  133.  
  134.    protected String makeExtraHeaders() {
  135.       String var1 = "";
  136.       Enumeration var2 = this.req_props.keys();
  137.       Enumeration var3 = this.req_props.elements();
  138.  
  139.       while(var2.hasMoreElements()) {
  140.          var1 = var1.concat((String)var2.nextElement());
  141.          String var4 = (String)var3.nextElement();
  142.          if (var4 != null) {
  143.             var1 = var1.concat(": " + var4 + "\n\r");
  144.          } else {
  145.             var1 = var1.concat("\n\r");
  146.          }
  147.       }
  148.  
  149.       return var1;
  150.    }
  151.  
  152.    private native void nativeConnect(String var1, String var2, int var3);
  153.  
  154.    public void setRequestProperty(String var1, String var2) {
  155.       this.req_props.put(var1, var2);
  156.    }
  157.  
  158.    public boolean usingProxy() {
  159.       return false;
  160.    }
  161. }
  162.