mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
role ws: allow zero length PONG
This commit is contained in:
parent
6c1fbbf4cb
commit
a4b44320c0
2 changed files with 12 additions and 10 deletions
|
@ -488,9 +488,6 @@ ping_drop:
|
|||
ebuf.token = &wsi->ws->rx_ubuf[LWS_PRE];
|
||||
ebuf.len = wsi->ws->rx_ubuf_head;
|
||||
|
||||
if (wsi->ws->opcode == LWSWSOPC_PONG && !ebuf.len)
|
||||
goto already_done;
|
||||
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
drain_extension:
|
||||
lwsl_ext("%s: passing %d to ext\n", __func__, ebuf.len);
|
||||
|
@ -504,14 +501,12 @@ drain_extension:
|
|||
#endif
|
||||
lwsl_debug("post inflate ebuf len %d\n", ebuf.len);
|
||||
|
||||
if (
|
||||
#if !defined(LWS_WITHOUT_EXTENSIONS)
|
||||
rx_draining_ext &&
|
||||
#endif
|
||||
!ebuf.len) {
|
||||
if (rx_draining_ext && !ebuf.len) {
|
||||
lwsl_debug(" --- ending drain on 0 read result\n");
|
||||
goto already_done;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (wsi->ws->check_utf8 && !wsi->ws->defeat_check_utf8) {
|
||||
if (lws_check_utf8(&wsi->ws->utf8,
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
static struct lws_context *context;
|
||||
static struct lws *client_wsi;
|
||||
static int interrupted;
|
||||
static int interrupted, zero_length_ping;
|
||||
|
||||
struct pss {
|
||||
int send_a_ping;
|
||||
|
@ -77,8 +77,11 @@ callback_minimal_broker(struct lws *wsi, enum lws_callback_reasons reason,
|
|||
int m;
|
||||
|
||||
pss->send_a_ping = 0;
|
||||
n = lws_snprintf((char *)ping + LWS_PRE, 125,
|
||||
"ping body!");
|
||||
n = 0;
|
||||
if (!zero_length_ping)
|
||||
n = lws_snprintf((char *)ping + LWS_PRE, 125,
|
||||
"ping body!");
|
||||
|
||||
lwsl_user("Sending PING %d...\n", n);
|
||||
|
||||
m = lws_write(wsi, ping + LWS_PRE, n, LWS_WRITE_PING);
|
||||
|
@ -177,6 +180,10 @@ int main(int argc, const char **argv)
|
|||
info.client_ssl_ca_filepath = "./libwebsockets.org.cer";
|
||||
#endif
|
||||
|
||||
if (lws_cmdline_option(argc, argv, "-z"))
|
||||
zero_length_ping = 1;
|
||||
|
||||
|
||||
context = lws_create_context(&info);
|
||||
if (!context) {
|
||||
lwsl_err("lws init failed\n");
|
||||
|
|
Loading…
Add table
Reference in a new issue