From 81e567b24822fb95c122a994eedc55fb87e5a1d9 Mon Sep 17 00:00:00 2001 From: Links Date: Sat, 18 Mar 2017 10:32:37 +0100 Subject: [PATCH] send 401 header too if auth string is empty #116 --- src/WebSocketsServer.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/WebSocketsServer.cpp b/src/WebSocketsServer.cpp index c10b2d4..9b8cfe7 100644 --- a/src/WebSocketsServer.cpp +++ b/src/WebSocketsServer.cpp @@ -766,17 +766,13 @@ void WebSocketsServer::handleHeader(WSclient_t * client, String * headerLine) { } if(_base64Authorization.length() > 0) { - if(client->base64Authorization.length() > 0) { - String auth = WEBSOCKETS_STRING("Basic "); - auth += _base64Authorization; - if(auth != client->base64Authorization) { - DEBUG_WEBSOCKETS("[WS-Server][%d][handleHeader] HTTP Authorization failed!\n", client->num); - handleAuthorizationFailed(client); - return; - } - } else { - ok = false; - } + String auth = WEBSOCKETS_STRING("Basic "); + auth += _base64Authorization; + if(auth != client->base64Authorization) { + DEBUG_WEBSOCKETS("[WS-Server][%d][handleHeader] HTTP Authorization failed!\n", client->num); + handleAuthorizationFailed(client); + return; + } } if(ok) {