aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/http/http_server.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-17 18:23:17 -0800
committerGarrett D'Amore <garrett@damore.org>2024-11-17 22:05:20 -0800
commit85aff44e00e836eda618d4f1cf013bce38b3fd44 (patch)
tree94b2dca800d6d254baae17932a017e031c17ce67 /src/supplemental/http/http_server.c
parentef82d4792bf59b1fe8053d9bb5ac924b443d8a78 (diff)
downloadnng-85aff44e00e836eda618d4f1cf013bce38b3fd44.tar.gz
nng-85aff44e00e836eda618d4f1cf013bce38b3fd44.tar.bz2
nng-85aff44e00e836eda618d4f1cf013bce38b3fd44.zip
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.
Diffstat (limited to 'src/supplemental/http/http_server.c')
-rw-r--r--src/supplemental/http/http_server.c8
1 files changed, 3 insertions, 5 deletions
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. <info@staysail.tech>
+// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2018 QXSoftware <lh563566994@126.com>
// Copyright 2019 Devolutions <info@devolutions.net>
@@ -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++;