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_api.h | |
| 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_api.h')
| -rw-r--r-- | src/supplemental/http/http_api.h | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/supplemental/http/http_api.h b/src/supplemental/http/http_api.h index a6dfa6ca..1630198d 100644 --- a/src/supplemental/http/http_api.h +++ b/src/supplemental/http/http_api.h @@ -114,12 +114,13 @@ extern int nni_http_conn_getopt( extern int nni_http_req_alloc(nni_http_req **, const nng_url *); extern int nni_http_res_alloc(nni_http_res **); extern int nni_http_res_alloc_error(nni_http_res **, uint16_t); +extern int nni_http_res_set_error(nni_http_res *, uint16_t); extern void nni_http_req_free(nni_http_req *); extern void nni_http_res_free(nni_http_res *); extern void nni_http_write_req(nni_http_conn *, nni_http_req *, nni_aio *); -extern void nni_http_write_res(nni_http_conn *, nni_http_res *, nni_aio *); -extern void nni_http_read_req(nni_http_conn *, nni_http_req *, nni_aio *); extern void nni_http_read_res(nni_http_conn *, nni_http_res *, nni_aio *); +extern void nni_http_read_req(nni_http_conn *, nni_aio *); +extern void nni_http_write_res(nni_http_conn *, nni_aio *); extern const char *nni_http_req_get_header(const nni_http_req *, const char *); extern const char *nni_http_res_get_header(const nni_http_res *, const char *); @@ -258,15 +259,8 @@ extern int nni_http_hijack(nni_http_conn *); // Note that methods which modify a handler cannot be called while the handler // is registered with the server, and that a handler can only be registered // once per server. -// -// The callback function will receive the following arguments (via -// nng_aio_get_input(): nni_http_request *, nni_http_handler *, and -// nni_http_conn_t *. The first is a request object, for convenience. -// The second is the handler, from which the callback can obtain any other -// data it has set. The final is the http context, from which its possible -// to hijack the session. extern int nni_http_handler_init( - nni_http_handler **, const char *, void (*)(nni_aio *)); + nni_http_handler **, const char *, nng_http_handler_func); // nni_http_handler_init_file creates a handler with a function to serve // up a file named in the last argument. @@ -395,4 +389,7 @@ extern void nni_http_transact( // upper layer scheme. extern const char *nni_http_stream_scheme(const char *); +// Private method used for the server. +extern bool nni_http_conn_res_sent(nni_http_conn *conn); + #endif // NNG_SUPPLEMENTAL_HTTP_HTTP_API_H |
