aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/http/http_conn.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2025-01-05 11:47:03 -0800
committerGarrett D'Amore <garrett@damore.org>2025-01-05 22:39:17 -0800
commitbce6a79fc55852032e9d653b099a121353aaa238 (patch)
tree6e6aa44e73ea7e671a50103539c55443df8c4dc2 /src/supplemental/http/http_conn.c
parentd31844817a5b304a894c5b963cd52aeb9e47c627 (diff)
downloadnng-bce6a79fc55852032e9d653b099a121353aaa238.tar.gz
nng-bce6a79fc55852032e9d653b099a121353aaa238.tar.bz2
nng-bce6a79fc55852032e9d653b099a121353aaa238.zip
http: changing transaction API to inline req and res structures
This is a step towards simplifying this API and ultimately simplifying the HTTP callback API used for the server side.
Diffstat (limited to 'src/supplemental/http/http_conn.c')
-rw-r--r--src/supplemental/http/http_conn.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/supplemental/http/http_conn.c b/src/supplemental/http/http_conn.c
index 44860fe6..912f2cc9 100644
--- a/src/supplemental/http/http_conn.c
+++ b/src/supplemental/http/http_conn.c
@@ -17,6 +17,7 @@
#include "supplemental/tls/tls_api.h"
#include "http_api.h"
+#include "http_msg.h"
// We insist that individual headers fit in 8K.
// If you need more than that, you need something we can't do.
@@ -52,6 +53,9 @@ struct nng_http_conn {
nni_mtx mtx;
+ nng_http_req req;
+ nng_http_res res;
+
enum read_flavor rd_flavor;
uint8_t *rd_buf;
size_t rd_get;
@@ -62,6 +66,18 @@ struct nng_http_conn {
enum write_flavor wr_flavor;
};
+nng_http_req *
+nni_http_conn_req(nng_http_conn *conn)
+{
+ return (&conn->req);
+}
+
+nng_http_res *
+nni_http_conn_res(nng_http_conn *conn)
+{
+ return (&conn->res);
+}
+
void
nni_http_conn_set_ctx(nni_http_conn *conn, void *ctx)
{
@@ -651,6 +667,8 @@ nni_http_conn_fini(nni_http_conn *conn)
nni_aio_fini(&conn->wr_aio);
nni_aio_fini(&conn->rd_aio);
+ nni_http_req_reset(&conn->req);
+ nni_http_res_reset(&conn->res);
nni_free(conn->rd_buf, conn->rd_bufsz);
nni_mtx_fini(&conn->mtx);
NNI_FREE_STRUCT(conn);
@@ -667,6 +685,8 @@ http_init(nni_http_conn **connp, nng_stream *data)
nni_mtx_init(&conn->mtx);
nni_aio_list_init(&conn->rdq);
nni_aio_list_init(&conn->wrq);
+ nni_http_req_init(&conn->req);
+ nni_http_res_init(&conn->res);
if ((conn->rd_buf = nni_alloc(HTTP_BUFSIZE)) == NULL) {
nni_http_conn_fini(conn);