diff --git a/.travis.yml b/.travis.yml index 3cc151dd9..6c9edc8e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -103,13 +103,13 @@ matrix: script: - export CC="arm-linux-gnueabi-gcc" - export CXX="arm-linux-gnueabi-g++" - - mkdir cmake-build && cd cmake-build && cmake -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_TESTS=ON .. && make -j2 && cd .. + - mkdir cmake-build && cd cmake-build && cmake -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_TESTS=OFF .. && make -j2 && cd .. - env: TEST_NAME="Linux arm-linux-gnueabihf-g++ (CMake)" script: - export CC="arm-linux-gnueabihf-gcc" - export CXX="arm-linux-gnueabihf-g++" - - mkdir cmake-build && cd cmake-build && cmake -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_TESTS=ON .. && make -j2 && cd .. + - mkdir cmake-build && cd cmake-build && cmake -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_TESTS=OFF .. && make -j2 && cd .. # TODO osx build # TODO run test suite diff --git a/NetSSL_Win/testsuite/TestSuite_CE_vs90.vcproj b/NetSSL_Win/testsuite/TestSuite_CE_vs90.vcproj index e7952fcd5..4f59bdd4c 100644 --- a/NetSSL_Win/testsuite/TestSuite_CE_vs90.vcproj +++ b/NetSSL_Win/testsuite/TestSuite_CE_vs90.vcproj @@ -551,6 +551,23 @@ RelativePath=".\src\HTTPSStreamFactoryTest.cpp"/> </Filter> </Filter> + <Filter + Name="WebSocket"> + <Filter + Name="Header Files"> + <File + RelativePath=".\src\WebSocketTest.h"/> + <File + RelativePath=".\src\WebSocketTestSuite.h"/> + </Filter> + <Filter + Name="Source Files"> + <File + RelativePath=".\src\WebSocketTest.cpp"/> + <File + RelativePath=".\src\WebSocketTestSuite.cpp"/> + </Filter> + </Filter> </Files> <Globals/> </VisualStudioProject> diff --git a/NetSSL_Win/testsuite/TestSuite_WEC2013_vs110.vcxproj b/NetSSL_Win/testsuite/TestSuite_WEC2013_vs110.vcxproj index eceff2c80..2eae66f90 100644 --- a/NetSSL_Win/testsuite/TestSuite_WEC2013_vs110.vcxproj +++ b/NetSSL_Win/testsuite/TestSuite_WEC2013_vs110.vcxproj @@ -316,6 +316,8 @@ <ClInclude Include="src\HTTPSClientSessionTest.h"/> <ClInclude Include="src\HTTPSClientTestSuite.h"/> <ClInclude Include="src\HTTPSStreamFactoryTest.h"/> + <ClInclude Include="src\WebSocketTest.h" /> + <ClInclude Include="src\WebSocketTestSuite.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="src\HTTPSTestServer.cpp"/> @@ -328,6 +330,8 @@ <ClCompile Include="src\HTTPSClientSessionTest.cpp"/> <ClCompile Include="src\HTTPSClientTestSuite.cpp"/> <ClCompile Include="src\HTTPSStreamFactoryTest.cpp"/> + <ClCompile Include="src\WebSocketTest.cpp" /> + <ClCompile Include="src\WebSocketTestSuite.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> <ImportGroup Label="ExtensionTargets"/> diff --git a/NetSSL_Win/testsuite/TestSuite_WEC2013_vs120.vcxproj b/NetSSL_Win/testsuite/TestSuite_WEC2013_vs120.vcxproj index 53e831b75..34fb61761 100644 --- a/NetSSL_Win/testsuite/TestSuite_WEC2013_vs120.vcxproj +++ b/NetSSL_Win/testsuite/TestSuite_WEC2013_vs120.vcxproj @@ -316,6 +316,8 @@ <ClInclude Include="src\NetSSLTestSuite.h"/> <ClInclude Include="src\TCPServerTest.h"/> <ClInclude Include="src\TCPServerTestSuite.h"/> + <ClInclude Include="src\WebSocketTest.h" /> + <ClInclude Include="src\WebSocketTestSuite.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="src\HTTPSClientSessionTest.cpp"/> @@ -328,6 +330,8 @@ <ClCompile Include="src\TCPServerTest.cpp"/> <ClCompile Include="src\TCPServerTestSuite.cpp"/> <ClCompile Include="src\WinCEDriver.cpp"/> + <ClCompile Include="src\WebSocketTest.cpp" /> + <ClCompile Include="src\WebSocketTestSuite.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> <ImportGroup Label="ExtensionTargets"/> diff --git a/NetSSL_Win/testsuite/TestSuite_vs100.vcxproj b/NetSSL_Win/testsuite/TestSuite_vs100.vcxproj index 1c5a7691c..70ae89f37 100644 --- a/NetSSL_Win/testsuite/TestSuite_vs100.vcxproj +++ b/NetSSL_Win/testsuite/TestSuite_vs100.vcxproj @@ -321,6 +321,8 @@ <ClInclude Include="src\HTTPSClientSessionTest.h"/> <ClInclude Include="src\HTTPSClientTestSuite.h"/> <ClInclude Include="src\HTTPSStreamFactoryTest.h"/> + <ClInclude Include="src\WebSocketTest.h" /> + <ClInclude Include="src\WebSocketTestSuite.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="src\HTTPSTestServer.cpp"/> @@ -333,6 +335,8 @@ <ClCompile Include="src\HTTPSClientSessionTest.cpp"/> <ClCompile Include="src\HTTPSClientTestSuite.cpp"/> <ClCompile Include="src\HTTPSStreamFactoryTest.cpp"/> + <ClCompile Include="src\WebSocketTest.cpp" /> + <ClCompile Include="src\WebSocketTestSuite.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> <ImportGroup Label="ExtensionTargets"/> diff --git a/NetSSL_Win/testsuite/TestSuite_vs110.vcxproj b/NetSSL_Win/testsuite/TestSuite_vs110.vcxproj index ff8ef1737..5a3e63afa 100644 --- a/NetSSL_Win/testsuite/TestSuite_vs110.vcxproj +++ b/NetSSL_Win/testsuite/TestSuite_vs110.vcxproj @@ -321,6 +321,8 @@ <ClInclude Include="src\HTTPSClientSessionTest.h"/> <ClInclude Include="src\HTTPSClientTestSuite.h"/> <ClInclude Include="src\HTTPSStreamFactoryTest.h"/> + <ClInclude Include="src\WebSocketTest.h" /> + <ClInclude Include="src\WebSocketTestSuite.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="src\HTTPSTestServer.cpp"/> @@ -333,6 +335,8 @@ <ClCompile Include="src\HTTPSClientSessionTest.cpp"/> <ClCompile Include="src\HTTPSClientTestSuite.cpp"/> <ClCompile Include="src\HTTPSStreamFactoryTest.cpp"/> + <ClCompile Include="src\WebSocketTest.cpp" /> + <ClCompile Include="src\WebSocketTestSuite.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> <ImportGroup Label="ExtensionTargets"/> diff --git a/NetSSL_Win/testsuite/TestSuite_vs120.vcxproj b/NetSSL_Win/testsuite/TestSuite_vs120.vcxproj index c64c28740..55cb0766c 100644 --- a/NetSSL_Win/testsuite/TestSuite_vs120.vcxproj +++ b/NetSSL_Win/testsuite/TestSuite_vs120.vcxproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="debug_shared|Win32"> @@ -32,7 +32,7 @@ <RootNamespace>TestSuite</RootNamespace> <Keyword>Win32Proj</Keyword> </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>MultiByte</CharacterSet> @@ -63,27 +63,27 @@ <CharacterSet>MultiByte</CharacterSet> <PlatformToolset>v120</PlatformToolset> </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/> - <ImportGroup Label="ExtensionSettings"/> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings" /> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|Win32'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|Win32'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|Win32'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> - <PropertyGroup Label="UserMacros"/> + <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion> <TargetName Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">TestSuited</TargetName> @@ -136,7 +136,7 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <CompileAs>Default</CompileAs> @@ -167,9 +167,9 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat/> + <DebugInformationFormat /> <CompileAs>Default</CompileAs> </ClCompile> <Link> @@ -196,7 +196,7 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <CompileAs>Default</CompileAs> @@ -227,9 +227,9 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat/> + <DebugInformationFormat /> <CompileAs>Default</CompileAs> </ClCompile> <Link> @@ -256,7 +256,7 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <CompileAs>Default</CompileAs> @@ -287,9 +287,9 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat/> + <DebugInformationFormat /> <CompileAs>Default</CompileAs> </ClCompile> <Link> @@ -304,28 +304,32 @@ </Link> </ItemDefinitionGroup> <ItemGroup> - <ClInclude Include="src\HTTPSClientSessionTest.h"/> - <ClInclude Include="src\HTTPSClientTestSuite.h"/> - <ClInclude Include="src\HTTPSServerTest.h"/> - <ClInclude Include="src\HTTPSServerTestSuite.h"/> - <ClInclude Include="src\HTTPSStreamFactoryTest.h"/> - <ClInclude Include="src\HTTPSTestServer.h"/> - <ClInclude Include="src\NetSSLTestSuite.h"/> - <ClInclude Include="src\TCPServerTest.h"/> - <ClInclude Include="src\TCPServerTestSuite.h"/> + <ClInclude Include="src\HTTPSClientSessionTest.h" /> + <ClInclude Include="src\HTTPSClientTestSuite.h" /> + <ClInclude Include="src\HTTPSServerTest.h" /> + <ClInclude Include="src\HTTPSServerTestSuite.h" /> + <ClInclude Include="src\HTTPSStreamFactoryTest.h" /> + <ClInclude Include="src\HTTPSTestServer.h" /> + <ClInclude Include="src\NetSSLTestSuite.h" /> + <ClInclude Include="src\TCPServerTest.h" /> + <ClInclude Include="src\TCPServerTestSuite.h" /> + <ClInclude Include="src\WebSocketTest.h" /> + <ClInclude Include="src\WebSocketTestSuite.h" /> </ItemGroup> <ItemGroup> - <ClCompile Include="src\Driver.cpp"/> - <ClCompile Include="src\HTTPSClientSessionTest.cpp"/> - <ClCompile Include="src\HTTPSClientTestSuite.cpp"/> - <ClCompile Include="src\HTTPSServerTest.cpp"/> - <ClCompile Include="src\HTTPSServerTestSuite.cpp"/> - <ClCompile Include="src\HTTPSStreamFactoryTest.cpp"/> - <ClCompile Include="src\HTTPSTestServer.cpp"/> - <ClCompile Include="src\NetSSLTestSuite.cpp"/> - <ClCompile Include="src\TCPServerTest.cpp"/> - <ClCompile Include="src\TCPServerTestSuite.cpp"/> + <ClCompile Include="src\Driver.cpp" /> + <ClCompile Include="src\HTTPSClientSessionTest.cpp" /> + <ClCompile Include="src\HTTPSClientTestSuite.cpp" /> + <ClCompile Include="src\HTTPSServerTest.cpp" /> + <ClCompile Include="src\HTTPSServerTestSuite.cpp" /> + <ClCompile Include="src\HTTPSStreamFactoryTest.cpp" /> + <ClCompile Include="src\HTTPSTestServer.cpp" /> + <ClCompile Include="src\NetSSLTestSuite.cpp" /> + <ClCompile Include="src\TCPServerTest.cpp" /> + <ClCompile Include="src\TCPServerTestSuite.cpp" /> + <ClCompile Include="src\WebSocketTest.cpp" /> + <ClCompile Include="src\WebSocketTestSuite.cpp" /> </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> - <ImportGroup Label="ExtensionTargets"/> -</Project> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets" /> +</Project> \ No newline at end of file diff --git a/NetSSL_Win/testsuite/TestSuite_vs120.vcxproj.filters b/NetSSL_Win/testsuite/TestSuite_vs120.vcxproj.filters index bd3bc66f1..7e0c821b6 100644 --- a/NetSSL_Win/testsuite/TestSuite_vs120.vcxproj.filters +++ b/NetSSL_Win/testsuite/TestSuite_vs120.vcxproj.filters @@ -52,6 +52,9 @@ <Filter Include="HTTPSClient\Source Files"> <UniqueIdentifier>{40e36c0c-5808-4c87-aa2e-04c0ffa6f35e}</UniqueIdentifier> </Filter> + <Filter Include="Websocket"> + <UniqueIdentifier>{9243a946-e87f-42f5-adba-efbb4823f93c}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> <ClInclude Include="src\HTTPSTestServer.h"> @@ -81,6 +84,12 @@ <ClInclude Include="src\HTTPSStreamFactoryTest.h"> <Filter>HTTPSClient\Header Files</Filter> </ClInclude> + <ClInclude Include="src\WebSocketTest.h"> + <Filter>Websocket</Filter> + </ClInclude> + <ClInclude Include="src\WebSocketTestSuite.h"> + <Filter>Websocket</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="src\HTTPSTestServer.cpp"> @@ -113,5 +122,11 @@ <ClCompile Include="src\HTTPSStreamFactoryTest.cpp"> <Filter>HTTPSClient\Source Files</Filter> </ClCompile> + <ClCompile Include="src\WebSocketTest.cpp"> + <Filter>Websocket</Filter> + </ClCompile> + <ClCompile Include="src\WebSocketTestSuite.cpp"> + <Filter>Websocket</Filter> + </ClCompile> </ItemGroup> </Project> \ No newline at end of file diff --git a/NetSSL_Win/testsuite/TestSuite_vs140.vcxproj b/NetSSL_Win/testsuite/TestSuite_vs140.vcxproj index 32545771c..6b06655ae 100644 --- a/NetSSL_Win/testsuite/TestSuite_vs140.vcxproj +++ b/NetSSL_Win/testsuite/TestSuite_vs140.vcxproj @@ -313,6 +313,8 @@ <ClInclude Include="src\NetSSLTestSuite.h"/> <ClInclude Include="src\TCPServerTest.h"/> <ClInclude Include="src\TCPServerTestSuite.h"/> + <ClInclude Include="src\WebSocketTest.h" /> + <ClInclude Include="src\WebSocketTestSuite.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="src\Driver.cpp"/> @@ -325,6 +327,8 @@ <ClCompile Include="src\NetSSLTestSuite.cpp"/> <ClCompile Include="src\TCPServerTest.cpp"/> <ClCompile Include="src\TCPServerTestSuite.cpp"/> + <ClCompile Include="src\WebSocketTest.cpp" /> + <ClCompile Include="src\WebSocketTestSuite.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> <ImportGroup Label="ExtensionTargets"/> diff --git a/NetSSL_Win/testsuite/TestSuite_vs90.vcproj b/NetSSL_Win/testsuite/TestSuite_vs90.vcproj index ab941c65d..5f9a968d7 100644 --- a/NetSSL_Win/testsuite/TestSuite_vs90.vcproj +++ b/NetSSL_Win/testsuite/TestSuite_vs90.vcproj @@ -532,6 +532,23 @@ RelativePath=".\src\HTTPSStreamFactoryTest.cpp"/> </Filter> </Filter> + <Filter + Name="WebSocket"> + <Filter + Name="Header Files"> + <File + RelativePath=".\src\WebSocketTest.h"/> + <File + RelativePath=".\src\WebSocketTestSuite.h"/> + </Filter> + <Filter + Name="Source Files"> + <File + RelativePath=".\src\WebSocketTest.cpp"/> + <File + RelativePath=".\src\WebSocketTestSuite.cpp"/> + </Filter> + </Filter> </Files> <Globals/> </VisualStudioProject> diff --git a/NetSSL_Win/testsuite/TestSuite_x64_vs100.vcxproj b/NetSSL_Win/testsuite/TestSuite_x64_vs100.vcxproj index 7e924fda7..f6bec29ea 100644 --- a/NetSSL_Win/testsuite/TestSuite_x64_vs100.vcxproj +++ b/NetSSL_Win/testsuite/TestSuite_x64_vs100.vcxproj @@ -321,6 +321,8 @@ <ClInclude Include="src\HTTPSClientSessionTest.h"/> <ClInclude Include="src\HTTPSClientTestSuite.h"/> <ClInclude Include="src\HTTPSStreamFactoryTest.h"/> + <ClInclude Include="src\WebSocketTest.h" /> + <ClInclude Include="src\WebSocketTestSuite.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="src\HTTPSTestServer.cpp"/> @@ -333,6 +335,8 @@ <ClCompile Include="src\HTTPSClientSessionTest.cpp"/> <ClCompile Include="src\HTTPSClientTestSuite.cpp"/> <ClCompile Include="src\HTTPSStreamFactoryTest.cpp"/> + <ClCompile Include="src\WebSocketTest.cpp" /> + <ClCompile Include="src\WebSocketTestSuite.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> <ImportGroup Label="ExtensionTargets"/> diff --git a/NetSSL_Win/testsuite/TestSuite_x64_vs110.vcxproj b/NetSSL_Win/testsuite/TestSuite_x64_vs110.vcxproj index ce11429b5..29ccd2bd3 100644 --- a/NetSSL_Win/testsuite/TestSuite_x64_vs110.vcxproj +++ b/NetSSL_Win/testsuite/TestSuite_x64_vs110.vcxproj @@ -321,6 +321,8 @@ <ClInclude Include="src\HTTPSClientSessionTest.h"/> <ClInclude Include="src\HTTPSClientTestSuite.h"/> <ClInclude Include="src\HTTPSStreamFactoryTest.h"/> + <ClInclude Include="src\WebSocketTest.h" /> + <ClInclude Include="src\WebSocketTestSuite.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="src\HTTPSTestServer.cpp"/> @@ -333,6 +335,8 @@ <ClCompile Include="src\HTTPSClientSessionTest.cpp"/> <ClCompile Include="src\HTTPSClientTestSuite.cpp"/> <ClCompile Include="src\HTTPSStreamFactoryTest.cpp"/> + <ClCompile Include="src\WebSocketTest.cpp" /> + <ClCompile Include="src\WebSocketTestSuite.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> <ImportGroup Label="ExtensionTargets"/> diff --git a/NetSSL_Win/testsuite/TestSuite_x64_vs120.vcxproj b/NetSSL_Win/testsuite/TestSuite_x64_vs120.vcxproj index c0539df28..20c95e0b3 100644 --- a/NetSSL_Win/testsuite/TestSuite_x64_vs120.vcxproj +++ b/NetSSL_Win/testsuite/TestSuite_x64_vs120.vcxproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="debug_shared|x64"> @@ -32,7 +32,7 @@ <RootNamespace>TestSuite</RootNamespace> <Keyword>Win32Proj</Keyword> </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>MultiByte</CharacterSet> @@ -63,27 +63,27 @@ <CharacterSet>MultiByte</CharacterSet> <PlatformToolset>v120</PlatformToolset> </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/> - <ImportGroup Label="ExtensionSettings"/> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings" /> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_md|x64'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_md|x64'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_static_mt|x64'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|x64'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='release_shared|x64'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'" Label="PropertySheets"> - <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/> + <Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" /> </ImportGroup> - <PropertyGroup Label="UserMacros"/> + <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion> <TargetName Condition="'$(Configuration)|$(Platform)'=='debug_shared|x64'">TestSuited</TargetName> @@ -136,7 +136,7 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <CompileAs>Default</CompileAs> @@ -167,9 +167,9 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat/> + <DebugInformationFormat /> <CompileAs>Default</CompileAs> </ClCompile> <Link> @@ -196,7 +196,7 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <CompileAs>Default</CompileAs> @@ -227,9 +227,9 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat/> + <DebugInformationFormat /> <CompileAs>Default</CompileAs> </ClCompile> <Link> @@ -256,7 +256,7 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <CompileAs>Default</CompileAs> @@ -287,9 +287,9 @@ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> <RuntimeTypeInfo>true</RuntimeTypeInfo> - <PrecompiledHeader/> + <PrecompiledHeader /> <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat/> + <DebugInformationFormat /> <CompileAs>Default</CompileAs> </ClCompile> <Link> @@ -304,28 +304,32 @@ </Link> </ItemDefinitionGroup> <ItemGroup> - <ClInclude Include="src\HTTPSClientSessionTest.h"/> - <ClInclude Include="src\HTTPSClientTestSuite.h"/> - <ClInclude Include="src\HTTPSServerTest.h"/> - <ClInclude Include="src\HTTPSServerTestSuite.h"/> - <ClInclude Include="src\HTTPSStreamFactoryTest.h"/> - <ClInclude Include="src\HTTPSTestServer.h"/> - <ClInclude Include="src\NetSSLTestSuite.h"/> - <ClInclude Include="src\TCPServerTest.h"/> - <ClInclude Include="src\TCPServerTestSuite.h"/> + <ClInclude Include="src\HTTPSClientSessionTest.h" /> + <ClInclude Include="src\HTTPSClientTestSuite.h" /> + <ClInclude Include="src\HTTPSServerTest.h" /> + <ClInclude Include="src\HTTPSServerTestSuite.h" /> + <ClInclude Include="src\HTTPSStreamFactoryTest.h" /> + <ClInclude Include="src\HTTPSTestServer.h" /> + <ClInclude Include="src\NetSSLTestSuite.h" /> + <ClInclude Include="src\TCPServerTest.h" /> + <ClInclude Include="src\TCPServerTestSuite.h" /> + <ClInclude Include="src\WebSocketTest.h" /> + <ClInclude Include="src\WebSocketTestSuite.h" /> </ItemGroup> <ItemGroup> - <ClCompile Include="src\Driver.cpp"/> - <ClCompile Include="src\HTTPSClientSessionTest.cpp"/> - <ClCompile Include="src\HTTPSClientTestSuite.cpp"/> - <ClCompile Include="src\HTTPSServerTest.cpp"/> - <ClCompile Include="src\HTTPSServerTestSuite.cpp"/> - <ClCompile Include="src\HTTPSStreamFactoryTest.cpp"/> - <ClCompile Include="src\HTTPSTestServer.cpp"/> - <ClCompile Include="src\NetSSLTestSuite.cpp"/> - <ClCompile Include="src\TCPServerTest.cpp"/> - <ClCompile Include="src\TCPServerTestSuite.cpp"/> + <ClCompile Include="src\Driver.cpp" /> + <ClCompile Include="src\HTTPSClientSessionTest.cpp" /> + <ClCompile Include="src\HTTPSClientTestSuite.cpp" /> + <ClCompile Include="src\HTTPSServerTest.cpp" /> + <ClCompile Include="src\HTTPSServerTestSuite.cpp" /> + <ClCompile Include="src\HTTPSStreamFactoryTest.cpp" /> + <ClCompile Include="src\HTTPSTestServer.cpp" /> + <ClCompile Include="src\NetSSLTestSuite.cpp" /> + <ClCompile Include="src\TCPServerTest.cpp" /> + <ClCompile Include="src\TCPServerTestSuite.cpp" /> + <ClCompile Include="src\WebSocketTest.cpp" /> + <ClCompile Include="src\WebSocketTestSuite.cpp" /> </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> - <ImportGroup Label="ExtensionTargets"/> -</Project> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets" /> +</Project> \ No newline at end of file diff --git a/NetSSL_Win/testsuite/TestSuite_x64_vs120.vcxproj.filters b/NetSSL_Win/testsuite/TestSuite_x64_vs120.vcxproj.filters index 69c90dee5..9de71608d 100644 --- a/NetSSL_Win/testsuite/TestSuite_x64_vs120.vcxproj.filters +++ b/NetSSL_Win/testsuite/TestSuite_x64_vs120.vcxproj.filters @@ -52,6 +52,9 @@ <Filter Include="HTTPSClient\Source Files"> <UniqueIdentifier>{363ebde9-9367-44b7-aa1b-dcb421bb759c}</UniqueIdentifier> </Filter> + <Filter Include="WebSocket"> + <UniqueIdentifier>{14c12fc4-d7e0-4311-a59e-f499f1993c3b}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> <ClInclude Include="src\HTTPSTestServer.h"> @@ -81,6 +84,12 @@ <ClInclude Include="src\HTTPSStreamFactoryTest.h"> <Filter>HTTPSClient\Header Files</Filter> </ClInclude> + <ClInclude Include="src\WebSocketTest.h"> + <Filter>WebSocket</Filter> + </ClInclude> + <ClInclude Include="src\WebSocketTestSuite.h"> + <Filter>WebSocket</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="src\HTTPSTestServer.cpp"> @@ -113,5 +122,11 @@ <ClCompile Include="src\HTTPSStreamFactoryTest.cpp"> <Filter>HTTPSClient\Source Files</Filter> </ClCompile> + <ClCompile Include="src\WebSocketTest.cpp"> + <Filter>WebSocket</Filter> + </ClCompile> + <ClCompile Include="src\WebSocketTestSuite.cpp"> + <Filter>WebSocket</Filter> + </ClCompile> </ItemGroup> </Project> \ No newline at end of file diff --git a/NetSSL_Win/testsuite/TestSuite_x64_vs140.vcxproj b/NetSSL_Win/testsuite/TestSuite_x64_vs140.vcxproj index 90138be0a..3d24283dc 100644 --- a/NetSSL_Win/testsuite/TestSuite_x64_vs140.vcxproj +++ b/NetSSL_Win/testsuite/TestSuite_x64_vs140.vcxproj @@ -313,6 +313,8 @@ <ClInclude Include="src\NetSSLTestSuite.h"/> <ClInclude Include="src\TCPServerTest.h"/> <ClInclude Include="src\TCPServerTestSuite.h"/> + <ClInclude Include="src\WebSocketTest.h" /> + <ClInclude Include="src\WebSocketTestSuite.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="src\Driver.cpp"/> @@ -325,6 +327,8 @@ <ClCompile Include="src\NetSSLTestSuite.cpp"/> <ClCompile Include="src\TCPServerTest.cpp"/> <ClCompile Include="src\TCPServerTestSuite.cpp"/> + <ClCompile Include="src\WebSocketTest.cpp" /> + <ClCompile Include="src\WebSocketTestSuite.cpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/> <ImportGroup Label="ExtensionTargets"/> diff --git a/NetSSL_Win/testsuite/TestSuite_x64_vs90.vcproj b/NetSSL_Win/testsuite/TestSuite_x64_vs90.vcproj index 473d7737d..1698914ec 100644 --- a/NetSSL_Win/testsuite/TestSuite_x64_vs90.vcproj +++ b/NetSSL_Win/testsuite/TestSuite_x64_vs90.vcproj @@ -532,6 +532,23 @@ RelativePath=".\src\HTTPSStreamFactoryTest.cpp"/> </Filter> </Filter> + <Filter + Name="WebSocket"> + <Filter + Name="Header Files"> + <File + RelativePath=".\src\WebSocketTest.h"/> + <File + RelativePath=".\src\WebSocketTestSuite.h"/> + </Filter> + <Filter + Name="Source Files"> + <File + RelativePath=".\src\WebSocketTest.cpp"/> + <File + RelativePath=".\src\WebSocketTestSuite.cpp"/> + </Filter> + </Filter> </Files> <Globals/> </VisualStudioProject> diff --git a/NetSSL_Win/testsuite/src/NetSSLTestSuite.cpp b/NetSSL_Win/testsuite/src/NetSSLTestSuite.cpp index 7fddff713..b2aa5303a 100644 --- a/NetSSL_Win/testsuite/src/NetSSLTestSuite.cpp +++ b/NetSSL_Win/testsuite/src/NetSSLTestSuite.cpp @@ -15,6 +15,7 @@ #include "HTTPSClientTestSuite.h" #include "TCPServerTestSuite.h" #include "HTTPSServerTestSuite.h" +#include "WebSocketTestSuite.h" CppUnit::Test* NetSSLTestSuite::suite() @@ -24,6 +25,7 @@ CppUnit::Test* NetSSLTestSuite::suite() pSuite->addTest(HTTPSClientTestSuite::suite()); pSuite->addTest(TCPServerTestSuite::suite()); pSuite->addTest(HTTPSServerTestSuite::suite()); + pSuite->addTest(WebSocketTestSuite::suite()); return pSuite; } diff --git a/NetSSL_Win/testsuite/src/WebSocketTest.cpp b/NetSSL_Win/testsuite/src/WebSocketTest.cpp new file mode 100644 index 000000000..1555d687b --- /dev/null +++ b/NetSSL_Win/testsuite/src/WebSocketTest.cpp @@ -0,0 +1,231 @@ +// +// WebSocketTest.cpp +// +// $Id: //poco/1.4/Net/testsuite/src/WebSocketTest.cpp#3 $ +// +// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "WebSocketTest.h" +#include "CppUnit/TestCaller.h" +#include "CppUnit/TestSuite.h" +#include "Poco/Net/WebSocket.h" +#include "Poco/Net/SocketStream.h" +#include "Poco/Net/HTTPSClientSession.h" +#include "Poco/Net/HTTPServer.h" +#include "Poco/Net/HTTPServerParams.h" +#include "Poco/Net/HTTPRequestHandler.h" +#include "Poco/Net/HTTPRequestHandlerFactory.h" +#include "Poco/Net/HTTPServerRequest.h" +#include "Poco/Net/HTTPServerResponse.h" +#include "Poco/Net/SecureServerSocket.h" +#include "Poco/Net/NetException.h" +#include "Poco/Thread.h" + + +using Poco::Net::HTTPSClientSession; +using Poco::Net::HTTPRequest; +using Poco::Net::HTTPResponse; +using Poco::Net::HTTPServerRequest; +using Poco::Net::HTTPServerResponse; +using Poco::Net::SocketStream; +using Poco::Net::WebSocket; +using Poco::Net::WebSocketException; + + +namespace +{ + class WebSocketRequestHandler: public Poco::Net::HTTPRequestHandler + { + public: + WebSocketRequestHandler(std::size_t bufSize = 1024): _bufSize(bufSize) + { + } + + void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) + { + try + { + WebSocket ws(request, response); + std::auto_ptr<char> pBuffer(new char[_bufSize]); + int flags; + int n; + do + { + n = ws.receiveFrame(pBuffer.get(), _bufSize, flags); + ws.sendFrame(pBuffer.get(), n, flags); + } + while (n > 0 || (flags & WebSocket::FRAME_OP_BITMASK) != WebSocket::FRAME_OP_CLOSE); + } + catch (WebSocketException& exc) + { + switch (exc.code()) + { + case WebSocket::WS_ERR_HANDSHAKE_UNSUPPORTED_VERSION: + response.set("Sec-WebSocket-Version", WebSocket::WEBSOCKET_VERSION); + // fallthrough + case WebSocket::WS_ERR_NO_HANDSHAKE: + case WebSocket::WS_ERR_HANDSHAKE_NO_VERSION: + case WebSocket::WS_ERR_HANDSHAKE_NO_KEY: + response.setStatusAndReason(HTTPResponse::HTTP_BAD_REQUEST); + response.setContentLength(0); + response.send(); + break; + } + } + } + + private: + std::size_t _bufSize; + }; + + class WebSocketRequestHandlerFactory: public Poco::Net::HTTPRequestHandlerFactory + { + public: + WebSocketRequestHandlerFactory(std::size_t bufSize = 1024): _bufSize(bufSize) + { + } + + Poco::Net::HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request) + { + return new WebSocketRequestHandler(_bufSize); + } + + private: + std::size_t _bufSize; + }; +} + + +WebSocketTest::WebSocketTest(const std::string& name): CppUnit::TestCase(name) +{ +} + + +WebSocketTest::~WebSocketTest() +{ +} + + +void WebSocketTest::testWebSocket() +{ + Poco::Net::SecureServerSocket ss(0); + Poco::Net::HTTPServer server(new WebSocketRequestHandlerFactory, ss, new Poco::Net::HTTPServerParams); + server.start(); + + Poco::Thread::sleep(200); + + HTTPSClientSession cs("localhost", ss.address().port()); + HTTPRequest request(HTTPRequest::HTTP_GET, "/ws"); + HTTPResponse response; + WebSocket ws(cs, request, response); + + std::string payload("x"); + ws.sendFrame(payload.data(), (int) payload.size()); + char buffer[1024]; + int flags; + int n = ws.receiveFrame(buffer, sizeof(buffer), flags); + assert (n == payload.size()); + assert (payload.compare(0, payload.size(), buffer, 0, n) == 0); + assert (flags == WebSocket::FRAME_TEXT); + + for (int i = 2; i < 20; i++) + { + payload.assign(i, 'x'); + ws.sendFrame(payload.data(), (int) payload.size()); + n = ws.receiveFrame(buffer, sizeof(buffer), flags); + assert (n == payload.size()); + assert (payload.compare(0, payload.size(), buffer, 0, n) == 0); + assert (flags == WebSocket::FRAME_TEXT); + } + + for (int i = 125; i < 129; i++) + { + payload.assign(i, 'x'); + ws.sendFrame(payload.data(), (int) payload.size()); + n = ws.receiveFrame(buffer, sizeof(buffer), flags); + assert (n == payload.size()); + assert (payload.compare(0, payload.size(), buffer, 0, n) == 0); + assert (flags == WebSocket::FRAME_TEXT); + } + + payload = "Hello, world!"; + ws.sendFrame(payload.data(), (int) payload.size()); + n = ws.receiveFrame(buffer, sizeof(buffer), flags); + assert (n == payload.size()); + assert (payload.compare(0, payload.size(), buffer, 0, n) == 0); + assert (flags == WebSocket::FRAME_TEXT); + + payload = "Hello, universe!"; + ws.sendFrame(payload.data(), (int) payload.size(), WebSocket::FRAME_BINARY); + n = ws.receiveFrame(buffer, sizeof(buffer), flags); + assert (n == payload.size()); + assert (payload.compare(0, payload.size(), buffer, 0, n) == 0); + assert (flags == WebSocket::FRAME_BINARY); + + ws.shutdown(); + n = ws.receiveFrame(buffer, sizeof(buffer), flags); + assert (n == 2); + assert ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE); + + server.stop(); +} + + +void WebSocketTest::testWebSocketLarge() +{ + const int msgSize = 64000; + + Poco::Net::SecureServerSocket ss(0); + Poco::Net::HTTPServer server(new WebSocketRequestHandlerFactory(msgSize), ss, new Poco::Net::HTTPServerParams); + server.start(); + + Poco::Thread::sleep(200); + + HTTPSClientSession cs("localhost", ss.address().port()); + HTTPRequest request(HTTPRequest::HTTP_GET, "/ws"); + HTTPResponse response; + WebSocket ws(cs, request, response); + ws.setSendBufferSize(msgSize); + ws.setReceiveBufferSize(msgSize); + std::string payload(msgSize, 'x'); + SocketStream sstr(ws); + sstr << payload; + sstr.flush(); + + char buffer[msgSize + 1]; + int flags; + int n = 0; + do + { + n += ws.receiveFrame(buffer + n, sizeof(buffer) - n, flags); + } while (n > 0 && n < msgSize); + + assert (n == payload.size()); + assert (payload.compare(0, payload.size(), buffer, 0, n) == 0); +} + + +void WebSocketTest::setUp() +{ +} + + +void WebSocketTest::tearDown() +{ +} + + +CppUnit::Test* WebSocketTest::suite() +{ + CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("WebSocketTest"); + + CppUnit_addTest(pSuite, WebSocketTest, testWebSocket); + CppUnit_addTest(pSuite, WebSocketTest, testWebSocketLarge); + + return pSuite; +} diff --git a/NetSSL_Win/testsuite/src/WebSocketTest.h b/NetSSL_Win/testsuite/src/WebSocketTest.h new file mode 100644 index 000000000..939acf630 --- /dev/null +++ b/NetSSL_Win/testsuite/src/WebSocketTest.h @@ -0,0 +1,41 @@ +// +// WebSocketTest.h +// +// $Id: //poco/1.4/Net/testsuite/src/WebSocketTest.h#1 $ +// +// Definition of the WebSocketTest class. +// +// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef WebSocketTest_INCLUDED +#define WebSocketTest_INCLUDED + + +#include "Poco/Net/Net.h" +#include "CppUnit/TestCase.h" + + +class WebSocketTest: public CppUnit::TestCase +{ +public: + WebSocketTest(const std::string& name); + ~WebSocketTest(); + + void testWebSocket(); + void testWebSocketLarge(); + + void setUp(); + void tearDown(); + + static CppUnit::Test* suite(); + +private: +}; + + +#endif // WebSocketTest_INCLUDED diff --git a/NetSSL_Win/testsuite/src/WebSocketTestSuite.cpp b/NetSSL_Win/testsuite/src/WebSocketTestSuite.cpp new file mode 100644 index 000000000..162eb38aa --- /dev/null +++ b/NetSSL_Win/testsuite/src/WebSocketTestSuite.cpp @@ -0,0 +1,24 @@ +// +// WebSocketTestSuite.cpp +// +// $Id: //poco/1.4/Net/testsuite/src/WebSocketTestSuite.cpp#1 $ +// +// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "WebSocketTestSuite.h" +#include "WebSocketTest.h" + + +CppUnit::Test* WebSocketTestSuite::suite() +{ + CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("WebSocketTestSuite"); + + pSuite->addTest(WebSocketTest::suite()); + + return pSuite; +} diff --git a/NetSSL_Win/testsuite/src/WebSocketTestSuite.h b/NetSSL_Win/testsuite/src/WebSocketTestSuite.h new file mode 100644 index 000000000..83b5dbb81 --- /dev/null +++ b/NetSSL_Win/testsuite/src/WebSocketTestSuite.h @@ -0,0 +1,29 @@ +// +// WebSocketTestSuite.h +// +// $Id: //poco/1.4/Net/testsuite/src/WebSocketTestSuite.h#1 $ +// +// Definition of the WebSocketTestSuite class. +// +// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef WebSocketTestSuite_INCLUDED +#define WebSocketTestSuite_INCLUDED + + +#include "CppUnit/TestSuite.h" + + +class WebSocketTestSuite +{ +public: + static CppUnit::Test* suite(); +}; + + +#endif // WebSocketTestSuite_INCLUDED diff --git a/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.cpp b/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.cpp index 3ec7a9bb7..ddd7a079e 100644 --- a/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.cpp +++ b/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.cpp @@ -1,10 +1,3 @@ -// -// TimeHandler.cpp -// -// This file has been generated from TimeHandler.cpsp on 2010-01-28 08:49:54. -// - - #include "TimeHandler.h" #include "Poco/Net/HTTPServerRequest.h" #include "Poco/Net/HTTPServerResponse.h" @@ -28,7 +21,7 @@ void TimeHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net responseStream << "\n"; responseStream << "\n"; responseStream << ""; -#line 6 "/ws/poco-1.3/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.cpsp" +#line 6 "/cygdrive/z/git/poco/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.cpsp" Poco::DateTime now; std::string dt(Poco::DateTimeFormatter::format(now, "%W, %e %b %y %H:%M:%S %Z")); @@ -40,7 +33,7 @@ void TimeHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net responseStream << "</head>\n"; responseStream << "<body>\n"; responseStream << "<p style=\"text-align: center; font-size: 48px;\">"; -#line 16 "/ws/poco-1.3/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.cpsp" +#line 16 "/cygdrive/z/git/poco/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.cpsp" responseStream << ( dt ); responseStream << "</p>\n"; responseStream << "</body>\n"; diff --git a/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.h b/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.h index e1ac5474d..c301516d0 100644 --- a/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.h +++ b/PageCompiler/samples/HTTPTimeServer/src/TimeHandler.h @@ -1,10 +1,3 @@ -// -// TimeHandler.h -// -// This file has been generated from TimeHandler.cpsp on 2010-01-28 08:49:54. -// - - #ifndef TimeHandler_INCLUDED #define TimeHandler_INCLUDED