From e333d1a751e7de30d5847d8e0841107805d3b359 Mon Sep 17 00:00:00 2001 From: Joe Littlejohn Date: Wed, 7 Mar 2018 20:22:55 +0800 Subject: [PATCH] Add 'HS: ws upgrade unauthorized' on receiving 401 In the case that the connection cannot be established because the caller is unauthorized, it's likely they have to do something to gain authorization before retrying. This change introduces a new message that can be checked for to understand more about why the connection has failed to establish. Closes #1200 --- lib/client/client.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/client/client.c b/lib/client/client.c index 5a8228d8..cf119c88 100644 --- a/lib/client/client.c +++ b/lib/client/client.c @@ -759,6 +759,13 @@ lws_client_interpret_server_handshake(struct lws *wsi) return 0; } + if (p && !strncmp(p, "401", 3)) { + lwsl_warn( + "lws_client_handshake: got bad HTTP response '%s'\n", p); + cce = "HS: ws upgrade unauthorized"; + goto bail3; + } + if (p && strncmp(p, "101", 3)) { lwsl_warn( "lws_client_handshake: got bad HTTP response '%s'\n", p);