mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
parse_remote_port: fix ;type= URL suffix over HTTP proxy
Test 563 is enabled now and verifies that the combo FTP type=A URL, CURLOPT_PORT set and proxy work fine. As a bonus I managed to remove the somewhat odd FTP check in parse_remote_port() and instead converted it to a better and more generic 'slash_removed' struct field. Checking the ->protocol field isn't right since when an FTP:// URL is sent over a HTTP proxy, the protocol is HTTP but the URL was handled by the FTP code and thus slash_removed is set TRUE for this case.
This commit is contained in:
parent
5d5dd08e77
commit
dc2157a087
@ -4178,6 +4178,7 @@ static CURLcode ftp_setup_connection(struct connectdata * conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
data->state.path++; /* don't include the initial slash */
|
data->state.path++; /* don't include the initial slash */
|
||||||
|
data->state.slash_removed = TRUE; /* we've skipped the slash */
|
||||||
|
|
||||||
/* FTP URLs support an extension like ";type=<typecode>" that
|
/* FTP URLs support an extension like ";type=<typecode>" that
|
||||||
* we'll try to get now! */
|
* we'll try to get now! */
|
||||||
@ -4189,6 +4190,7 @@ static CURLcode ftp_setup_connection(struct connectdata * conn)
|
|||||||
if(type) {
|
if(type) {
|
||||||
*type = 0; /* it was in the middle of the hostname */
|
*type = 0; /* it was in the middle of the hostname */
|
||||||
command = Curl_raw_toupper(type[6]);
|
command = Curl_raw_toupper(type[6]);
|
||||||
|
conn->bits.type_set = TRUE;
|
||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 'A': /* ASCII mode */
|
case 'A': /* ASCII mode */
|
||||||
|
19
lib/url.c
19
lib/url.c
@ -4259,18 +4259,23 @@ static CURLcode parse_remote_port(struct SessionHandle *data,
|
|||||||
if(conn->bits.httpproxy) {
|
if(conn->bits.httpproxy) {
|
||||||
/* we need to create new URL with the new port number */
|
/* we need to create new URL with the new port number */
|
||||||
char *url;
|
char *url;
|
||||||
/* FTPS connections have the FTP bit set too, so they match as well */
|
char type[12]="";
|
||||||
bool isftp = (bool)(0 != (conn->protocol & PROT_FTP));
|
|
||||||
|
if(conn->bits.type_set)
|
||||||
|
snprintf(type, sizeof(type), ";type=%c",
|
||||||
|
data->set.prefer_ascii?'A':
|
||||||
|
(data->set.ftp_list_only?'D':'I'));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This synthesized URL isn't always right--suffixes like ;type=A
|
* This synthesized URL isn't always right--suffixes like ;type=A are
|
||||||
* are stripped off. It would be better to work directly from the
|
* stripped off. It would be better to work directly from the original
|
||||||
* original URL and simply replace the port part of it.
|
* URL and simply replace the port part of it.
|
||||||
*/
|
*/
|
||||||
url = aprintf("%s://%s%s%s:%hu%s%s", conn->handler->scheme,
|
url = aprintf("%s://%s%s%s:%hu%s%s%s", conn->handler->scheme,
|
||||||
conn->bits.ipv6_ip?"[":"", conn->host.name,
|
conn->bits.ipv6_ip?"[":"", conn->host.name,
|
||||||
conn->bits.ipv6_ip?"]":"", conn->remote_port,
|
conn->bits.ipv6_ip?"]":"", conn->remote_port,
|
||||||
isftp?"/":"", data->state.path);
|
data->state.slash_removed?"/":"", data->state.path,
|
||||||
|
type);
|
||||||
if(!url)
|
if(!url)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -418,6 +418,7 @@ struct ConnectBits {
|
|||||||
that libcurl should reconnect and continue. */
|
that libcurl should reconnect and continue. */
|
||||||
bool bound; /* set true if bind() has already been done on this socket/
|
bool bound; /* set true if bind() has already been done on this socket/
|
||||||
connection */
|
connection */
|
||||||
|
bool type_set; /* type= was used in the URL */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hostname {
|
struct hostname {
|
||||||
@ -1127,7 +1128,8 @@ struct UrlState {
|
|||||||
char *pathbuffer;/* allocated buffer to store the URL's path part in */
|
char *pathbuffer;/* allocated buffer to store the URL's path part in */
|
||||||
char *path; /* path to use, points to somewhere within the pathbuffer
|
char *path; /* path to use, points to somewhere within the pathbuffer
|
||||||
area */
|
area */
|
||||||
|
bool slash_removed; /* set TRUE if the 'path' points to a path where the
|
||||||
|
initial URL slash separator has been taken off */
|
||||||
bool use_range;
|
bool use_range;
|
||||||
bool rangestringalloc; /* the range string is malloc()'ed */
|
bool rangestringalloc; /* the range string is malloc()'ed */
|
||||||
|
|
||||||
|
@ -2,5 +2,4 @@
|
|||||||
# test cases are run by runtests.pl. Just add the plain test case numbers, one
|
# test cases are run by runtests.pl. Just add the plain test case numbers, one
|
||||||
# per line.
|
# per line.
|
||||||
# Lines starting with '#' letters are treated as comments.
|
# Lines starting with '#' letters are treated as comments.
|
||||||
563
|
|
||||||
564
|
564
|
||||||
|
@ -47,7 +47,7 @@ ftp_proxy=http://%HOSTIP:%HTTPPORT/
|
|||||||
# Verify data after the test has been "shot"
|
# Verify data after the test has been "shot"
|
||||||
<verify>
|
<verify>
|
||||||
<protocol>
|
<protocol>
|
||||||
GET ftp://%HOSTIP:%FTPPORT/563;type=A HTTP/1.1
|
GET FTP://%HOSTIP:%FTPPORT/563;type=A HTTP/1.1
|
||||||
Host: %HOSTIP:%FTPPORT
|
Host: %HOSTIP:%FTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Proxy-Connection: Keep-Alive
|
Proxy-Connection: Keep-Alive
|
||||||
|
Loading…
Reference in New Issue
Block a user