2003/02/22 03:59:43
[org.ibex.core.git] / src / org / xwt / HTTP.java
index acdfcc3..22a0761 100644 (file)
@@ -39,9 +39,6 @@ public class HTTP {
     /** the socket's inputstream */
     InputStream in = null;
 
-    /** the socket's outputstream */
-    PrintWriter out = null;
-
     /** the username and password portions of the URL */
     String userInfo = null;
 
@@ -321,24 +318,12 @@ public class HTTP {
     // Everything Else ////////////////////////////////////////////////////////////////////////////
 
     private synchronized void connect() throws IOException {
-        if (sock != null && !"".equals(originalUrl)) {
+        if (sock != null) {
             if (in == null) in = new BufferedInputStream(sock.getInputStream());
             return;
         }
         // grab the userinfo; gcj doesn't have java.net.URL.getUserInfo()
         String url = originalUrl;
-
-        if ("".equals(url)) {
-            userInfo = "";
-            this.url = null;
-            port = 80;
-            path = "/RPC2";
-            host = "";
-            in = System.in;
-            out = new PrintWriter(System.out);
-            return;
-        }
-
         userInfo = url.substring(url.indexOf("://") + 3);
         userInfo = userInfo.indexOf('/') == -1 ? userInfo : userInfo.substring(0, userInfo.indexOf('/'));
         if (userInfo.indexOf('@') != -1) {
@@ -347,7 +332,7 @@ public class HTTP {
         } else {
             userInfo = null;
         }
-        
+
         if (url.startsWith("https:")) {
             this.url = new URL("http" + url.substring(5));
             ssl = true;
@@ -356,7 +341,6 @@ public class HTTP {
         } else {
             this.url = new URL(url);
         }
-
         if (!skipResolveCheck) resolveAndCheckIfFirewalled(this.url.getHost());
         port = this.url.getPort();
         path = this.url.getFile();
@@ -372,12 +356,11 @@ public class HTTP {
         if (sock == null) sock = attemptDirect();
         if (sock == null) throw new HTTPException("unable to contact host " + host);
         if (in == null) in = new BufferedInputStream(sock.getInputStream());
-        if (out == null) out = new PrintWriter(new OutputStreamWriter(sock.getOutputStream()));
     }
 
     public void sendRequest(String contentType, String content) throws IOException {
 
-        PrintWriter pw = out;
+        PrintWriter pw = new PrintWriter(new OutputStreamWriter(sock.getOutputStream()));
         if (content != null) {
             pw.print("POST " + path + " HTTP/1.1\r\n");
         int contentLength = content.substring(0, 2).equals("\r\n") ?