From d1bd64c8251171ac8e1d4e71ab8726c2a64fd55a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 5 Oct 2025 08:25:50 -0700 Subject: Various header file fixes... also fix compilation errors when HTTP is disabled. Also, some instances nni_aio are changed to nng_aio. We think we want to harmonize some of these types going forward as it will reduce the need to include headers hopefully letting us get away with just "defs.h" in more places. --- src/supplemental/http/http_api.h | 31 +++++++++++++++---------------- src/supplemental/http/http_chunk.c | 2 +- src/supplemental/http/http_client.c | 2 +- src/supplemental/http/http_conn.c | 14 +++++++------- src/supplemental/http/http_msg.c | 6 +++--- src/supplemental/http/http_msg.h | 4 ++-- src/supplemental/http/http_public.c | 20 +++++++++----------- src/supplemental/http/http_schemes.c | 6 +++--- src/supplemental/http/http_server.c | 2 +- src/supplemental/http/http_server_test.c | 4 ++-- 10 files changed, 44 insertions(+), 47 deletions(-) (limited to 'src/supplemental/http') diff --git a/src/supplemental/http/http_api.h b/src/supplemental/http/http_api.h index 61c6e45f..a8f648dc 100644 --- a/src/supplemental/http/http_api.h +++ b/src/supplemental/http/http_api.h @@ -12,10 +12,9 @@ #ifndef NNG_SUPPLEMENTAL_HTTP_HTTP_API_H #define NNG_SUPPLEMENTAL_HTTP_HTTP_API_H -#include "core/nng_impl.h" -#include "nng/http.h" - +#include "../../core/defs.h" #include "http_msg.h" +#include "nng/http.h" // This represents the "internal" HTTP API. It should not be used // or exposed to applications directly. @@ -68,7 +67,7 @@ extern nng_err nni_http_chunks_parse( nni_http_chunks *, void *, size_t, size_t *); extern void nni_http_read_chunks( - nni_http_conn *, nni_http_chunks *, nni_aio *); + nni_http_conn *, nni_http_chunks *, nng_aio *); extern nni_http_req *nni_http_conn_req(nni_http_conn *); extern nni_http_res *nni_http_conn_res(nni_http_conn *); @@ -106,21 +105,21 @@ extern int nni_http_conn_getopt( // Note that the iovs of the aio's are clobbered by these methods -- callers // must not use them for any other purpose. -extern void nni_http_write_req(nni_http_conn *, nni_aio *); -extern void nni_http_read_res(nni_http_conn *, 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 void nni_http_read_discard(nni_http_conn *, size_t, nni_aio *); +extern void nni_http_write_req(nni_http_conn *, nng_aio *); +extern void nni_http_read_res(nni_http_conn *, nng_aio *); +extern void nni_http_read_req(nni_http_conn *, nng_aio *); +extern void nni_http_write_res(nni_http_conn *, nng_aio *); +extern void nni_http_read_discard(nni_http_conn *, size_t, nng_aio *); extern nng_err nni_http_req_alloc_data(nni_http_req *, size_t); extern nng_err nni_http_res_alloc_data(nni_http_res *, size_t); extern bool nni_http_is_error(nng_http *); -extern void nni_http_read(nni_http_conn *, nni_aio *); -extern void nni_http_read_full(nni_http_conn *, nni_aio *); -extern void nni_http_write(nni_http_conn *, nni_aio *); -extern void nni_http_write_full(nni_http_conn *, nni_aio *); +extern void nni_http_read(nni_http_conn *, nng_aio *); +extern void nni_http_read_full(nni_http_conn *, nng_aio *); +extern void nni_http_write(nni_http_conn *, nng_aio *); +extern void nni_http_write_full(nni_http_conn *, nng_aio *); extern nng_err nni_http_add_header(nng_http *, const char *, const char *); extern nng_err nni_http_set_header(nng_http *, const char *, const char *); @@ -324,7 +323,7 @@ extern int nni_http_client_set( extern int nni_http_client_get( nni_http_client *, const char *, void *, size_t *, nni_type); -extern void nni_http_client_connect(nni_http_client *, nni_aio *); +extern void nni_http_client_connect(nni_http_client *, nng_aio *); // nni_http_transact_conn is used to perform a round-trip exchange (i.e. a // single HTTP transaction). It will not automatically close the connection, @@ -333,14 +332,14 @@ extern void nni_http_client_connect(nni_http_client *, nni_aio *); // Note that this will fail with NNG_ENOTSUP if the server attempts to reply // with a chunked transfer encoding. The request and response used are the // ones associated with the connection. -extern void nni_http_transact_conn(nni_http_conn *, nni_aio *); +extern void nni_http_transact_conn(nni_http_conn *, nng_aio *); // nni_http_transact is used to execute a single transaction to a server. // The connection is opened, and will be closed when the transaction is // complete. Note that this will fail with NNG_ENOTSUP if the server attempts // to reply with a chunked transfer encoding. extern void nni_http_transact( - nni_http_client *, nni_http_req *, nni_http_res *, nni_aio *); + nni_http_client *, nni_http_req *, nni_http_res *, nng_aio *); // nni_http_stream_scheme returns the underlying stream scheme for a given // upper layer scheme. diff --git a/src/supplemental/http/http_chunk.c b/src/supplemental/http/http_chunk.c index 1d4335db..99f29800 100644 --- a/src/supplemental/http/http_chunk.c +++ b/src/supplemental/http/http_chunk.c @@ -12,7 +12,7 @@ #include #include -#include "core/nng_impl.h" +#include "../../core/defs.h" #include "http_api.h" diff --git a/src/supplemental/http/http_client.c b/src/supplemental/http/http_client.c index 06215ca0..5cacb39c 100644 --- a/src/supplemental/http/http_client.c +++ b/src/supplemental/http/http_client.c @@ -14,7 +14,7 @@ #include #include -#include "core/nng_impl.h" +#include "../../core/nng_impl.h" #include "http_api.h" #include "http_msg.h" diff --git a/src/supplemental/http/http_conn.c b/src/supplemental/http/http_conn.c index 5baa3136..21087474 100644 --- a/src/supplemental/http/http_conn.c +++ b/src/supplemental/http/http_conn.c @@ -15,10 +15,10 @@ #include #include -#include "core/list.h" -#include "core/nng_impl.h" +#include "../../core/list.h" +#include "../../core/nng_impl.h" +#include "../../supplemental/tls/tls_api.h" #include "nng/http.h" -#include "supplemental/tls/tls_api.h" #include "http_api.h" #include "http_msg.h" @@ -52,10 +52,10 @@ struct nng_http_conn { nni_list rdq; // high level http read requests nni_list wrq; // high level http write requests - nni_aio *rd_uaio; // user aio for read - nni_aio *wr_uaio; // user aio for write - nni_aio rd_aio; // bottom half read operations - nni_aio wr_aio; // bottom half write operations + nng_aio *rd_uaio; // user aio for read + nng_aio *wr_uaio; // user aio for write + nng_aio rd_aio; // bottom half read operations + nng_aio wr_aio; // bottom half write operations nni_mtx mtx; diff --git a/src/supplemental/http/http_msg.c b/src/supplemental/http/http_msg.c index 09470e31..e6b2a0ab 100644 --- a/src/supplemental/http/http_msg.c +++ b/src/supplemental/http/http_msg.c @@ -14,9 +14,9 @@ #include #include -#include "core/list.h" -#include "core/nng_impl.h" -#include "core/url.h" +#include "../../core/list.h" +#include "../../core/nng_impl.h" +#include "../../core/url.h" #include "http_api.h" #include "http_msg.h" #include "nng/http.h" diff --git a/src/supplemental/http/http_msg.h b/src/supplemental/http/http_msg.h index 4b4e03a6..02e0db07 100644 --- a/src/supplemental/http/http_msg.h +++ b/src/supplemental/http/http_msg.h @@ -11,8 +11,8 @@ #ifndef NNG_SUPPLEMENTAL_HTTP_HTTP_MSG #define NNG_SUPPLEMENTAL_HTTP_HTTP_MSG -#include "core/defs.h" -#include "core/list.h" +#include "../../core/defs.h" +#include "../../core/list.h" // Note that as we parse headers, the rule is that if a header is already // present, then we can append it to the existing header, separated by diff --git a/src/supplemental/http/http_public.c b/src/supplemental/http/http_public.c index 42b7a1ab..9c8ded2d 100644 --- a/src/supplemental/http/http_public.c +++ b/src/supplemental/http/http_public.c @@ -8,7 +8,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "core/nng_impl.h" +#include "../../core/nng_impl.h" #include "http_api.h" #include "nng/http.h" @@ -73,7 +73,7 @@ nng_http_set_body(nng_http *conn, void *data, size_t sz) NNI_ARG_UNUSED(conn); NNI_ARG_UNUSED(data); NNI_ARG_UNUSED(sz); - return (NNG_ENOTSUP); + return; #endif } @@ -108,7 +108,7 @@ nng_http_get_uri(nng_http *conn) #ifdef NNG_SUPP_HTTP return (nni_http_get_uri(conn)); #else - NNI_ARG_UNUSED(req); + NNI_ARG_UNUSED(conn); return (NULL); #endif } @@ -132,7 +132,7 @@ nng_http_get_version(nng_http *conn) #ifdef NNG_SUPP_HTTP return (nni_http_get_version(conn)); #else - NNI_ARG_UNUSED(res); + NNI_ARG_UNUSED(conn); return (NULL); #endif } @@ -143,7 +143,7 @@ nng_http_set_status(nng_http *conn, nng_http_status status, const char *reason) #ifdef NNG_SUPP_HTTP nni_http_set_status(conn, status, reason); #else - NNI_ARG_UNUSED(res); + NNI_ARG_UNUSED(conn); NNI_ARG_UNUSED(status); NNI_ARG_UNUSED(reason); #endif @@ -155,8 +155,7 @@ nng_http_get_status(nng_http *conn) #ifdef NNG_SUPP_HTTP return (nni_http_get_status(conn)); #else - NNI_ARG_UNUSED(res); - NNI_ARG_UNUSED(status); + NNI_ARG_UNUSED(conn); return (0); #endif } @@ -167,8 +166,7 @@ nng_http_get_reason(nng_http *conn) #ifdef NNG_SUPP_HTTP return (nni_http_get_reason(conn)); #else - NNI_ARG_UNUSED(res); - NNI_ARG_UNUSED(status); + NNI_ARG_UNUSED(conn); return (0); #endif } @@ -560,7 +558,7 @@ nng_http_server_error(nng_http_server *srv, nng_http *conn) return (nni_http_server_error(srv, conn)); #else NNI_ARG_UNUSED(srv); - NNI_ARG_UNUSED(res); + NNI_ARG_UNUSED(conn); return (NNG_ENOTSUP); #endif } @@ -650,6 +648,6 @@ nng_http_reset(nng_http *conn) #ifdef NNG_SUPP_HTTP nni_http_conn_reset(conn); #else - NNI_ARG_UNUSED(req); + NNI_ARG_UNUSED(conn); #endif } diff --git a/src/supplemental/http/http_schemes.c b/src/supplemental/http/http_schemes.c index df8b9208..1e56cdc5 100644 --- a/src/supplemental/http/http_schemes.c +++ b/src/supplemental/http/http_schemes.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. +// Copyright 2025 Staysail Systems, Inc. // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -11,7 +11,7 @@ #include #include -#include "core/nng_impl.h" +#include "../../core/nng_impl.h" #include "http_api.h" @@ -82,4 +82,4 @@ nni_http_stream_scheme(const char *upper) } } return (NULL); -} \ No newline at end of file +} diff --git a/src/supplemental/http/http_server.c b/src/supplemental/http/http_server.c index fc7a3075..d1e8a5e7 100644 --- a/src/supplemental/http/http_server.c +++ b/src/supplemental/http/http_server.c @@ -17,7 +17,7 @@ #include #include -#include "core/nng_impl.h" +#include "../../core/nng_impl.h" #include "http_api.h" #include "http_msg.h" diff --git a/src/supplemental/http/http_server_test.c b/src/supplemental/http/http_server_test.c index fdc38950..ed63e136 100644 --- a/src/supplemental/http/http_server_test.c +++ b/src/supplemental/http/http_server_test.c @@ -10,12 +10,12 @@ // // Basic HTTP server tests. -#include "core/defs.h" +#include "../../core/defs.h" #include #include #include -#include +#include "../../testing/nuts.h" const char *doc1 = "Someone is home!"; const char *doc2 = "This is a text file."; -- cgit v1.2.3-70-g09d2