commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1650420 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/ftp/FTP.java main/java/org/apache/commons/net/ftp/FTPClient.java main/java/org/apache/commons/net/ftp/FTPHTTPClient.java
Date Thu, 08 Jan 2015 23:29:41 GMT
Author: sebb
Date: Thu Jan  8 23:29:40 2015
New Revision: 1650420

URL: http://svn.apache.org/r1650420
Log:
NET-552 SocketTimeoutException connecting a FTP server via an HTTP Proxy

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java

Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1650420&r1=1650419&r2=1650420&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml [utf-8] (original)
+++ commons/proper/net/trunk/src/changes/changes.xml [utf-8] Thu Jan  8 23:29:40 2015
@@ -62,12 +62,15 @@ The <action> type attribute can be add,u
      -->
 
     <body>
-        <release version="3.4" date="2014-01-??" description="
+        <release version="3.4" date="2015-01-??" description="
 This is mainly a bug-fix release. See further details below.
   Notable additions:
   IMAPExportMbox (example app) allows IMAP folders to be exported into an mbox file.
   This is the inverse of the IMAPImportMbox example added previously
         ">
+            <action issue="NET-552" type="fix" dev="sebb" due-to="Quentin Devriendt">
+            SocketTimeoutException connecting a FTP server via an HTTP Proxy
+            </action>
             <action issue="NET-528" type="add" dev="sebb">
             FTPListParseEngine does not provide access to raw responses
             </action>

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java?rev=1650420&r1=1650419&r2=1650420&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTP.java Thu Jan  8
23:29:40 2015
@@ -21,6 +21,7 @@ import java.io.BufferedWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
+import java.io.Reader;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
@@ -377,9 +378,18 @@ public class FTP extends SocketClient
     @Override
     protected void _connectAction_() throws IOException
     {
+        _connectAction_(null);
+    }
+
+
+    protected void _connectAction_(Reader socketIsReader) throws IOException {
         super._connectAction_(); // sets up _input_ and _output_
-        _controlInput_ =
-            new CRLFLineReader(new InputStreamReader(_input_, getControlEncoding()));
+        if(socketIsReader == null) {
+            _controlInput_ =
+                    new CRLFLineReader(new InputStreamReader(_input_, getControlEncoding()));
+        } else {
+            _controlInput_ = new CRLFLineReader(socketIsReader);
+        }
         _controlOutput_ =
             new BufferedWriter(new OutputStreamWriter(_output_, getControlEncoding()));
         if (connectTimeout > 0) { // NET-385

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=1650420&r1=1650419&r2=1650420&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java Thu Jan
 8 23:29:40 2015
@@ -24,6 +24,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.io.Reader;
 import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
@@ -939,7 +940,14 @@ implements Configurable
     @Override
     protected void _connectAction_() throws IOException
     {
-        super._connectAction_(); // sets up _input_ and _output_
+        _connectAction_(null);
+    }
+
+
+    @Override
+    protected void _connectAction_(Reader socketIsReader) throws IOException
+    {
+    	super._connectAction_(socketIsReader); // sets up _input_ and _output_
         __initDefaults();
         // must be after super._connectAction_(), because otherwise we get an
         // Exception claiming we're not connected

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java?rev=1650420&r1=1650419&r2=1650420&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPHTTPClient.java Thu
Jan  8 23:29:40 2015
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
+import java.io.Reader;
 import java.io.UnsupportedEncodingException;
 import java.net.Inet6Address;
 import java.net.Socket;
@@ -131,18 +132,19 @@ public class FTPHTTPClient extends FTPCl
         _socket_ = new Socket(proxyHost, proxyPort);
         _input_ = _socket_.getInputStream();
         _output_ = _socket_.getOutputStream();
+        Reader socketIsReader;
         try {
-            tunnelHandshake(host, port, _input_, _output_);
+            socketIsReader = tunnelHandshake(host, port, _input_, _output_);
         }
         catch (Exception e) {
             IOException ioe = new IOException("Could not connect to " + host+ " using port
" + port);
             ioe.initCause(e);
             throw ioe;
         }
-        super._connectAction_();
+        super._connectAction_(socketIsReader);
     }
 
-    private void tunnelHandshake(String host, int port, InputStream input, OutputStream output)
throws IOException,
+    private BufferedReader tunnelHandshake(String host, int port, InputStream input, OutputStream
output) throws IOException,
     UnsupportedEncodingException {
         final String connectString = "CONNECT "  + host + ":" + port  + " HTTP/1.1";
         final String hostString = "Host: " + host + ":" + port;
@@ -193,6 +195,7 @@ public class FTPHTTPClient extends FTPCl
             }
             throw new IOException(msg.toString());
         }
+        return reader;
     }
 }
 



Mime
View raw message