You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2013/01/23 01:34:16 UTC
svn commit: r1437243 - in /commons/proper/net/trunk/src: changes/changes.xml
main/java/org/apache/commons/net/ftp/FTPHTTPClient.java
Author: sebb
Date: Wed Jan 23 00:34:15 2013
New Revision: 1437243
URL: http://svn.apache.org/viewvc?rev=1437243&view=rev
Log:
NET-480 Wrong passivHost when using FTPHTTPClient with EPSV
Modified:
commons/proper/net/trunk/src/changes/changes.xml
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=1437243&r1=1437242&r2=1437243&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml (original)
+++ commons/proper/net/trunk/src/changes/changes.xml Wed Jan 23 00:34:15 2013
@@ -64,6 +64,9 @@ The <action> type attribute can be add,u
<body>
<release version="3.3" date="TBA" description="
">
+ <action issue="NET-480" dev="sebb" type="fix">
+ Wrong passivHost when using FTPHTTPClient with EPSV
+ </action>
<action issue="NET-494" dev="sebb" type="fix">
FTPClient.CSL.cleanUp() fails to restore timeout value on exception
</action>
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=1437243&r1=1437242&r2=1437243&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 Wed Jan 23 00:34:15 2013
@@ -45,11 +45,14 @@ public class FTPHTTPClient extends FTPCl
private static final byte[] CRLF={'\r', '\n'};
private final Base64 base64 = new Base64();
+ private String tunnelHost; // Save the host when setting up a tunnel (needed for EPSV)
+
public FTPHTTPClient(String proxyHost, int proxyPort, String proxyUser, String proxyPass) {
this.proxyHost = proxyHost;
this.proxyPort = proxyPort;
this.proxyUsername = proxyUser;
this.proxyPassword = proxyPass;
+ this.tunnelHost = null;
}
public FTPHTTPClient(String proxyHost, int proxyPort) {
@@ -85,10 +88,12 @@ public class FTPHTTPClient extends FTPCl
}
final boolean isInet6Address = getRemoteAddress() instanceof Inet6Address;
+ String passiveHost = null;
boolean attemptEPSV = isUseEPSVwithIPv4() || isInet6Address;
if (attemptEPSV && epsv() == FTPReply.ENTERING_EPSV_MODE) {
_parseExtendedPassiveModeReply(_replyLines.get(0));
+ passiveHost = this.tunnelHost;
} else {
if (isInet6Address) {
return null; // Must use EPSV for IPV6
@@ -98,12 +103,13 @@ public class FTPHTTPClient extends FTPCl
return null;
}
_parsePassiveModeReply(_replyLines.get(0));
+ passiveHost = this.getPassiveHost();
}
Socket socket = new Socket(proxyHost, proxyPort);
InputStream is = socket.getInputStream();
OutputStream os = socket.getOutputStream();
- tunnelHandshake(this.getPassiveHost(), this.getPassivePort(), is, os);
+ tunnelHandshake(passiveHost, this.getPassivePort(), is, os);
if ((getRestartOffset() > 0) && !restart(getRestartOffset())) {
socket.close();
return null;
@@ -139,6 +145,7 @@ public class FTPHTTPClient extends FTPCl
final String connectString = "CONNECT " + host + ":" + port + " HTTP/1.1";
final String hostString = "Host: " + host + ":" + port;
+ this.tunnelHost = host;
output.write(connectString.getBytes("UTF-8")); // TODO what is the correct encoding?
output.write(CRLF);
output.write(hostString.getBytes("UTF-8"));