CURLcode result=CURLE_OK;
struct HTTP *http;
const char *ppath = data->state.path;
+ bool paste_ftp_userpwd = FALSE;
char ftp_typecode[sizeof(";type=?")] = "";
const char *host = conn->host.name;
const char *te = ""; /* transfer-encoding */
}
}
ppath = data->change.url;
- if (data->set.proxy_transfer_mode) {
- /* 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 (Curl_raw_toupper(p[6])) {
- case 'A':
- case 'D':
- case 'I':
- break;
- default:
- p = NULL;
+ if(checkprefix("ftp://", ppath)) {
+ if (data->set.proxy_transfer_mode) {
+ /* when doing ftp, append ;type=<a|i> if not present */
+ char *p = strstr(ppath, ";type=");
+ if(p && p[6] && p[7] == 0) {
+ switch (Curl_raw_toupper(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 (conn->bits.user_passwd && !conn->bits.userpwd_in_url)
+ paste_ftp_userpwd = TRUE;
}
}
#endif /* CURL_DISABLE_PROXY */
return CURLE_OUT_OF_MEMORY;
/* add the main request stuff */
- result =
- add_bufferf(req_buffer,
- "%s " /* GET/HEAD/POST/PUT */
- "%s%s HTTP/%s\r\n" /* path + HTTP version */
+ /* GET/HEAD/POST/PUT */
+ result = add_bufferf(req_buffer, "%s ", request);
+ if (result)
+ return result;
+
+ /* url */
+ if (paste_ftp_userpwd)
+ result = add_bufferf(req_buffer, "ftp://%s:%s@%s",
+ conn->user, conn->passwd, ppath + sizeof("ftp://") - 1);
+ else
+ result = add_buffer(req_buffer, ppath, strlen(ppath));
+ if (result)
+ return result;
+
+ result = add_bufferf(req_buffer,
+ "%s" /* ftp typecode (;type=x) */
+ " HTTP/%s\r\n" /* HTTP version */
"%s" /* proxyuserpwd */
"%s" /* userpwd */
"%s" /* range */
"%s" /* Proxy-Connection */
"%s",/* transfer-encoding */
- request,
- ppath,
ftp_typecode,
httpstring,
conn->allocptr.proxyuserpwd?
--- /dev/null
+<testcase>
+<info>
+<keywords>
+FTP
+HTTP
+CURLOPT_USERPWD
+HTTP proxy
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<data>
+HTTP/1.0 200 OK swsclose
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+
+blablabla
+
+</data>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+<features>
+ftp
+</features>
+ <name>
+FTP over HTTP proxy with user:pass not in url
+ </name>
+ <command>
+-x http://%HOSTIP:%HTTPPORT -u michal:aybabtu ftp://host.com/we/want/299
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET ftp://michal:aybabtu@host.com/we/want/299 HTTP/1.1\r
+Authorization: Basic bWljaGFsOmF5YmFidHU=\r
+Host: host.com:21\r
+Accept: */*\r
+Proxy-Connection: Keep-Alive\r
+\r
+</protocol>
+</verify>
+</testcase>