home *** CD-ROM | disk | FTP | other *** search
- package sun.rmi.transport.proxy;
-
- import java.io.DataInputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.io.PrintStream;
- import java.net.InetAddress;
- import java.net.Socket;
- import java.net.SocketException;
- import java.net.SocketImpl;
- import java.net.URL;
- import java.net.URLConnection;
- import java.net.UnknownHostException;
- import java.rmi.server.LogStream;
-
- class HttpSendSocket extends Socket implements RMISocketInfo {
- protected String host;
- protected int port;
- protected URL url;
- protected URLConnection conn;
- // $FF: renamed from: in java.io.InputStream
- protected InputStream field_0;
- protected OutputStream out;
- protected HttpSendInputStream inNotifier;
- protected HttpSendOutputStream outNotifier;
-
- public HttpSendSocket(String var1, int var2, URL var3) throws IOException {
- super((SocketImpl)null);
- if (RMIMasterSocketFactory.logLevel >= 20) {
- LogStream.log("proxy").println("HttpSendSocket.<init>: host = " + var1 + ", port = " + var2 + ", url = " + var3);
- }
-
- this.host = var1;
- this.port = var2;
- this.url = var3;
- this.inNotifier = new HttpSendInputStream((InputStream)null, this);
- this.outNotifier = new HttpSendOutputStream(this.writeNotify(), this);
- }
-
- public HttpSendSocket(String var1, int var2) throws IOException {
- this(var1, var2, new URL("http", var1, var2, "/"));
- }
-
- public HttpSendSocket(InetAddress var1, int var2) throws IOException {
- this(var1.getHostName(), var2);
- }
-
- public boolean isReusable() {
- return false;
- }
-
- public synchronized OutputStream writeNotify() throws IOException {
- if (this.conn != null) {
- throw new IOException("attempt to write on HttpSendSocket after request has been sent");
- } else {
- this.conn = this.url.openConnection();
- this.conn.setDoOutput(true);
- this.conn.setUseCaches(false);
- this.conn.setRequestProperty("Content-type", "application/octet-stream");
- this.inNotifier.deactivate();
- this.field_0 = null;
- return this.out = this.conn.getOutputStream();
- }
- }
-
- public synchronized InputStream readNotify() throws IOException {
- if (RMIMasterSocketFactory.logLevel >= 20) {
- LogStream.log("proxy").println("HttpSendSocket.readNotify: sending request and activating input stream");
- }
-
- this.outNotifier.deactivate();
- this.out.close();
- this.out = null;
-
- try {
- this.field_0 = this.conn.getInputStream();
- } catch (IOException var16) {
- IOException var1 = var16;
- if (RMIMasterSocketFactory.logLevel >= 10) {
- LogStream var2 = LogStream.log("proxy");
- synchronized(var2){}
-
- try {
- ((PrintStream)var2).print("HttpSendSocket.readNotify: failed to get input stream, exception: ");
- ((Throwable)var1).printStackTrace(var2);
- } catch (Throwable var15) {
- throw var15;
- }
- }
-
- throw new IOException("HTTP request failed");
- }
-
- String var19 = this.conn.getContentType();
- if (var19 != null && this.conn.getContentType().equals("application/octet-stream")) {
- return this.field_0;
- } else {
- if (RMIMasterSocketFactory.logLevel >= 10) {
- LogStream var20 = LogStream.log("proxy");
- synchronized(var20){}
-
- try {
- if (var19 == null) {
- ((PrintStream)var20).println("HttpSendSocket.readNotify: missing content type in response");
- } else {
- ((PrintStream)var20).println("HttpSendSocket.readNotify: invalid content type in response: " + var19);
- }
-
- ((PrintStream)var20).print("HttpSendSocket.readNotify: response body: ");
-
- try {
- DataInputStream var5 = new DataInputStream(this.field_0);
-
- String var6;
- while((var6 = var5.readLine()) != null) {
- ((PrintStream)var20).println(var6);
- }
- } catch (IOException var17) {
- }
- } catch (Throwable var18) {
- throw var18;
- }
- }
-
- throw new IOException("HTTP request failed");
- }
- }
-
- public InetAddress getInetAddress() {
- try {
- return InetAddress.getByName(this.host);
- } catch (UnknownHostException var1) {
- return null;
- }
- }
-
- public InetAddress getLocalAddress() {
- try {
- return InetAddress.getLocalHost();
- } catch (UnknownHostException var1) {
- return null;
- }
- }
-
- public int getPort() {
- return this.port;
- }
-
- public int getLocalPort() {
- return -1;
- }
-
- public InputStream getInputStream() throws IOException {
- return this.inNotifier;
- }
-
- public OutputStream getOutputStream() throws IOException {
- return this.outNotifier;
- }
-
- public void setTcpNoDelay(boolean var1) throws SocketException {
- }
-
- public boolean getTcpNoDelay() throws SocketException {
- return false;
- }
-
- public void setSoLinger(boolean var1, int var2) throws SocketException {
- }
-
- public int getSoLinger() throws SocketException {
- return -1;
- }
-
- public synchronized void setSoTimeout(int var1) throws SocketException {
- }
-
- public synchronized int getSoTimeout() throws SocketException {
- return 0;
- }
-
- public synchronized void close() throws IOException {
- if (this.out != null) {
- this.out.close();
- }
-
- }
-
- public String toString() {
- return "HttpSendSocket[host=" + this.host + ",port=" + this.port + ",url=" + this.url + "]";
- }
- }
-