From 57ce9f1035a7d265d0f8b0d907dc893d4fcbcaeb Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 8 Oct 2025 08:20:23 -0700 Subject: fixes #2133 websocket: new header iteration options --- include/nng/http.h | 2 +- include/nng/nng.h | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/nng/http.h b/include/nng/http.h index 18fc03ea..864dcc4f 100644 --- a/include/nng/http.h +++ b/include/nng/http.h @@ -203,7 +203,7 @@ NNG_DECL const char *nng_http_get_header(nng_http *, const char *); // the will receive its value. The caller starts the iteration by setting ptr // to NULL, and then the value must be preserved. The function returns NNG_OK // on success, or NNG_ENOENT if there are no more headers. -NNG_DECL nng_err nng_http_next_header( +NNG_DECL bool nng_http_next_header( nng_http *, const char **key, const char **val, void **ptr); // nng_http_get_body returns the body sent by the peer, if one is attached. diff --git a/include/nng/nng.h b/include/nng/nng.h index 4108f027..57283f00 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -772,6 +772,9 @@ NNG_DECL nng_err nng_pipe_get_int(nng_pipe, const char *, int *); NNG_DECL nng_err nng_pipe_get_ms(nng_pipe, const char *, nng_duration *); NNG_DECL nng_err nng_pipe_get_size(nng_pipe, const char *, size_t *); NNG_DECL nng_err nng_pipe_get_string(nng_pipe, const char *, const char **); +NNG_DECL nng_err nng_pipe_get_strdup(nng_pipe, const char *, char **); +NNG_DECL nng_err nng_pipe_get_strcpy(nng_pipe, const char *, char *, size_t); +NNG_DECL nng_err nng_pipe_get_strlen(nng_pipe, const char *, size_t *); NNG_DECL nng_err nng_pipe_get_addr(nng_pipe, const char *, nng_sockaddr *); NNG_DECL nng_err nng_pipe_peer_cert(nng_pipe, nng_tls_cert **); @@ -893,14 +896,10 @@ NNG_DECL nng_listener nng_pipe_listener(nng_pipe); // headers from the peer on a pipe. #define NNG_OPT_WS_HEADER "ws:header:" -// NNG_OPT_WS_HEADER_KEY is also a prefix, but the value it contains -// is the name (key) of the header at the index referenced. This -// allows successive iteration through headers. -#define NNG_OPT_WS_HEADER_KEY "ws:header_k:" - -// NNG_OPT_WS_HEADER_VAL is also a prefix, but the value it contains -// is the value of the header at the index referenced. -#define NNG_OPT_WS_HEADER_VAL "ws:header_v:" +#define NNG_OPT_WS_HEADER_NEXT "ws:hdr-next" +#define NNG_OPT_WS_HEADER_RESET "ws:hdr-reset" +#define NNG_OPT_WS_HEADER_KEY "ws:hdr-key" +#define NNG_OPT_WS_HEADER_VALUE "ws:hdr-val" // NNG_OPT_WS_REQUEST_URI is used to obtain the URI sent by the client. // This can be useful when a handler supports an entire directory tree. -- cgit v1.2.3-70-g09d2