(ixwebsocket) Fix #252 / regression in 11.0.2 with string comparisons
This commit is contained in:
		@@ -2,6 +2,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
All changes to this project will be documented in this file.
 | 
					All changes to this project will be documented in this file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## [11.0.3] - 2020-11-16
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(ixwebsocket) Fix #252 / regression in 11.0.2 with string comparisons
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## [11.0.2] - 2020-11-15
 | 
					## [11.0.2] - 2020-11-15
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(ixwebsocket) use a C++11 compatible make_unique shim
 | 
					(ixwebsocket) use a C++11 compatible make_unique shim
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -105,6 +105,24 @@ namespace ix
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return ret;
 | 
					        return ret;
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
 | 
					        //
 | 
				
			||||||
 | 
					        // It was reported that on Android poll can fail and return -1 with
 | 
				
			||||||
 | 
					        // errno == EINTR, which should be a temp error and should typically
 | 
				
			||||||
 | 
					        // be handled by retrying in a loop.
 | 
				
			||||||
 | 
					        // Maybe we need to put all syscall / C functions in
 | 
				
			||||||
 | 
					        // a new IXSysCalls.cpp and wrap them all.
 | 
				
			||||||
 | 
					        //
 | 
				
			||||||
 | 
					        // The style from libuv is as such.
 | 
				
			||||||
 | 
					        //
 | 
				
			||||||
 | 
					        // int ret = -1;
 | 
				
			||||||
 | 
					        // do
 | 
				
			||||||
 | 
					        // {
 | 
				
			||||||
 | 
					        //     ret = ::poll(fds, nfds, timeout);
 | 
				
			||||||
 | 
					        // }
 | 
				
			||||||
 | 
					        // while (ret == -1 && errno == EINTR);
 | 
				
			||||||
 | 
					        // return ret;
 | 
				
			||||||
 | 
					        //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return ::poll(fds, nfds, timeout);
 | 
					        return ::poll(fds, nfds, timeout);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,10 +8,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "IXHttp.h"
 | 
					#include "IXHttp.h"
 | 
				
			||||||
#include "IXSocketConnect.h"
 | 
					#include "IXSocketConnect.h"
 | 
				
			||||||
 | 
					#include "IXStrCaseCompare.h"
 | 
				
			||||||
#include "IXUrlParser.h"
 | 
					#include "IXUrlParser.h"
 | 
				
			||||||
#include "IXUserAgent.h"
 | 
					#include "IXUserAgent.h"
 | 
				
			||||||
#include "IXWebSocketHandshakeKeyGen.h"
 | 
					#include "IXWebSocketHandshakeKeyGen.h"
 | 
				
			||||||
#include "IXStrCaseCompare.h"
 | 
					 | 
				
			||||||
#include <algorithm>
 | 
					#include <algorithm>
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
#include <random>
 | 
					#include <random>
 | 
				
			||||||
@@ -36,7 +36,7 @@ namespace ix
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    bool WebSocketHandshake::insensitiveStringCompare(const std::string& a, const std::string& b)
 | 
					    bool WebSocketHandshake::insensitiveStringCompare(const std::string& a, const std::string& b)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return CaseInsensitiveLess::cmp(a, b);
 | 
					        return CaseInsensitiveLess::cmp(a, b) == 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string WebSocketHandshake::genRandomString(const int len)
 | 
					    std::string WebSocketHandshake::genRandomString(const int len)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,4 +6,4 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define IX_WEBSOCKET_VERSION "11.0.2"
 | 
					#define IX_WEBSOCKET_VERSION "11.0.3"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,6 @@ option(USE_TLS "Add TLS support" ON)
 | 
				
			|||||||
set (TEST_TARGET_NAMES
 | 
					set (TEST_TARGET_NAMES
 | 
				
			||||||
  IXSocketTest
 | 
					  IXSocketTest
 | 
				
			||||||
  IXSocketConnectTest
 | 
					  IXSocketConnectTest
 | 
				
			||||||
  # IXWebSocketLeakTest.cpp # commented until we have a fix for #224
 | 
					 | 
				
			||||||
  IXWebSocketServerTest
 | 
					  IXWebSocketServerTest
 | 
				
			||||||
  IXWebSocketTestConnectionDisconnection
 | 
					  IXWebSocketTestConnectionDisconnection
 | 
				
			||||||
  IXUrlParserTest
 | 
					  IXUrlParserTest
 | 
				
			||||||
@@ -28,6 +27,7 @@ set (TEST_TARGET_NAMES
 | 
				
			|||||||
  IXWebSocketBroadcastTest
 | 
					  IXWebSocketBroadcastTest
 | 
				
			||||||
  IXWebSocketPerMessageDeflateCompressorTest
 | 
					  IXWebSocketPerMessageDeflateCompressorTest
 | 
				
			||||||
  IXStreamSqlTest
 | 
					  IXStreamSqlTest
 | 
				
			||||||
 | 
					  IXStrCaseCompareTest
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Some unittest don't work on windows yet
 | 
					# Some unittest don't work on windows yet
 | 
				
			||||||
@@ -47,6 +47,9 @@ endif()
 | 
				
			|||||||
# IXWebSocketPingTest.cpp
 | 
					# IXWebSocketPingTest.cpp
 | 
				
			||||||
# IXWebSocketPingTimeoutTest.cpp
 | 
					# IXWebSocketPingTimeoutTest.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# IXWebSocketLeakTest.cpp # commented until we have a fix for #224 /
 | 
				
			||||||
 | 
					# that was was fixed but now the test does not compile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Disable tests for now that are failing or not reliable
 | 
					# Disable tests for now that are failing or not reliable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
find_package(JsonCpp)
 | 
					find_package(JsonCpp)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										46
									
								
								test/IXStrCaseCompareTest.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								test/IXStrCaseCompareTest.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 *  IXStrCaseCompareTest.cpp
 | 
				
			||||||
 | 
					 *  Author: Benjamin Sergeant
 | 
				
			||||||
 | 
					 *  Copyright (c) 2020 Machine Zone. All rights reserved.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "IXTest.h"
 | 
				
			||||||
 | 
					#include "catch.hpp"
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#include <ixwebsocket/IXUrlParser.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using namespace ix;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace ix
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    TEST_CASE("str_case_compare", "[str_case_compare]")
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        SECTION("1")
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            using HttpHeaders = std::map<std::string, std::string, CaseInsensitiveLess>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            HttpHeaders httpHeaders;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            httpHeaders["foo"] = "foo";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            REQUIRE(httpHeaders["foo"] == "foo");
 | 
				
			||||||
 | 
					            REQUIRE(httpHeaders["missing"] == "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Comparison should be case insensitive
 | 
				
			||||||
 | 
					            REQUIRE(httpHeaders["Foo"] == "foo");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        SECTION("2")
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            using HttpHeaders = std::map<std::string, std::string, CaseInsensitiveLess>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            HttpHeaders headers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            headers["Upgrade"] = "webSocket";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            REQUIRE(CaseInsensitiveLess::cmp(headers["upgrade"], "WebSocket") == 0);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // namespace ix
 | 
				
			||||||
		Reference in New Issue
	
	Block a user