diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-03-20 18:38:54 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-03-20 18:42:23 -0700 |
| commit | 6df40cb6eea9a4220d61c4c927ce5a857a12a338 (patch) | |
| tree | ac4b7ecbcb41a456eb4d0429fc180047656371ba /tests/ws.c | |
| parent | 9ca901c1b70b17d851426483d9f54611cfa8e395 (diff) | |
| download | nng-6df40cb6eea9a4220d61c4c927ce5a857a12a338.tar.gz nng-6df40cb6eea9a4220d61c4c927ce5a857a12a338.tar.bz2 nng-6df40cb6eea9a4220d61c4c927ce5a857a12a338.zip | |
fixes #301 String option handling for getopt
Diffstat (limited to 'tests/ws.c')
| -rw-r--r-- | tests/ws.c | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -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); } |
