From ad07f3c66510696849bcbc77831e138978c942f8 Mon Sep 17 00:00:00 2001 From: Martin Becker Date: Tue, 18 Jul 2017 12:37:04 +0200 Subject: [PATCH] Allow to disable "Origin" header The origin header often makes trouble with current WebSocket implementations. Thus, we introduce the WEBSOCKET_HEADERS_NO_ORIGIN macro which disables this header it if defined. --- src/WebSocketsClient.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/WebSocketsClient.cpp b/src/WebSocketsClient.cpp index 819af0e..1dfcfba 100644 --- a/src/WebSocketsClient.cpp +++ b/src/WebSocketsClient.cpp @@ -479,8 +479,12 @@ void WebSocketsClient::sendHeader(WSclient_t * client) { handshake += WEBSOCKETS_STRING("Connection: keep-alive\r\n"); } - handshake += WEBSOCKETS_STRING("Origin: file://\r\n" - "User-Agent: arduino-WebSocket-Client\r\n"); +#ifndef WEBSOCKET_HEADERS_NO_ORIGIN + // add origin header if requested + handshake += WEBSOCKETS_STRING("Origin: file://\r\n"); +#endif + + handshake += WEBSOCKETS_STRING("User-Agent: arduino-WebSocket-Client\r\n"); if(client->base64Authorization.length() > 0) { handshake += WEBSOCKETS_STRING("Authorization: Basic ");