Index: lib/http.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/http.c,v
retrieving revision 1.334
diff -u -p -r1.334 http.c
--- lib/http.c	27 Aug 2007 06:31:28 -0000	1.334
+++ lib/http.c	14 Sep 2007 08:22:31 -0000
@@ -1740,6 +1740,7 @@ CURLcode Curl_http(struct connectdata *c
   CURLcode result=CURLE_OK;
   struct HTTP *http;
   char *ppath = data->reqdata.path;
+  char ftp_typecode[sizeof(";type=?")] = "";
   char *host = conn->host.name;
   const char *te = ""; /* transfer-encoding */
   char *ptr;
@@ -1950,6 +1951,23 @@ CURLcode Curl_http(struct connectdata *c
       }
     }
     ppath = data->change.url;
+    /* when doing ftp, append ;type=<a|i> if not present */
+    if (checkprefix("ftp://", ppath) || checkprefix("ftps://", ppath)) {
+      char *p = strstr(ppath, ";type=");
+      if (p && p[6] && p[7] == 0) {
+        switch (toupper(p[6])) {
+        case 'A':
+        case 'D':
+        case 'I':
+          break;
+        default:
+          p = NULL;
+        }
+      }
+      if (!p) {
+        sprintf(ftp_typecode, ";type=%c", data->set.prefer_ascii ? 'a' : 'i');
+      }
+    }
   }
   if(HTTPREQ_POST_FORM == httpreq) {
     /* we must build the whole darned post sequence first, so that we have
@@ -2093,7 +2111,7 @@ CURLcode Curl_http(struct connectdata *c
     result =
       add_bufferf(req_buffer,
                   "%s " /* GET/HEAD/POST/PUT */
-                  "%s HTTP/%s\r\n" /* path + HTTP version */
+                  "%s%s HTTP/%s\r\n" /* path + HTTP version */
                   "%s" /* proxyuserpwd */
                   "%s" /* userpwd */
                   "%s" /* range */
@@ -2108,6 +2126,7 @@ CURLcode Curl_http(struct connectdata *c
 
                 request,
                 ppath,
+                ftp_typecode,
                 httpstring,
                 conn->allocptr.proxyuserpwd?
                 conn->allocptr.proxyuserpwd:"",
Index: tests/data/test208
===================================================================
RCS file: /cvsroot/curl/curl/tests/data/test208,v
retrieving revision 1.5
diff -u -p -r1.5 test208
--- tests/data/test208	9 Mar 2007 21:01:40 -0000	1.5
+++ tests/data/test208	14 Sep 2007 08:22:31 -0000
@@ -44,7 +44,7 @@ the
 ^User-Agent:.*
 </strip>
 <protocol>
-PUT ftp://daniel:mysecret@host.com/we/want/208 HTTP/1.1
+PUT ftp://daniel:mysecret@host.com/we/want/208;type=i HTTP/1.1
 Authorization: Basic ZGFuaWVsOm15c2VjcmV0
 Host: host.com:21
 Pragma: no-cache
Index: tests/data/test79
===================================================================
RCS file: /cvsroot/curl/curl/tests/data/test79,v
retrieving revision 1.9
diff -u -p -r1.9 test79
--- tests/data/test79	9 Mar 2007 21:01:40 -0000	1.9
+++ tests/data/test79	14 Sep 2007 08:22:31 -0000
@@ -45,7 +45,7 @@ ftp://%HOSTIP:%HTTPPORT/we/want/that/pag
 ^User-Agent:.*
 </strip>
 <protocol>
-GET ftp://127.0.0.1:%HTTPPORT/we/want/that/page/79 HTTP/1.1
+GET ftp://127.0.0.1:%HTTPPORT/we/want/that/page/79;type=i HTTP/1.1
 Host: 127.0.0.1:%HTTPPORT
 Pragma: no-cache
 Accept: */*
