From 862f8ea2d40a3a4b9432ab88c584ab82c45df574 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Mon, 16 Dec 2019 17:57:43 -0800 Subject: [PATCH] (websocket client) improve the error message when connecting to a non websocket server --- docs/CHANGELOG.md | 16 ++++++++++++++++ ixwebsocket/IXWebSocketHandshake.cpp | 4 ++-- ixwebsocket/IXWebSocketVersion.h | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6eb14c76..c3396efb 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,22 @@ # Changelog All notable changes to this project will be documented in this file. +## [7.5.4] - 2019-12-16 + +(websocket client) improve the error message when connecting to a non websocket server + +Before: + +``` +Connection error: Got bad status connecting to example.com:443, status: 200, HTTP Status line: HTTP/1.1 200 OK +``` + +After: + +``` +Connection error: Expecting status 101 (Switching Protocol), got 200 status connecting to example.com:443, HTTP Status line: HTTP/1.1 200 OK +``` + ## [7.5.3] - 2019-12-12 (server) attempt at fixing #131 by using blocking writes in server mode diff --git a/ixwebsocket/IXWebSocketHandshake.cpp b/ixwebsocket/IXWebSocketHandshake.cpp index 0cad8ae6..dac14dac 100644 --- a/ixwebsocket/IXWebSocketHandshake.cpp +++ b/ixwebsocket/IXWebSocketHandshake.cpp @@ -178,8 +178,8 @@ namespace ix if (status != 101) { std::stringstream ss; - ss << "Got bad status connecting to " << host << ":" << port << ", status: " << status - << ", HTTP Status line: " << line; + ss << "Expecting status 101 (Switching Protocol), got " << status + << " status connecting to " << host << ":" << port << ", HTTP Status line: " << line; return WebSocketInitResult(false, status, ss.str()); } diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index c3990864..aa63a9ba 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "7.5.3" +#define IX_WEBSOCKET_VERSION "7.5.4"