diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-01-05 16:46:03 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-01-06 13:58:07 -0800 |
| commit | f42d0c6ef956d119e8762a3ecda37886fa055637 (patch) | |
| tree | 1744a559dafafdfecd906608888bf0cb9f6c4d10 /src/supplemental/http/http_server_test.c | |
| parent | bce6a79fc55852032e9d653b099a121353aaa238 (diff) | |
| download | nng-f42d0c6ef956d119e8762a3ecda37886fa055637.tar.gz nng-f42d0c6ef956d119e8762a3ecda37886fa055637.tar.bz2 nng-f42d0c6ef956d119e8762a3ecda37886fa055637.zip | |
http: server callback API simplified
This simplified API lets callbacks obtain the response from the
connection objection directly, and does not require the aio to carry
it as a parameter. Further, the request and response are both
stored inline in the connection, reducing allocations.
This is at present only for the server; the client will get a similar
set of changes.
Diffstat (limited to 'src/supplemental/http/http_server_test.c')
| -rw-r--r-- | src/supplemental/http/http_server_test.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/supplemental/http/http_server_test.c b/src/supplemental/http/http_server_test.c index 37c45f14..91411499 100644 --- a/src/supplemental/http/http_server_test.c +++ b/src/supplemental/http/http_server_test.c @@ -10,6 +10,7 @@ // // Basic HTTP server tests. +#include "core/defs.h" #include <nng/nng.h> #include <nng/supplemental/http/http.h> @@ -141,21 +142,20 @@ fail: } static void -httpecho(nng_aio *aio) +httpecho(nng_http_conn *conn, void *arg, nng_aio *aio) { - nng_http_req *req = nng_aio_get_input(aio, 0); - nng_http_res *res; + nng_http_req *req = nng_http_conn_req(conn); + nng_http_res *res = nng_http_conn_res(conn); int rv; void *body; size_t len; + NNI_ARG_UNUSED(arg); nng_http_req_get_data(req, &body, &len); - if (((rv = nng_http_res_alloc(&res)) != 0) || - ((rv = nng_http_res_copy_data(res, body, len)) != 0) || + if (((rv = nng_http_res_copy_data(res, body, len)) != 0) || ((rv = nng_http_res_set_header( res, "Content-type", "text/plain")) != 0)) { - nng_http_res_free(res); nng_aio_finish(aio, rv); return; } |
