mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
- When doing non-anonymous ftp via http proxies and the password is not
provided in the url, add it there (squid needs this).
This commit is contained in:
parent
afe06d1563
commit
0b317b72ae
4
CHANGES
4
CHANGES
@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Michal Marek (16 Jun 2009)
|
||||||
|
- When doing non-anonymous ftp via http proxies and the password is not
|
||||||
|
provided in the url, add it there (squid needs this).
|
||||||
|
|
||||||
Daniel Stenberg (15 Jun 2009)
|
Daniel Stenberg (15 Jun 2009)
|
||||||
- Eric Wong's patch:
|
- Eric Wong's patch:
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ This release includes the following bugfixes:
|
|||||||
o libcurl-NSS client cert handling segfaults
|
o libcurl-NSS client cert handling segfaults
|
||||||
o curl uploading from stdin/pipes now works in non-blocking way so that it
|
o curl uploading from stdin/pipes now works in non-blocking way so that it
|
||||||
continues the downloading even when the read stalls
|
continues the downloading even when the read stalls
|
||||||
|
o ftp credentials are added to the url if needed for http proxies
|
||||||
|
|
||||||
This release includes the following known bugs:
|
This release includes the following known bugs:
|
||||||
|
|
||||||
|
58
lib/http.c
58
lib/http.c
@ -2060,6 +2060,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
CURLcode result=CURLE_OK;
|
CURLcode result=CURLE_OK;
|
||||||
struct HTTP *http;
|
struct HTTP *http;
|
||||||
const char *ppath = data->state.path;
|
const char *ppath = data->state.path;
|
||||||
|
bool paste_ftp_userpwd = FALSE;
|
||||||
char ftp_typecode[sizeof(";type=?")] = "";
|
char ftp_typecode[sizeof(";type=?")] = "";
|
||||||
const char *host = conn->host.name;
|
const char *host = conn->host.name;
|
||||||
const char *te = ""; /* transfer-encoding */
|
const char *te = ""; /* transfer-encoding */
|
||||||
@ -2288,24 +2289,26 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ppath = data->change.url;
|
ppath = data->change.url;
|
||||||
if (data->set.proxy_transfer_mode) {
|
if(checkprefix("ftp://", ppath)) {
|
||||||
/* when doing ftp, append ;type=<a|i> if not present */
|
if (data->set.proxy_transfer_mode) {
|
||||||
if(checkprefix("ftp://", ppath) || checkprefix("ftps://", ppath)) {
|
/* when doing ftp, append ;type=<a|i> if not present */
|
||||||
char *p = strstr(ppath, ";type=");
|
char *p = strstr(ppath, ";type=");
|
||||||
if(p && p[6] && p[7] == 0) {
|
if(p && p[6] && p[7] == 0) {
|
||||||
switch (Curl_raw_toupper(p[6])) {
|
switch (Curl_raw_toupper(p[6])) {
|
||||||
case 'A':
|
case 'A':
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'I':
|
case 'I':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
p = NULL;
|
p = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if(!p)
|
||||||
if(!p)
|
snprintf(ftp_typecode, sizeof(ftp_typecode), ";type=%c",
|
||||||
snprintf(ftp_typecode, sizeof(ftp_typecode), ";type=%c",
|
data->set.prefer_ascii ? 'a' : 'i');
|
||||||
data->set.prefer_ascii ? 'a' : 'i');
|
|
||||||
}
|
}
|
||||||
|
if (conn->bits.user_passwd && !conn->bits.userpwd_in_url)
|
||||||
|
paste_ftp_userpwd = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* CURL_DISABLE_PROXY */
|
#endif /* CURL_DISABLE_PROXY */
|
||||||
@ -2464,10 +2467,23 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
/* add the main request stuff */
|
/* add the main request stuff */
|
||||||
result =
|
/* GET/HEAD/POST/PUT */
|
||||||
add_bufferf(req_buffer,
|
result = add_bufferf(req_buffer, "%s ", request);
|
||||||
"%s " /* GET/HEAD/POST/PUT */
|
if (result)
|
||||||
"%s%s HTTP/%s\r\n" /* path + HTTP version */
|
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" /* proxyuserpwd */
|
||||||
"%s" /* userpwd */
|
"%s" /* userpwd */
|
||||||
"%s" /* range */
|
"%s" /* range */
|
||||||
@ -2479,8 +2495,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
"%s" /* Proxy-Connection */
|
"%s" /* Proxy-Connection */
|
||||||
"%s",/* transfer-encoding */
|
"%s",/* transfer-encoding */
|
||||||
|
|
||||||
request,
|
|
||||||
ppath,
|
|
||||||
ftp_typecode,
|
ftp_typecode,
|
||||||
httpstring,
|
httpstring,
|
||||||
conn->allocptr.proxyuserpwd?
|
conn->allocptr.proxyuserpwd?
|
||||||
|
@ -3831,6 +3831,7 @@ static CURLcode parse_url_userpass(struct SessionHandle *data,
|
|||||||
* set user/passwd, but doing that first adds more cases here :-(
|
* set user/passwd, but doing that first adds more cases here :-(
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
conn->bits.userpwd_in_url = 1;
|
||||||
if(data->set.use_netrc != CURL_NETRC_REQUIRED) {
|
if(data->set.use_netrc != CURL_NETRC_REQUIRED) {
|
||||||
/* We could use the one in the URL */
|
/* We could use the one in the URL */
|
||||||
|
|
||||||
|
@ -625,6 +625,7 @@ struct ConnectBits {
|
|||||||
EPRT doesn't work we disable it for the forthcoming
|
EPRT doesn't work we disable it for the forthcoming
|
||||||
requests */
|
requests */
|
||||||
bool netrc; /* name+password provided by netrc */
|
bool netrc; /* name+password provided by netrc */
|
||||||
|
bool userpwd_in_url; /* name+password found in url */
|
||||||
|
|
||||||
bool done; /* set to FALSE when Curl_do() is called and set to TRUE
|
bool done; /* set to FALSE when Curl_do() is called and set to TRUE
|
||||||
when Curl_done() is called, to prevent Curl_done() to
|
when Curl_done() is called, to prevent Curl_done() to
|
||||||
|
53
tests/data/test299
Normal file
53
tests/data/test299
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<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
|
||||||
|
Authorization: Basic bWljaGFsOmF5YmFidHU=
|
||||||
|
Host: host.com:21
|
||||||
|
Accept: */*
|
||||||
|
Proxy-Connection: Keep-Alive
|
||||||
|
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
||||||
|
</testcase>
|
Loading…
Reference in New Issue
Block a user