X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-ws-client.c;h=582212fc29bb4f4d6a641a88f9ae45d8d4aacd10;hb=2243a0dd1adc75530bed663db808971789729df3;hp=e9c1a90619379f6ab3862b534c164e2c44aed8e5;hpb=ceb2e567b5f26ff148fbc0e9526f7e7e99464000;p=src%2Fapp-framework-binder.git diff --git a/src/afb-ws-client.c b/src/afb-ws-client.c index e9c1a906..582212fc 100644 --- a/src/afb-ws-client.c +++ b/src/afb-ws-client.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 "IoT.bzh" + * Copyright (C) 2016, 2017 "IoT.bzh" * Author: José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -51,14 +51,6 @@ static const char *compkeys[32] = { "MHiEc+Qc8w/SJ3zMHEM8pA==", "FVCxLBmoil3gY0jSX3aNJ6kR/t4=" }; -static const char websocket_s[] = "websocket"; -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 vseparators[] = " \t,"; - /* get randomly a pair of key/accept value */ static void getkeypair(const char **key, const char **ack) { @@ -111,7 +103,7 @@ static char *strjoin(int count, const char **strings, const char *separ) /* creates the http message for the request */ static int make_request(char **request, const char *path, const char *host, const char *key, const char *protocols) { - int rc = asprintf(request, + int rc = asprintf(request, "GET %s HTTP/1.1\r\n" "Host: %s\r\n" "Upgrade: websocket\r\n" @@ -314,7 +306,6 @@ invalid: errno = EINVAL; error: return -1; - } @@ -322,7 +313,7 @@ error: static const char *proto_json1[2] = { "x-afb-ws-json1", NULL }; -struct afb_wsj1 *afb_ws_client_connect_wsj1(const char *uri, struct afb_wsj1_itf *itf, void *closure) +struct afb_wsj1 *afb_ws_client_connect_wsj1(struct sd_event *eloop, const char *uri, struct afb_wsj1_itf *itf, void *closure) { int rc, fd; char *host, *service, xhost[32]; @@ -363,7 +354,7 @@ struct afb_wsj1 *afb_ws_client_connect_wsj1(const char *uri, struct afb_wsj1_itf if (rc == 0) { rc = negociate(fd, proto_json1, path, xhost); if (rc == 0) { - result = afb_wsj1_create(fd, itf, closure); + result = afb_wsj1_create(eloop, fd, itf, closure); if (result != NULL) { fcntl(fd, F_SETFL, O_NONBLOCK); break;