- afb_hreq_reply_empty(hreq, MHD_HTTP_SWITCHING_PROTOCOLS,
- sec_websocket_accept_s, acceptval,
- sec_websocket_protocol_s, proto->name,
- MHD_HTTP_HEADER_CONNECTION, MHD_HTTP_HEADER_UPGRADE,
- MHD_HTTP_HEADER_UPGRADE, websocket_s,
- NULL);
-
- hreq->upgrade = 1;
+ 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, sec_websocket_protocol_s, proto->name);
+ MHD_add_response_header(response, MHD_HTTP_HEADER_CONNECTION, MHD_HTTP_HEADER_UPGRADE);
+ MHD_add_response_header(response, MHD_HTTP_HEADER_UPGRADE, websocket_s);
+ MHD_queue_response(con, MHD_HTTP_SWITCHING_PROTOCOLS, response);
+ MHD_destroy_response(response);
+
+ *websock = ws;