aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-05-19 13:18:16 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-05-19 13:18:16 +0200
commit917ffb686f88dfcd2819206deff88307dc90943c (patch)
tree4062a9050f7131b91ed1f4a40e321751b13561b7
parent0ea46ffe93ab87cbd41df1a80d38904d026fcb3b (diff)
websocket: accept empty protocol
Change-Id: If4d8609d5340faa53fea9e133a5415a576cbf5c5 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-websock.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/afb-websock.c b/src/afb-websock.c
index 3ad9e20d..0228ce1b 100644
--- a/src/afb-websock.c
+++ b/src/afb-websock.c
@@ -102,6 +102,10 @@ static const struct protodef *search_proto(const struct protodef *protodefs, con
int i;
size_t len;
+ if (protocols == NULL) {
+ /* return NULL; */
+ return protodefs != NULL && protodefs->name != NULL ? protodefs : NULL;
+ }
for(;;) {
protocols += strspn(protocols, vseparators);
if (!*protocols)
@@ -154,7 +158,7 @@ static int check_websocket_upgrade(struct MHD_Connection *con, const struct prot
/* is the protocol supported ? */
protocols = MHD_lookup_connection_value(con, MHD_HEADER_KIND, sec_websocket_protocol_s);
- proto = protocols == NULL ? NULL : search_proto(protodefs, protocols);
+ proto = search_proto(protodefs, protocols);
if (proto == NULL) {
response = MHD_create_response_from_buffer(0, NULL, MHD_RESPMEM_PERSISTENT);
MHD_queue_response(con, MHD_HTTP_PRECONDITION_FAILED, response);