From 5ff3d3d3ab82be4b2171e06f1def9cdddaef4115 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 27 Dec 2017 16:32:33 -0800 Subject: fixes #180 add websocket header properties --- tests/ws.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/ws.c') diff --git a/tests/ws.c b/tests/ws.c index eff95ab3..71836390 100644 --- a/tests/ws.c +++ b/tests/ws.c @@ -11,6 +11,7 @@ #include "convey.h" #include "nng.h" #include "protocol/pair1/pair.h" +#include "transport/ws/websocket.h" #include "trantest.h" #include "stubs.h" @@ -48,6 +49,41 @@ check_props_v4(nng_msg *msg, nng_listener l, nng_dialer d) So(ra.s_un.s_in.sa_port != 0); So(ra.s_un.s_in.sa_addr == htonl(0x7f000001)); }); + + Convey("Request header property works", { + char * buf; + size_t len; + z = 0; + buf = NULL; + So(nng_pipe_getopt(p, NNG_OPT_WS_REQUEST_HEADERS, buf, &z) == + 0); + So(z > 0); + len = z; + So((buf = nni_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); + }); + + Convey("Response header property works", { + char * buf; + size_t len; + z = 0; + buf = NULL; + So(nng_pipe_getopt(p, NNG_OPT_WS_RESPONSE_HEADERS, buf, &z) == + 0); + So(z > 0); + len = z; + So((buf = nni_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); + }); + return (0); } -- cgit v1.2.3-70-g09d2