diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-12-27 16:32:33 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-12-27 16:32:33 -0800 |
| commit | 5ff3d3d3ab82be4b2171e06f1def9cdddaef4115 (patch) | |
| tree | 028fff3d0dbcbec741406541931029c106bae465 /tests/ws.c | |
| parent | eb1f8db4ed87867f0f08afba79253e3981db9c88 (diff) | |
| download | nng-5ff3d3d3ab82be4b2171e06f1def9cdddaef4115.tar.gz nng-5ff3d3d3ab82be4b2171e06f1def9cdddaef4115.tar.bz2 nng-5ff3d3d3ab82be4b2171e06f1def9cdddaef4115.zip | |
fixes #180 add websocket header properties
Diffstat (limited to 'tests/ws.c')
| -rw-r--r-- | tests/ws.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -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); } |
