MINOR: http-htx: Use new HTTP functions for the scheme based normalization

Use http_get_host_port() and http_is_default_port() functions to perform the
scheme based normalization.

(cherry picked from commit d1d983fb1267a42e602bf7fb0467e4cfa3c184de)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d2376a318965b0831f3205b7d5f884e09958eeb2)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 5fb0031a12f5570247f122032a8aa6592447730a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/http_htx.c b/src/http_htx.c
index 6f5c1a1..e97141c 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -1721,12 +1721,6 @@
 	return NULL;
 }
 
-static int uri_is_default_port(const struct ist scheme, const struct ist port)
-{
-	return (isteq(port, ist("443")) && isteqi(scheme, ist("https://"))) ||
-	        (isteq(port, ist("80")) && isteqi(scheme, ist("http://")));
-}
-
 /* Apply schemed-based normalization as described on rfc3986 on section 6.3.2.
  * Returns 0 if no error has been found else non-zero.
  *
@@ -1741,7 +1735,6 @@
 	struct http_hdr_ctx ctx;
 	struct htx_sl *sl;
 	struct ist uri, scheme, authority, host, port;
-	char *start, *end, *ptr;
 
 	sl = http_get_stline(htx);
 
@@ -1755,25 +1748,16 @@
 	if (!isttest(scheme))
 		return 0;
 
-	/* Extract the port if present in authority. To properly support ipv6
-	 * hostnames, do a reverse search on the last ':' separator as long as
-	 * digits are found.
-	 */
-	authority = http_get_authority(uri, 0);
-	start = istptr(authority);
-	end = istend(authority);
-	for (ptr = end; ptr > start && isdigit((unsigned char)*--ptr); )
-		;
-
-	/* if no port found, no normalization to proceed */
-	if (likely(*ptr != ':'))
+	/* Extract the port if present in authority */
+	authority = http_get_authority(uri, 1);
+	port = http_get_host_port(authority);
+	if (!isttest(port)) {
+		/* if no port found, no normalization to proceed */
 		return 0;
-
-	/* split host/port on the ':' separator found */
-	host = ist2(start, ptr - start);
-	port = istnext(ist2(ptr, end - ptr));
+	}
+	host = isttrim(authority, istlen(authority) - istlen(port) - 1);
 
-	if (istlen(port) && uri_is_default_port(scheme, port)) {
+	if (istlen(port) && http_is_default_port(scheme, port)) {
 		/* reconstruct the uri with removal of the port */
 		struct buffer *temp = get_trash_chunk();
 		struct ist meth, vsn;