new websocket handling
[src/app-framework-binder.git] / src / websock.c
index e583a49..c578eba 100644 (file)
@@ -199,10 +199,10 @@ static int check_control_header(struct websock *ws)
                return 0;
        if (FRAME_GET_RSV3(ws->header[0]) != 0)
                return 0;
-       if (FRAME_GET_MASK(ws->header[1]))
-               return 0;
        if (FRAME_GET_OPCODE(ws->header[0]) == OPCODE_CLOSE)
                return FRAME_GET_PAYLOAD_LEN(ws->header[1]) != 1;
+       if (FRAME_GET_MASK(ws->header[1]))
+               return 0;
        return FRAME_GET_PAYLOAD_LEN(ws->header[1]) == 0;
 }
 
@@ -346,7 +346,7 @@ loop:
                                                  (size_t) ws->length);
                        else
                                ws->itf->on_close(ws->closure,
-                                                 WEBSOCKET_CODE_UNSET, 0);
+                                                 WEBSOCKET_CODE_NOT_SET, 0);
                        ws->itf->disconnect(ws->closure);
                        return 0;
                default: