X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-websock.c;h=b9417cbe34ba1703e118dac95d8a5a4677a4d3e0;hb=f113d2b31333538f5784de5ee5f02bc19cc603e4;hp=b6056adcd0e7edf7219e08966bca78671ec1fe5d;hpb=ca208671cc79bbc05c574df788035878e5d39382;p=src%2Fapp-framework-binder.git diff --git a/src/afb-websock.c b/src/afb-websock.c index b6056adc..b9417cbe 100644 --- a/src/afb-websock.c +++ b/src/afb-websock.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -29,7 +30,7 @@ #include "websock.h" -#include "../include/local-def.h" +#include "local-def.h" #include "afb-method.h" #include "afb-hreq.h" @@ -39,7 +40,7 @@ static const char sec_websocket_key_s[] = "Sec-WebSocket-Key"; static const char sec_websocket_version_s[] = "Sec-WebSocket-Version"; static const char sec_websocket_accept_s[] = "Sec-WebSocket-Accept"; static const char sec_websocket_protocol_s[] = "Sec-WebSocket-Protocol"; -static const char websocket_uuid[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; +static const char websocket_guid[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; struct afb_websock @@ -108,10 +109,10 @@ static void make_accept_value(const char *key, char result[29]) { unsigned char md[SHA_DIGEST_LENGTH+1]; size_t len = strlen(key); - char *buffer = alloca(len + sizeof websocket_uuid - 1); + char *buffer = alloca(len + sizeof websocket_guid - 1); memcpy(buffer, key, len); - memcpy(buffer + len, websocket_uuid, sizeof websocket_uuid - 1); - SHA1((const unsigned char *)buffer, (unsigned long)(len + sizeof websocket_uuid - 1), md); + memcpy(buffer + len, websocket_guid, sizeof websocket_guid - 1); + SHA1((const unsigned char *)buffer, (unsigned long)(len + sizeof websocket_guid - 1), md); assert(SHA_DIGEST_LENGTH == 20); md[20] = 0; enc64(&md[0], &result[0]); @@ -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);