aboutsummaryrefslogtreecommitdiff
path: root/tests/wssfile.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-03-20 18:38:54 -0700
committerGarrett D'Amore <garrett@damore.org>2018-03-20 18:42:23 -0700
commit6df40cb6eea9a4220d61c4c927ce5a857a12a338 (patch)
treeac4b7ecbcb41a456eb4d0429fc180047656371ba /tests/wssfile.c
parent9ca901c1b70b17d851426483d9f54611cfa8e395 (diff)
downloadnng-6df40cb6eea9a4220d61c4c927ce5a857a12a338.tar.gz
nng-6df40cb6eea9a4220d61c4c927ce5a857a12a338.tar.bz2
nng-6df40cb6eea9a4220d61c4c927ce5a857a12a338.zip
fixes #301 String option handling for getopt
Diffstat (limited to 'tests/wssfile.c')
-rw-r--r--tests/wssfile.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/wssfile.c b/tests/wssfile.c
index 48736117..41fb8f9f 100644
--- a/tests/wssfile.c
+++ b/tests/wssfile.c
@@ -162,26 +162,34 @@ check_props(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);
}