aboutsummaryrefslogtreecommitdiff
path: root/lib/http.c
diff options
context:
space:
mode:
authorMichal Marek <mmarek@suse.cz>2009-06-16 13:16:28 +0000
committerMichal Marek <mmarek@suse.cz>2009-06-16 13:16:28 +0000
commit0b317b72ae6f23eb4dbd0a22509a20ff5acb2958 (patch)
treefc1a05be21aa1ea7a36a9ef385ac60d1abbb3647 /lib/http.c
parentafe06d15639d9add4c62880a3020c3707fdff9f9 (diff)
- When doing non-anonymous ftp via http proxies and the password is not
provided in the url, add it there (squid needs this).
Diffstat (limited to 'lib/http.c')
-rw-r--r--lib/http.c58
1 files changed, 36 insertions, 22 deletions
diff --git a/lib/http.c b/lib/http.c
index 8457b51f4..f69c5aaaf 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -2060,6 +2060,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
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 */
@@ -2288,24 +2289,26 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
}
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 */
@@ -2464,10 +2467,23 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
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 */
@@ -2479,8 +2495,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
"%s" /* Proxy-Connection */
"%s",/* transfer-encoding */
- request,
- ppath,
ftp_typecode,
httpstring,
conn->allocptr.proxyuserpwd?