work in progress
[src/app-framework-binder.git] / src / afb-websock.c
index 1c087e2..b9417cb 100644 (file)
@@ -22,6 +22,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <sys/uio.h>
+#include <string.h>
 
 #include <openssl/sha.h>
 #include <openssl/bio.h>
@@ -29,7 +30,7 @@
 
 #include "websock.h"
 
-#include "../include/local-def.h"
+#include "local-def.h"
 
 #include "afb-method.h"
 #include "afb-hreq.h"
@@ -136,7 +137,6 @@ static int headerhas(const char *header, const char *needle)
                if (!*header)
                        return 0;
                len = strcspn(header, sep);
-printf("!!!%.*s!!!\n",len,header);
                if (n == len && 0 == strncasecmp(needle, header, n))
                        return 1;
                header += len;
@@ -173,7 +173,7 @@ int afb_websock_check(struct afb_hreq *hreq, int *later)
        /* is a supported version ? */
        vernum = atoi(version);
        if (vernum != 13) {
-               response = MHD_create_response_from_data(0,NULL,0,0);
+               response = MHD_create_response_from_buffer(0, NULL, MHD_RESPMEM_PERSISTENT);
                MHD_add_response_header (response, sec_websocket_version_s, "13");
                MHD_queue_response (hreq->connection, MHD_HTTP_BAD_REQUEST, response);
                MHD_destroy_response (response);
@@ -186,7 +186,7 @@ int afb_websock_check(struct afb_hreq *hreq, int *later)
 
        /* send the accept connection */
        make_accept_value(key, acceptval);
-       response = MHD_create_response_from_data(0,NULL,0,0);
+       response = MHD_create_response_from_buffer(0, NULL, MHD_RESPMEM_PERSISTENT);
        MHD_add_response_header (response, sec_websocket_accept_s, acceptval);
        MHD_add_response_header (response, MHD_HTTP_HEADER_CONNECTION, MHD_HTTP_HEADER_UPGRADE);
        MHD_add_response_header (response, MHD_HTTP_HEADER_UPGRADE, websocket_s);