aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ftp.c2
-rw-r--r--lib/url.c19
-rw-r--r--lib/urldata.h4
-rw-r--r--tests/data/DISABLED1
-rw-r--r--tests/data/test5632
5 files changed, 18 insertions, 10 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index c3de7e0bc..40ed4b790 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -4178,6 +4178,7 @@ static CURLcode ftp_setup_connection(struct connectdata * conn)
}
data->state.path++; /* don't include the initial slash */
+ data->state.slash_removed = TRUE; /* we've skipped the slash */
/* FTP URLs support an extension like ";type=<typecode>" that
* we'll try to get now! */
@@ -4189,6 +4190,7 @@ static CURLcode ftp_setup_connection(struct connectdata * conn)
if(type) {
*type = 0; /* it was in the middle of the hostname */
command = Curl_raw_toupper(type[6]);
+ conn->bits.type_set = TRUE;
switch (command) {
case 'A': /* ASCII mode */
diff --git a/lib/url.c b/lib/url.c
index 228e35386..fd6443a59 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -4259,18 +4259,23 @@ static CURLcode parse_remote_port(struct SessionHandle *data,
if(conn->bits.httpproxy) {
/* we need to create new URL with the new port number */
char *url;
- /* FTPS connections have the FTP bit set too, so they match as well */
- bool isftp = (bool)(0 != (conn->protocol & PROT_FTP));
+ char type[12]="";
+
+ if(conn->bits.type_set)
+ snprintf(type, sizeof(type), ";type=%c",
+ data->set.prefer_ascii?'A':
+ (data->set.ftp_list_only?'D':'I'));
/*
- * This synthesized URL isn't always right--suffixes like ;type=A
- * are stripped off. It would be better to work directly from the
- * original URL and simply replace the port part of it.
+ * This synthesized URL isn't always right--suffixes like ;type=A are
+ * stripped off. It would be better to work directly from the original
+ * URL and simply replace the port part of it.
*/
- url = aprintf("%s://%s%s%s:%hu%s%s", conn->handler->scheme,
+ url = aprintf("%s://%s%s%s:%hu%s%s%s", conn->handler->scheme,
conn->bits.ipv6_ip?"[":"", conn->host.name,
conn->bits.ipv6_ip?"]":"", conn->remote_port,
- isftp?"/":"", data->state.path);
+ data->state.slash_removed?"/":"", data->state.path,
+ type);
if(!url)
return CURLE_OUT_OF_MEMORY;
diff --git a/lib/urldata.h b/lib/urldata.h
index 7763278d2..7919921f7 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -418,6 +418,7 @@ struct ConnectBits {
that libcurl should reconnect and continue. */
bool bound; /* set true if bind() has already been done on this socket/
connection */
+ bool type_set; /* type= was used in the URL */
};
struct hostname {
@@ -1127,7 +1128,8 @@ struct UrlState {
char *pathbuffer;/* allocated buffer to store the URL's path part in */
char *path; /* path to use, points to somewhere within the pathbuffer
area */
-
+ bool slash_removed; /* set TRUE if the 'path' points to a path where the
+ initial URL slash separator has been taken off */
bool use_range;
bool rangestringalloc; /* the range string is malloc()'ed */
diff --git a/tests/data/DISABLED b/tests/data/DISABLED
index 42c5f8aa1..b6071cbd9 100644
--- a/tests/data/DISABLED
+++ b/tests/data/DISABLED
@@ -2,5 +2,4 @@
# test cases are run by runtests.pl. Just add the plain test case numbers, one
# per line.
# Lines starting with '#' letters are treated as comments.
-563
564
diff --git a/tests/data/test563 b/tests/data/test563
index 5d2d7338b..785152319 100644
--- a/tests/data/test563
+++ b/tests/data/test563
@@ -47,7 +47,7 @@ ftp_proxy=http://%HOSTIP:%HTTPPORT/
# Verify data after the test has been "shot"
<verify>
<protocol>
-GET ftp://%HOSTIP:%FTPPORT/563;type=A HTTP/1.1
+GET FTP://%HOSTIP:%FTPPORT/563;type=A HTTP/1.1
Host: %HOSTIP:%FTPPORT
Accept: */*
Proxy-Connection: Keep-Alive