Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
983df2d8f9 | ||
|
|
6beba16ca7 | ||
|
|
48cefe5525 | ||
|
|
ae3856c10f |
@@ -115,10 +115,7 @@ endif()
|
|||||||
|
|
||||||
set(USE_OPEN_SSL FALSE)
|
set(USE_OPEN_SSL FALSE)
|
||||||
if (USE_TLS)
|
if (USE_TLS)
|
||||||
add_definitions(-DIXWEBSOCKET_USE_TLS)
|
|
||||||
|
|
||||||
if (USE_MBED_TLS)
|
if (USE_MBED_TLS)
|
||||||
add_definitions(-DIXWEBSOCKET_USE_MBED_TLS)
|
|
||||||
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketMbedTLS.h)
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketMbedTLS.h)
|
||||||
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketMbedTLS.cpp)
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketMbedTLS.cpp)
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
@@ -128,7 +125,6 @@ if (USE_TLS)
|
|||||||
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketSChannel.h)
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketSChannel.h)
|
||||||
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketSChannel.cpp)
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketSChannel.cpp)
|
||||||
else()
|
else()
|
||||||
add_definitions(-DIXWEBSOCKET_USE_OPEN_SSL)
|
|
||||||
set(USE_OPEN_SSL TRUE)
|
set(USE_OPEN_SSL TRUE)
|
||||||
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketOpenSSL.h)
|
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketOpenSSL.h)
|
||||||
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketOpenSSL.cpp)
|
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketOpenSSL.cpp)
|
||||||
@@ -140,6 +136,17 @@ add_library( ixwebsocket STATIC
|
|||||||
${IXWEBSOCKET_HEADERS}
|
${IXWEBSOCKET_HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (USE_TLS)
|
||||||
|
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_TLS)
|
||||||
|
if (USE_MBED_TLS)
|
||||||
|
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_MBED_TLS)
|
||||||
|
elseif (APPLE)
|
||||||
|
elseif (WIN32)
|
||||||
|
else()
|
||||||
|
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_OPEN_SSL)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (APPLE AND USE_TLS AND NOT USE_MBED_TLS)
|
if (APPLE AND USE_TLS AND NOT USE_MBED_TLS)
|
||||||
target_link_libraries(ixwebsocket "-framework foundation" "-framework security")
|
target_link_libraries(ixwebsocket "-framework foundation" "-framework security")
|
||||||
endif()
|
endif()
|
||||||
@@ -171,7 +178,7 @@ if (USE_TLS AND USE_MBED_TLS)
|
|||||||
target_link_libraries(ixwebsocket mbedtls)
|
target_link_libraries(ixwebsocket mbedtls)
|
||||||
else()
|
else()
|
||||||
find_package(MbedTLS REQUIRED)
|
find_package(MbedTLS REQUIRED)
|
||||||
include_directories(${MBEDTLS_INCLUDE_DIRS})
|
target_include_directories(ixwebsocket PUBLIC ${MBEDTLS_INCLUDE_DIRS})
|
||||||
target_link_libraries(ixwebsocket ${MBEDTLS_LIBRARIES})
|
target_link_libraries(ixwebsocket ${MBEDTLS_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
6.1.0
|
6.2.0
|
||||||
|
|||||||
14
appveyor.yml
14
appveyor.yml
@@ -2,13 +2,21 @@ image:
|
|||||||
- Visual Studio 2017
|
- Visual Studio 2017
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- ls -al
|
- cd C:\Tools\vcpkg
|
||||||
|
- git pull
|
||||||
|
- .\bootstrap-vcpkg.bat
|
||||||
|
- cd %APPVEYOR_BUILD_FOLDER%
|
||||||
- cmd: call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
|
- cmd: call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||||
|
- vcpkg install zlib:x64-windows
|
||||||
|
- vcpkg install mbedtls:x64-windows
|
||||||
- cd test
|
- cd test
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- cmake -G"NMake Makefiles" ..
|
- cmake -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DUSE_TLS=1 -G"NMake Makefiles" ..
|
||||||
- nmake
|
- nmake
|
||||||
- ixwebsocket_unittest.exe
|
- cd ..
|
||||||
|
- build\ixwebsocket_unittest.exe
|
||||||
|
|
||||||
|
cache: c:\tools\vcpkg\installed\
|
||||||
|
|
||||||
build: off
|
build: off
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [6.2.0] - 2019-09-09
|
||||||
|
|
||||||
|
- websocket and http server: server does not close the bound client socket in many cases
|
||||||
|
|
||||||
## [6.1.0] - 2019-09-08
|
## [6.1.0] - 2019-09-08
|
||||||
|
|
||||||
- move poll wrapper on top of select (only used on Windows) to the ix namespace
|
- move poll wrapper on top of select (only used on Windows) to the ix namespace
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ Options for building:
|
|||||||
* `-DUSE_MBED_TLS=1` will use [mbedlts](https://tls.mbed.org/) for the TLS support (default on Windows)
|
* `-DUSE_MBED_TLS=1` will use [mbedlts](https://tls.mbed.org/) for the TLS support (default on Windows)
|
||||||
* `-DUSE_WS=1` will build the ws interactive command line tool
|
* `-DUSE_WS=1` will build the ws interactive command line tool
|
||||||
|
|
||||||
|
If you are on Windows, look at the [appveyor](https://github.com/machinezone/IXWebSocket/blob/master/appveyor.yml) file that has instructions for building dependencies.
|
||||||
|
|
||||||
### vcpkg
|
### vcpkg
|
||||||
|
|
||||||
It is possible to get IXWebSocket through Microsoft [vcpkg](https://github.com/microsoft/vcpkg).
|
It is possible to get IXWebSocket through Microsoft [vcpkg](https://github.com/microsoft/vcpkg).
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ namespace ix
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
connectionState->setTerminated();
|
connectionState->setTerminated();
|
||||||
|
Socket::closeSocket(fd);
|
||||||
|
|
||||||
_connectedClientsCount--;
|
_connectedClientsCount--;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace ix
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "WebSocketServer::handleConnection() error: "
|
ss << "WebSocketServer::handleConnection() HTTP status: "
|
||||||
<< status.http_status
|
<< status.http_status
|
||||||
<< " error: "
|
<< " error: "
|
||||||
<< status.errorStr;
|
<< status.errorStr;
|
||||||
@@ -111,6 +111,8 @@ namespace ix
|
|||||||
|
|
||||||
logInfo("WebSocketServer::handleConnection() done");
|
logInfo("WebSocketServer::handleConnection() done");
|
||||||
connectionState->setTerminated();
|
connectionState->setTerminated();
|
||||||
|
|
||||||
|
Socket::closeSocket(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::shared_ptr<WebSocket>> WebSocketServer::getClients()
|
std::set<std::shared_ptr<WebSocket>> WebSocketServer::getClients()
|
||||||
|
|||||||
@@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "6.1.0"
|
#define IX_WEBSOCKET_VERSION "6.2.0"
|
||||||
|
|||||||
@@ -62,8 +62,6 @@ set (SOURCES
|
|||||||
IXHttpClientTest.cpp
|
IXHttpClientTest.cpp
|
||||||
IXHttpServerTest.cpp
|
IXHttpServerTest.cpp
|
||||||
IXUnityBuildsTest.cpp
|
IXUnityBuildsTest.cpp
|
||||||
IXCobraChatTest.cpp
|
|
||||||
IXCobraMetricsPublisherTest.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Some unittest don't work on windows yet
|
# Some unittest don't work on windows yet
|
||||||
@@ -72,6 +70,8 @@ if (UNIX)
|
|||||||
IXDNSLookupTest.cpp
|
IXDNSLookupTest.cpp
|
||||||
cmd_websocket_chat.cpp
|
cmd_websocket_chat.cpp
|
||||||
IXWebSocketCloseTest.cpp
|
IXWebSocketCloseTest.cpp
|
||||||
|
IXCobraChatTest.cpp
|
||||||
|
IXCobraMetricsPublisherTest.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
55
test/IXHttpTest.cpp
Normal file
55
test/IXHttpTest.cpp
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* IXHttpTest.cpp
|
||||||
|
* Author: Benjamin Sergeant
|
||||||
|
* Copyright (c) 2019 Machine Zone. All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <ixwebsocket/IXHttp.h>
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
namespace ix
|
||||||
|
{
|
||||||
|
|
||||||
|
TEST_CASE("http", "[http]")
|
||||||
|
{
|
||||||
|
SECTION("Normal case")
|
||||||
|
{
|
||||||
|
std::string line = "HTTP/1.1 200";
|
||||||
|
auto result = Http::parseStatusLine(line);
|
||||||
|
|
||||||
|
REQUIRE(result.first == "HTTP/1.1");
|
||||||
|
REQUIRE(result.second == 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("http/1.0 case")
|
||||||
|
{
|
||||||
|
std::string line = "HTTP/1.0 200";
|
||||||
|
auto result = Http::parseStatusLine(line);
|
||||||
|
|
||||||
|
REQUIRE(result.first == "HTTP/1.0");
|
||||||
|
REQUIRE(result.second == 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("empty case")
|
||||||
|
{
|
||||||
|
std::string line = "";
|
||||||
|
auto result = Http::parseStatusLine(line);
|
||||||
|
|
||||||
|
REQUIRE(result.first == "");
|
||||||
|
REQUIRE(result.second == -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("empty case")
|
||||||
|
{
|
||||||
|
std::string line = "HTTP/1.1";
|
||||||
|
auto result = Http::parseStatusLine(line);
|
||||||
|
|
||||||
|
REQUIRE(result.first == "HTTP/1.1");
|
||||||
|
REQUIRE(result.second == -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user