From 85aff44e00e836eda618d4f1cf013bce38b3fd44 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 17 Nov 2024 18:23:17 -0800 Subject: URL u_port should be a number not a string. The idea here is to reduce the dynamic allocations used for URLs, and also the back and forth with parsing begin strings and port numbers. We always resolve to a port number, and this is easier for everyone. The real goal in the long term is to eliminate dynamic allocation of the URL fields altogether, but that requires a little more work. This is a step in the right direction. --- src/supplemental/http/http_server.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/supplemental/http/http_server.c') diff --git a/src/supplemental/http/http_server.c b/src/supplemental/http/http_server.c index ac57cf5b..03b3cf68 100644 --- a/src/supplemental/http/http_server.c +++ b/src/supplemental/http/http_server.c @@ -1,5 +1,5 @@ // -// Copyright 2024 Staysail Systems, Inc. +// Copyright 2023 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // Copyright 2018 QXSoftware // Copyright 2019 Devolutions @@ -962,9 +962,7 @@ http_server_init(nni_http_server **serverp, const nni_url *url) return (rv); } - // NB: We only support number port numbers, and the URL framework - // expands empty port numbers to 80 or 443 as appropriate. - s->port = atoi(url->u_port); + s->port = url->u_port; if ((s->hostname = nni_strdup(url->u_hostname)) == NULL) { http_server_fini(s); @@ -989,7 +987,7 @@ nni_http_server_init(nni_http_server **serverp, const nni_url *url) nni_mtx_lock(&http_servers_lk); NNI_LIST_FOREACH (&http_servers, s) { - if ((!s->closed) && (atoi(url->u_port) == s->port) && + if ((!s->closed) && (url->u_port == s->port) && (strcmp(url->u_hostname, s->hostname) == 0)) { *serverp = s; s->refcnt++; -- cgit v1.2.3-70-g09d2