aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-10-15 00:25:35 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-10-15 00:39:27 +0200
commitb3c377afdb1a53998980b80de112f16130d8bec3 (patch)
treeb5a83b2c6c01abdd3609ea2a23cfea84ec817dac
parent4236a4943a89dc8e1c1c2d30c31f09f80164ec17 (diff)
downloadjson-rpc-shell-b3c377afdb1a53998980b80de112f16130d8bec3.tar.gz
json-rpc-shell-b3c377afdb1a53998980b80de112f16130d8bec3.tar.xz
json-rpc-shell-b3c377afdb1a53998980b80de112f16130d8bec3.zip
json-rpc-test-server: WS: fix failures to upgrade
Similar to ad1aba9, only here we return 426 to the client.
-rw-r--r--json-rpc-test-server.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/json-rpc-test-server.c b/json-rpc-test-server.c
index ce31b54..0cfd161 100644
--- a/json-rpc-test-server.c
+++ b/json-rpc-test-server.c
@@ -1003,9 +1003,10 @@ ws_handler_on_headers_complete (http_parser *parser)
if (self->have_header_value)
ws_handler_on_header_read (self);
- // We strictly require a protocol upgrade
+ // We require a protocol upgrade. 1 is for "skip body", 2 is the same
+ // + "stop processing", return another number to indicate a problem here.
if (!parser->upgrade)
- return 2;
+ return 3;
return 0;
}
@@ -1268,11 +1269,13 @@ ws_handler_push (struct ws_handler *self, const void *data, size_t len)
ev_timer_stop (EV_DEFAULT_ &self->handshake_timeout_watcher);
if (err == HPE_CB_headers_complete)
+ {
print_debug ("WS handshake failed: %s", "missing `Upgrade' field");
- else
- print_debug ("WS handshake failed: %s",
- http_errno_description (err));
+ FAIL_HANDSHAKE (HTTP_426_UPGRADE_REQUIRED,
+ "Upgrade: websocket", SEC_WS_VERSION ": 13");
+ }
+ print_debug ("WS handshake failed: %s", http_errno_description (err));
FAIL_HANDSHAKE (HTTP_400_BAD_REQUEST);
}
return true;