From 6a925e5179727436bf91fe60abab34ba2bfa1442 Mon Sep 17 00:00:00 2001 From: Joe Littlejohn Date: Wed, 7 Mar 2018 20:23:49 +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 adb104546..ded4e4bf0 100644 --- a/lib/client/client.c +++ b/lib/client/client.c @@ -728,6 +728,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);