aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2020-10-26 00:09:23 -0700
committerGarrett D'Amore <garrett@damore.org>2020-10-26 21:17:06 -0700
commitcaefd5cb745e2d1e8454dcda6753262f95812de4 (patch)
treef5d4b081670b19a8b979ae4a5eae23b91daa1126 /include
parent4e7205cedb5f631d0fbbe72dbf89b5b9205a6260 (diff)
downloadnng-caefd5cb745e2d1e8454dcda6753262f95812de4.tar.gz
nng-caefd5cb745e2d1e8454dcda6753262f95812de4.tar.bz2
nng-caefd5cb745e2d1e8454dcda6753262f95812de4.zip
fixes #914 websocket stream mode should support TEXT
This adds new options, NNG_OPT_WS_SEND_TEXT and NNG_OPT_WS_RECV_TEXT that permit communication with WebSocket peers that insist on using TEXT frames (stream mode only). The support is limited, as NNG does no validation of the frame contents to check for UTF-8 compliance.
Diffstat (limited to 'include')
-rw-r--r--include/nng/nng.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/include/nng/nng.h b/include/nng/nng.h
index 3e70bc8f..56b2f029 100644
--- a/include/nng/nng.h
+++ b/include/nng/nng.h
@@ -932,11 +932,32 @@ NNG_DECL nng_listener nng_pipe_listener(nng_pipe);
// to send more data than this in a single message, it will be dropped.
#define NNG_OPT_WS_RECVMAXFRAME "ws:rxframe-max"
-// NNG_OPT_WS_PROTOCOL is the "websocket subprotocol" -- it's a string.
+// NNG_OPT_WS_PROTOCOL is the "websocket sub-protocol" -- it's a string.
// This is also known as the Sec-WebSocket-Protocol header. It is treated
// specially. This is part of the websocket handshake.
#define NNG_OPT_WS_PROTOCOL "ws:protocol"
+// NNG_OPT_WS_SEND_TEXT is a boolean used to tell the WS stream
+// transport to send text messages. This is not supported for the
+// core WebSocket transport, but when using streams it might be useful
+// to speak with 3rd party WebSocket applications. This mode should
+// not be used unless absolutely required. No validation of the message
+// contents is performed by NNG; applications are expected to honor
+// the requirement to send only valid UTF-8. (Compliant applications
+// will close the socket if they see this message type with invalid UTF-8.)
+#define NNG_OPT_WS_SEND_TEXT "ws:send-text"
+
+// NNG_OPT_WS_RECV_TEXT is a boolean that enables NNG to receive
+// TEXT frames. This is only useful for stream mode applications --
+// SP protocol requires the use of binary frames. Note also that
+// NNG does not validate the message contents for valid UTF-8; this
+// means it will not be conformant with RFC-6455 on it's own. Applications
+// that need this should check the message contents themselves, and
+// close the connection if invalid UTF-8 is received. This option
+// should not be used unless required to communication with 3rd party
+// peers that cannot be coerced into sending binary frames.
+#define NNG_OPT_WS_RECV_TEXT "ws:recv-text"
+
// XXX: TBD: priorities, ipv4only
// Statistics. These are for informational purposes only, and subject