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:
Daniel Stenberg
2010-08-10 00:56:45 +02:00
parent 5d5dd08e77
commit dc2157a087
5 changed files with 18 additions and 10 deletions

View File

@@ -4259,18 +4259,23 @@ static CURLcode parse_remote_port(struct SessionHandle *data,
if(conn->bits.httpproxy) {
/* we need to create new URL with the new port number */
char *url;
/* FTPS connections have the FTP bit set too, so they match as well */
bool isftp = (bool)(0 != (conn->protocol & PROT_FTP));
char type[12]="";
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
* are stripped off. It would be better to work directly from the
* original URL and simply replace the port part of it.
* This synthesized URL isn't always right--suffixes like ;type=A are
* stripped off. It would be better to work directly from the original
* 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->remote_port,
isftp?"/":"", data->state.path);
data->state.slash_removed?"/":"", data->state.path,
type);
if(!url)
return CURLE_OUT_OF_MEMORY;