From 2662596f105fc98ae1d2aa3b6137261bb351a8df Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 22 Dec 2024 12:27:49 -0800 Subject: HTTP: nng_http_handler_set_method no longer fails --- src/supplemental/http/http_server.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 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 e9c8bea3..6a594158 100644 --- a/src/supplemental/http/http_server.c +++ b/src/supplemental/http/http_server.c @@ -236,20 +236,14 @@ nni_http_handler_set_host(nni_http_handler *h, const char *host) (void) snprintf(h->host, sizeof(h->host), "%s", host); } -int +void nni_http_handler_set_method(nni_http_handler *h, const char *method) { - if (nni_atomic_get_bool(&h->busy) != 0) { - return (NNG_EBUSY); - } + NNI_ASSERT(!nni_atomic_get_bool(&h->busy)); if (method == NULL) { method = ""; } - if (strlen(method) >= sizeof(h->method)) { - return (NNG_EINVAL); - } (void) snprintf(h->method, sizeof(h->method), "%s", method); - return (0); } static nni_list http_servers = @@ -1757,9 +1751,9 @@ nni_http_handler_init_redirect(nni_http_handler **hpp, const char *uri, return (rv); } - if (((rv = nni_http_handler_set_method(h, NULL)) != 0) || - ((rv = nni_http_handler_set_data(h, hr, http_redirect_free)) != - 0)) { + nni_http_handler_set_method(h, NULL); + + if ((rv = nni_http_handler_set_data(h, hr, http_redirect_free)) != 0) { http_redirect_free(hr); nni_http_handler_fini(h); return (rv); -- cgit v1.2.3-70-g09d2