From 1c93e75375882ed309c7d93a1ce59d27a53f23d3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 2 Dec 2007 23:38:23 +0000 Subject: Michal Marek introduced CURLOPT_PROXY_TRANSFER_MODE which is used to control the appending of the "type=" thing on FTP URLs when they are passed to a HTTP proxy. Some proxies just don't like that appending (which is done unconditionally in 7.17.1), and some proxies treat binary/ascii transfers better with the appending done! --- lib/http.c | 30 ++++++++++++++++-------------- lib/url.c | 17 +++++++++++++++++ lib/urldata.h | 2 ++ 3 files changed, 35 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/http.c b/lib/http.c index 635506e08..7cfb23f3c 100644 --- a/lib/http.c +++ b/lib/http.c @@ -2122,22 +2122,24 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) } } ppath = data->change.url; - /* when doing ftp, append ;type= if not present */ - if(checkprefix("ftp://", ppath) || checkprefix("ftps://", ppath)) { - char *p = strstr(ppath, ";type="); - if(p && p[6] && p[7] == 0) { - switch (toupper((int)((unsigned char)p[6]))) { - case 'A': - case 'D': - case 'I': - break; - default: - p = NULL; + if (data->set.proxy_transfer_mode) { + /* when doing ftp, append ;type= if not present */ + if(checkprefix("ftp://", ppath) || checkprefix("ftps://", ppath)) { + char *p = strstr(ppath, ";type="); + if(p && p[6] && p[7] == 0) { + switch (toupper((int)((unsigned char)p[6]))) { + case 'A': + case 'D': + case 'I': + break; + default: + p = NULL; + } } + if(!p) + snprintf(ftp_typecode, sizeof(ftp_typecode), ";type=%c", + data->set.prefer_ascii ? 'a' : 'i'); } - if(!p) - snprintf(ftp_typecode, sizeof(ftp_typecode), ";type=%c", - data->set.prefer_ascii ? 'a' : 'i'); } } if(HTTPREQ_POST_FORM == httpreq) { diff --git a/lib/url.c b/lib/url.c index e7c1412bf..a176ac225 100644 --- a/lib/url.c +++ b/lib/url.c @@ -2036,6 +2036,23 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, */ data->set.new_directory_perms = va_arg(param, long); break; + case CURLOPT_PROXY_TRANSFER_MODE: + /* + * set transfer mode (;type=) when doing FTP via an HTTP proxy + */ + switch (va_arg(param, long)) { + case 0: + data->set.proxy_transfer_mode = FALSE; + break; + case 1: + data->set.proxy_transfer_mode = TRUE; + break; + default: + /* reserve other values for future use */ + result = CURLE_FAILED_INIT; + break; + } + break; default: /* unknown tag and its companion, just ignore: */ diff --git a/lib/urldata.h b/lib/urldata.h index 0188a8e93..9febb8415 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1439,6 +1439,8 @@ struct UserDefined { content-encoded (chunked, compressed) */ long new_file_perms; /* Permissions to use when creating remote files */ long new_directory_perms; /* Permissions to use when creating remote dirs */ + bool proxy_transfer_mode; /* set transfer mode (;type=) when doing FTP + via an HTTP proxy */ char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */ }; -- cgit v1.2.3