$ git clone https://libwebsocket.ion.nu/libwebsocket.git
commit 921e69cbe91e94e041e1423b851b4cd5e02f4719
Author: Alicia <...>
Date:   Mon May 29 21:33:11 2017 +0200

    Fixed websock_handshake_client()

diff --git a/websock.c b/websock.c
index 433b0e9..8f1e5d0 100644
--- a/websock.c
+++ b/websock.c
@@ -251,8 +251,9 @@ char websock_handshake_client(websock_conn* conn, const char* path, const char*
   while((r=aread(conn, &buf[len], 2047-len))>0)
   {
     len+=r;
+    buf[len]=0;
+    if(strstr(buf, "\r\n\r\n") || strstr(buf, "\n\n")){break;}
   }
-  buf[len]=0;
 //  write(1, buf, len);
   if(strncmp(buf, "HTTP/1.1 101 ", 13)){printf("%s\n", buf); return 0;}
   if(!strstr(buf, "\n\n") && !strstr(buf, "\r\n\r\n")){return 0;}