diff options
Diffstat (limited to 'src/supplemental')
| -rw-r--r-- | src/supplemental/http/http_api.h | 2 | ||||
| -rw-r--r-- | src/supplemental/http/http_public.c | 5 | ||||
| -rw-r--r-- | src/supplemental/http/http_server.c | 16 | ||||
| -rw-r--r-- | src/supplemental/http/http_server_test.c | 9 |
4 files changed, 12 insertions, 20 deletions
diff --git a/src/supplemental/http/http_api.h b/src/supplemental/http/http_api.h index d759e27b..0748b1f9 100644 --- a/src/supplemental/http/http_api.h +++ b/src/supplemental/http/http_api.h @@ -332,7 +332,7 @@ extern void nni_http_handler_set_host(nni_http_handler *, const char *); // is obligated to inspect the method. (Note: the passed method must be // in upper case and should come from a statically allocated string; the // server does not make its own copy.) -extern int nni_http_handler_set_method(nni_http_handler *, const char *); +extern void nni_http_handler_set_method(nni_http_handler *, const char *); // nni_http_handler_set_data sets an opaque data element on the handler, // which will be available to the callback via nni_http_handler_get_data. diff --git a/src/supplemental/http/http_public.c b/src/supplemental/http/http_public.c index a60743fd..58550a3f 100644 --- a/src/supplemental/http/http_public.c +++ b/src/supplemental/http/http_public.c @@ -583,15 +583,14 @@ nng_http_handler_alloc_static(nng_http_handler **hp, const char *uri, #endif } -int +void nng_http_handler_set_method(nng_http_handler *h, const char *meth) { #ifdef NNG_SUPP_HTTP - return (nni_http_handler_set_method(h, meth)); + nni_http_handler_set_method(h, meth); #else NNI_ARG_UNUSED(h); NNI_ARG_UNUSED(meth); - return (NNG_ENOTSUP); #endif } 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); diff --git a/src/supplemental/http/http_server_test.c b/src/supplemental/http/http_server_test.c index f29fa52b..e1d13ad2 100644 --- a/src/supplemental/http/http_server_test.c +++ b/src/supplemental/http/http_server_test.c @@ -346,10 +346,9 @@ test_server_method_too_long(void) NUTS_PASS(nng_http_handler_alloc_static( &h, "/home.html", doc1, strlen(doc1), "text/html")); - NUTS_FAIL(nng_http_handler_set_method(h, - "THISMETHODISFARFARTOOLONGTOBEVALIDASAMETHODASITISLONGER" - "THANTHIRTYTWOBYTES"), - NNG_EINVAL); + nng_http_handler_set_method(h, + "THISMETHODISFARFARTOOLONGTOBEVALIDASAMETHODASITISLONGER" + "THANTHIRTYTWOBYTES"); } void @@ -393,7 +392,7 @@ test_server_post_handler(void) void *data; NUTS_PASS(nng_http_handler_alloc(&h, "/post", httpecho)); - NUTS_PASS(nng_http_handler_set_method(h, "POST")); + nng_http_handler_set_method(h, "POST"); server_setup(&st, h); |
