summaryrefslogtreecommitdiff
path: root/tests/ws.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ws.c')
-rw-r--r--tests/ws.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/tests/ws.c b/tests/ws.c
index 32175e9c..6db790f2 100644
--- a/tests/ws.c
+++ b/tests/ws.c
@@ -34,9 +34,7 @@ check_props_v4(nng_msg *msg)
p = nng_msg_get_pipe(msg);
So(p > 0);
- z = sizeof(nng_sockaddr);
- So(nng_pipe_getopt(p, NNG_OPT_LOCADDR, &la, &z) == 0);
- So(z == sizeof(la));
+ So(nng_pipe_getopt_sockaddr(p, NNG_OPT_LOCADDR, &la) == 0);
So(la.s_family == NNG_AF_INET);
So(la.s_in.sa_port == htons(trantest_port - 1));
So(la.s_in.sa_port != 0);
@@ -52,26 +50,34 @@ check_props_v4(nng_msg *msg)
// Request Header
z = 0;
buf = NULL;
- So(nng_pipe_getopt(p, NNG_OPT_WS_REQUEST_HEADERS, buf, &z) == 0);
+ So(nng_pipe_getopt(p, NNG_OPT_WS_REQUEST_HEADERS, buf, &z) ==
+ NNG_EINVAL);
So(z > 0);
len = z;
- So((buf = nni_alloc(len)) != NULL);
+ So((buf = nng_alloc(len)) != NULL);
So(nng_pipe_getopt(p, NNG_OPT_WS_REQUEST_HEADERS, buf, &z) == 0);
So(strstr(buf, "Sec-WebSocket-Key") != NULL);
So(z == len);
- nni_free(buf, len);
+ nng_free(buf, len);
+ So(nng_pipe_getopt_string(p, NNG_OPT_WS_REQUEST_HEADERS, &buf) == 0);
+ So(strlen(buf) == len - 1);
+ nng_strfree(buf);
// Response Header
z = 0;
buf = NULL;
- So(nng_pipe_getopt(p, NNG_OPT_WS_RESPONSE_HEADERS, buf, &z) == 0);
+ So(nng_pipe_getopt(p, NNG_OPT_WS_RESPONSE_HEADERS, buf, &z) ==
+ NNG_EINVAL);
So(z > 0);
len = z;
- So((buf = nni_alloc(len)) != NULL);
+ So((buf = nng_alloc(len)) != NULL);
So(nng_pipe_getopt(p, NNG_OPT_WS_RESPONSE_HEADERS, buf, &z) == 0);
So(strstr(buf, "Sec-WebSocket-Accept") != NULL);
So(z == len);
- nni_free(buf, len);
+ nng_free(buf, len);
+ So(nng_pipe_getopt_string(p, NNG_OPT_WS_RESPONSE_HEADERS, &buf) == 0);
+ So(strlen(buf) == len - 1);
+ nng_strfree(buf);
return (0);
}