aboutsummaryrefslogtreecommitdiff
path: root/tests/wss.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-03 08:29:55 -0800
committerGarrett D'Amore <garrett@damore.org>2024-11-03 08:30:34 -0800
commit8249242a9325a27e57107d78bfa168e918cc4f7a (patch)
tree3fa7a7a0dd66c23684b731f6b2686e9b6ea7a574 /tests/wss.c
parenta5807e45b1badfb5d0cb4f697e1873a8ece59a30 (diff)
downloadnng-8249242a9325a27e57107d78bfa168e918cc4f7a.tar.gz
nng-8249242a9325a27e57107d78bfa168e918cc4f7a.tar.bz2
nng-8249242a9325a27e57107d78bfa168e918cc4f7a.zip
Remove untyped nng_pipe_get, support for untyped sockaddr set.
This is a step on the path to removing unsafe untyped option accesses.
Diffstat (limited to 'tests/wss.c')
-rw-r--r--tests/wss.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/tests/wss.c b/tests/wss.c
index 660ede3b..28b578fc 100644
--- a/tests/wss.c
+++ b/tests/wss.c
@@ -132,49 +132,30 @@ static int
check_props(nng_msg *msg)
{
nng_pipe p;
- size_t z;
nng_sockaddr la;
nng_sockaddr ra;
char *buf;
- size_t len;
p = nng_msg_get_pipe(msg);
So(nng_pipe_id(p) > 0);
- z = sizeof(nng_sockaddr);
- So(nng_pipe_get(p, NNG_OPT_LOCADDR, &la, &z) == 0);
- So(z == sizeof(la));
+ So(nng_pipe_get_addr(p, NNG_OPT_LOCADDR, &la) == 0);
So(validloopback(&la));
- z = sizeof(nng_sockaddr);
- So(nng_pipe_get(p, NNG_OPT_REMADDR, &ra, &z) == 0);
- So(z == sizeof(ra));
+ So(nng_pipe_get_addr(p, NNG_OPT_REMADDR, &ra) == 0);
So(validloopback(&ra));
// Request header
- z = 0;
buf = NULL;
- So(nng_pipe_get(p, NNG_OPT_WS_REQUEST_HEADERS, buf, &z) == NNG_EINVAL);
- So(z > 0);
- len = z;
- So((buf = nng_alloc(len)) != NULL);
- So(nng_pipe_get(p, NNG_OPT_WS_REQUEST_HEADERS, buf, &z) == 0);
+ So(nng_pipe_get_string(p, NNG_OPT_WS_REQUEST_HEADERS, &buf) == 0);
So(strstr(buf, "Sec-WebSocket-Key") != NULL);
- So(z == len);
- nng_free(buf, len);
+ nng_strfree(buf);
// Response header
- z = 0;
buf = NULL;
- So(nng_pipe_get(p, NNG_OPT_WS_RESPONSE_HEADERS, buf, &z) ==
- NNG_EINVAL);
- So(z > 0);
- len = z;
- So((buf = nng_alloc(len)) != NULL);
- So(nng_pipe_get(p, NNG_OPT_WS_RESPONSE_HEADERS, buf, &z) == 0);
+ So(nng_pipe_get_string(p, NNG_OPT_WS_RESPONSE_HEADERS, &buf) == 0);
So(strstr(buf, "Sec-WebSocket-Accept") != NULL);
- So(z == len);
- nng_free(buf, len);
+ nng_strfree(buf);
return (0);
}