aboutsummaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-12-10 15:11:11 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-12-10 15:11:11 +0000
commit8a4eb8ed45f927b6d2c9c49fb3d290da1c5c2f6f (patch)
treea044486e3cf1f1c114db3eaa54e5ed7b75a63a19 /lib/url.c
parenteee70dcf8ead4857c9a219207366196bd0f28e3a (diff)
move the port number extraction to after the extraction of user name/password,
as suggested by Kai Sommerfeld
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/lib/url.c b/lib/url.c
index 74e65d164..7c1cf19be 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2885,54 +2885,6 @@ static CURLcode CreateConnection(struct SessionHandle *data,
return CURLE_UNSUPPORTED_PROTOCOL;
}
- /*************************************************************
- * Figure out the remote port number
- *
- * No matter if we use a proxy or not, we have to figure out the remote
- * port number of various reasons.
- *
- * To be able to detect port number flawlessly, we must not confuse them
- * IPv6-specified addresses in the [0::1] style. (RFC2732)
- *
- * The conn->host.name is currently [user:passwd@]host[:port] where host
- * could be a hostname, IPv4 address or IPv6 address.
- *************************************************************/
- if((1 == sscanf(conn->host.name, "[%*39[0-9a-fA-F:.]%c", &endbracket)) &&
- (']' == endbracket)) {
- /* this is a RFC2732-style specified IP-address */
- conn->bits.ipv6_ip = TRUE;
-
- conn->host.name++; /* pass the starting bracket */
- tmp = strchr(conn->host.name, ']');
- *tmp = 0; /* zero terminate */
- tmp++; /* pass the ending bracket */
- if(':' != *tmp)
- tmp = NULL; /* no port number available */
- }
- else
- tmp = strrchr(conn->host.name, ':');
-
- if (tmp) {
- char *rest;
- unsigned long port;
-
- port=strtoul(tmp+1, &rest, 10); /* Port number must be decimal */
-
- if (rest != (tmp+1) && *rest == '\0') {
- /* The colon really did have only digits after it,
- * so it is either a port number or a mistake */
-
- if (port > 0xffff) { /* Single unix standard says port numbers are
- * 16 bits long */
- failf(data, "Port number too large: %lu", port);
- return CURLE_URL_MALFORMAT;
- }
-
- *tmp = '\0'; /* cut off the name there */
- conn->remote_port = (unsigned short)port;
- }
- }
-
if(data->change.proxy && *data->change.proxy) {
/* If this is supposed to use a proxy, we need to figure out the proxy
host name name, so that we can re-use an existing connection
@@ -3079,6 +3031,54 @@ static CURLcode CreateConnection(struct SessionHandle *data,
}
}
+ /*************************************************************
+ * Figure out the remote port number
+ *
+ * No matter if we use a proxy or not, we have to figure out the remote
+ * port number of various reasons.
+ *
+ * To be able to detect port number flawlessly, we must not confuse them
+ * IPv6-specified addresses in the [0::1] style. (RFC2732)
+ *
+ * The conn->host.name is currently [user:passwd@]host[:port] where host
+ * could be a hostname, IPv4 address or IPv6 address.
+ *************************************************************/
+ if((1 == sscanf(conn->host.name, "[%*39[0-9a-fA-F:.]%c", &endbracket)) &&
+ (']' == endbracket)) {
+ /* this is a RFC2732-style specified IP-address */
+ conn->bits.ipv6_ip = TRUE;
+
+ conn->host.name++; /* pass the starting bracket */
+ tmp = strchr(conn->host.name, ']');
+ *tmp = 0; /* zero terminate */
+ tmp++; /* pass the ending bracket */
+ if(':' != *tmp)
+ tmp = NULL; /* no port number available */
+ }
+ else
+ tmp = strrchr(conn->host.name, ':');
+
+ if (tmp) {
+ char *rest;
+ unsigned long port;
+
+ port=strtoul(tmp+1, &rest, 10); /* Port number must be decimal */
+
+ if (rest != (tmp+1) && *rest == '\0') {
+ /* The colon really did have only digits after it,
+ * so it is either a port number or a mistake */
+
+ if (port > 0xffff) { /* Single unix standard says port numbers are
+ * 16 bits long */
+ failf(data, "Port number too large: %lu", port);
+ return CURLE_URL_MALFORMAT;
+ }
+
+ *tmp = '\0'; /* cut off the name there */
+ conn->remote_port = (unsigned short)port;
+ }
+ }
+
/* Programmatically set password:
* - always applies, if available
* - takes precedence over the values we just set above