mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 22:45:52 +00:00
Reorganize beast modules and files
This commit is contained in:
@@ -21,9 +21,18 @@
|
||||
<ItemGroup>
|
||||
<None Include="..\..\.gitattributes" />
|
||||
<None Include="..\..\.gitignore" />
|
||||
<None Include="..\..\beast\http\impl\http-parser\.gitignore" />
|
||||
<None Include="..\..\beast\http\impl\http-parser\.mailmap" />
|
||||
<None Include="..\..\beast\http\impl\http-parser\.travis.yml" />
|
||||
<None Include="..\..\beast\http\impl\http-parser\AUTHORS" />
|
||||
<None Include="..\..\beast\http\impl\http-parser\CONTRIBUTIONS" />
|
||||
<None Include="..\..\beast\http\impl\http-parser\http_parser.gyp" />
|
||||
<None Include="..\..\beast\http\impl\http-parser\LICENSE-MIT" />
|
||||
<None Include="..\..\beast\http\impl\http-parser\Makefile" />
|
||||
<None Include="..\..\beast\http\impl\http-parser\README.md" />
|
||||
<None Include="..\..\CodingStyle.md" />
|
||||
<None Include="..\..\Doxyfile" />
|
||||
<None Include="..\..\modules\beast_core\core.mm">
|
||||
<None Include="..\..\modules\beast_core\beast_core.mm">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
@@ -69,14 +78,27 @@
|
||||
<None Include="..\..\README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\beast\Arithmetic.h" />
|
||||
<ClInclude Include="..\..\beast\Atomic.h" />
|
||||
<ClInclude Include="..\..\beast\ByteOrder.h" />
|
||||
<ClInclude Include="..\..\beast\Config.h" />
|
||||
<ClInclude Include="..\..\beast\config\CompilerConfig.h" />
|
||||
<ClInclude Include="..\..\beast\config\ConfigCheck.h" />
|
||||
<ClInclude Include="..\..\beast\config\ContractChecks.h" />
|
||||
<ClInclude Include="..\..\beast\config\PlatformConfig.h" />
|
||||
<ClInclude Include="..\..\beast\config\StandardConfig.h" />
|
||||
<ClInclude Include="..\..\beast\CStdInt.h" />
|
||||
<ClInclude Include="..\..\beast\HeapBlock.h" />
|
||||
<ClInclude Include="..\..\beast\HTTP.h" />
|
||||
<ClInclude Include="..\..\beast\http\impl\http-parser\http_parser.h" />
|
||||
<ClInclude Include="..\..\beast\http\ParsedURL.h" />
|
||||
<ClInclude Include="..\..\beast\http\URL.h" />
|
||||
<ClInclude Include="..\..\beast\Intrusive.h" />
|
||||
<ClInclude Include="..\..\beast\intrusive\ForwardList.h" />
|
||||
<ClInclude Include="..\..\beast\intrusive\List.h" />
|
||||
<ClInclude Include="..\..\beast\intrusive\LockFreeStack.h" />
|
||||
<ClInclude Include="..\..\beast\intrusive\PointerTraits.h" />
|
||||
<ClInclude Include="..\..\beast\Memory.h" />
|
||||
<ClInclude Include="..\..\beast\MPL.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\AddConst.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\CopyConst.h" />
|
||||
@@ -90,6 +112,16 @@
|
||||
<ClInclude Include="..\..\beast\Net.h" />
|
||||
<ClInclude Include="..\..\beast\net\IPEndpoint.h" />
|
||||
<ClInclude Include="..\..\beast\StaticAssert.h" />
|
||||
<ClInclude Include="..\..\beast\Strings.h" />
|
||||
<ClInclude Include="..\..\beast\strings\CharacterFunctions.h" />
|
||||
<ClInclude Include="..\..\beast\strings\CharPointer_ASCII.h" />
|
||||
<ClInclude Include="..\..\beast\strings\CharPointer_UTF16.h" />
|
||||
<ClInclude Include="..\..\beast\strings\CharPointer_UTF32.h" />
|
||||
<ClInclude Include="..\..\beast\strings\CharPointer_UTF8.h" />
|
||||
<ClInclude Include="..\..\beast\strings\NewLine.h" />
|
||||
<ClInclude Include="..\..\beast\strings\String.h" />
|
||||
<ClInclude Include="..\..\beast\strings\StringCharPointerType.h" />
|
||||
<ClInclude Include="..\..\beast\strings\StringFromNumber.h" />
|
||||
<ClInclude Include="..\..\beast\Thread.h" />
|
||||
<ClInclude Include="..\..\beast\thread\LockGuard.h" />
|
||||
<ClInclude Include="..\..\beast\thread\SharedData.h" />
|
||||
@@ -104,6 +136,7 @@
|
||||
<ClInclude Include="..\..\beast\Utility.h" />
|
||||
<ClInclude Include="..\..\beast\utility\EnableIf.h" />
|
||||
<ClInclude Include="..\..\beast\utility\Journal.h" />
|
||||
<ClInclude Include="..\..\beast\Version.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\async\AsyncObject.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\async\ComposedAsyncOperation.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\async\SharedHandler.h" />
|
||||
@@ -127,8 +160,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_asio\http\HTTPRequest.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\http\HTTPResponse.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\http\HTTPVersion.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\http\UniformResourceLocator.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\parsehttp\http_parser.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\protocol\HandshakeDetectLogic.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\protocol\HandshakeDetectLogicPROXY.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\protocol\HandshakeDetectLogicSSL2.h" />
|
||||
@@ -186,7 +217,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\Throw.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\UnitTest.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\UnitTestUtilities.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\ContractChecks.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\MeasureFunctionCallTime.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\files\DirectoryIterator.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\files\File.h" />
|
||||
@@ -203,7 +233,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Expression.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Interval.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Math.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\MathsFunctions.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\MurmurHash.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Random.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Range.h" />
|
||||
@@ -213,8 +242,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\AtomicFlag.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\AtomicPointer.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\AtomicState.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\ByteOrder.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\ByteSwap.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\CacheLine.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\ContainerDeletePolicy.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\FifoFreeStore.h" />
|
||||
@@ -222,8 +249,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\FifoFreeStoreWithTLS.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\GlobalFifoFreeStore.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\GlobalPagedFreeStore.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\HeapBlock.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\Memory.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\MemoryAlignment.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\MemoryBlock.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\OptionalScopedPointer.h" />
|
||||
@@ -249,7 +274,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\network\MACAddress.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\network\NamedPipe.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\network\Socket.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\network\URL.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\streams\BufferedInputStream.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\streams\FileInputSource.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\streams\InputSource.h" />
|
||||
@@ -258,31 +282,20 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\streams\MemoryOutputStream.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\streams\OutputStream.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\streams\SubregionStream.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\system\BeastConfigCheck.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\system\Functional.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\system\PlatformDefs.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\system\StandardHeader.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\system\StandardIncludes.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\system\SystemStats.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\system\BeforeBoost.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\system\BoostIncludes.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\system\BoostPlaceholdersFix.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\system\FunctionalIncludes.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\CharacterFunctions.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\CharPointer_ASCII.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\CharPointer_UTF16.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\CharPointer_UTF32.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\CharPointer_UTF8.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\Identifier.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\LexicalCast.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\LocalisedStrings.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\NewLine.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\String.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\StringArray.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\StringPairArray.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\StringPool.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\TextDiff.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\StringCharPointerType.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\text\StringFromNumber.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\threads\ChildProcess.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\threads\CriticalSection.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\threads\DynamicLibrary.h" />
|
||||
@@ -371,6 +384,49 @@
|
||||
<ClInclude Include="BeastConfig.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\beast\http\HTTP.cpp" />
|
||||
<ClCompile Include="..\..\beast\http\impl\http_parser.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\http-parser\contrib\parsertrace.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\http-parser\contrib\url_parser.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\http-parser\http_parser.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\http-parser\test.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\ParsedURL.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\URL.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\net\impl\IPEndpoint.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -378,6 +434,19 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\net\Net.cpp" />
|
||||
<ClCompile Include="..\..\beast\strings\impl\CharacterFunctions.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\strings\impl\String.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\strings\Strings.cpp" />
|
||||
<ClCompile Include="..\..\beast\utility\impl\Journal.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -456,18 +525,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_asio\http\UniformResourceLocator.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_asio\parsehttp\http_parser.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_asio\protocol\HandshakeDetectLogicPROXY.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -941,12 +998,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\network\URL.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\streams\BufferedInputStream.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
@@ -1001,12 +1052,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\text\CharacterFunctions.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\text\Identifier.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
@@ -1025,12 +1070,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\text\String.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\text\StringArray.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<None Include="..\..\modules\beast_core\core.mm">
|
||||
<Filter>beast_core</Filter>
|
||||
</None>
|
||||
<None Include="..\..\modules\beast_core\native\mac_Files.mm">
|
||||
<Filter>beast_core\native</Filter>
|
||||
</None>
|
||||
@@ -40,6 +37,36 @@
|
||||
<None Include="..\..\README.md">
|
||||
<Filter>_meta</Filter>
|
||||
</None>
|
||||
<None Include="..\..\beast\http\impl\http-parser\.gitignore">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</None>
|
||||
<None Include="..\..\beast\http\impl\http-parser\.mailmap">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</None>
|
||||
<None Include="..\..\beast\http\impl\http-parser\.travis.yml">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</None>
|
||||
<None Include="..\..\beast\http\impl\http-parser\AUTHORS">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</None>
|
||||
<None Include="..\..\beast\http\impl\http-parser\CONTRIBUTIONS">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</None>
|
||||
<None Include="..\..\beast\http\impl\http-parser\http_parser.gyp">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</None>
|
||||
<None Include="..\..\beast\http\impl\http-parser\LICENSE-MIT">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</None>
|
||||
<None Include="..\..\beast\http\impl\http-parser\Makefile">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</None>
|
||||
<None Include="..\..\beast\http\impl\http-parser\README.md">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</None>
|
||||
<None Include="..\..\modules\beast_core\beast_core.mm">
|
||||
<Filter>beast_core</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="beast_core">
|
||||
@@ -174,9 +201,6 @@
|
||||
<Filter Include="beast\mpl">
|
||||
<UniqueIdentifier>{5904368f-a0f2-4d26-a031-8cbe4448dc3f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast_asio\parsehttp">
|
||||
<UniqueIdentifier>{ac367054-ddbf-4118-a41a-07bea34d32c8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast_asio\protocol">
|
||||
<UniqueIdentifier>{c0724499-ab69-40c3-90e2-65242dbd2eaa}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -204,6 +228,27 @@
|
||||
<Filter Include="beast\thread">
|
||||
<UniqueIdentifier>{da8084c0-491b-4eb0-b750-97182a9deed4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast\http">
|
||||
<UniqueIdentifier>{56ef157f-ad92-4da7-8fbf-00723f769732}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast\http\impl">
|
||||
<UniqueIdentifier>{565f012b-42b7-42c9-81b7-9e93aa378000}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast\http\impl\http-parser">
|
||||
<UniqueIdentifier>{7eead15d-f9dc-4b4d-a653-57d9c090e697}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast\http\impl\http-parser\contrib">
|
||||
<UniqueIdentifier>{233e3c4d-e398-4c11-a42c-3483107eb8e9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast\strings">
|
||||
<UniqueIdentifier>{8d80e304-a42d-411a-9528-811eddff3191}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast\strings\impl">
|
||||
<UniqueIdentifier>{eabf472c-e198-409a-a65b-7c087ae911d0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast\config">
|
||||
<UniqueIdentifier>{1fff3bd8-44ae-41df-8dd4-8bb6f07b2908}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\modules\beast_core\beast_core.h">
|
||||
@@ -284,24 +329,12 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Expression.h">
|
||||
<Filter>beast_core\maths</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\MathsFunctions.h">
|
||||
<Filter>beast_core\maths</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Random.h">
|
||||
<Filter>beast_core\maths</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\Range.h">
|
||||
<Filter>beast_core\maths</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\ByteOrder.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\HeapBlock.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\Memory.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\MemoryBlock.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
@@ -350,9 +383,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\network\Socket.h">
|
||||
<Filter>beast_core\network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\network\URL.h">
|
||||
<Filter>beast_core\network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\streams\BufferedInputStream.h">
|
||||
<Filter>beast_core\streams</Filter>
|
||||
</ClInclude>
|
||||
@@ -377,33 +407,12 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\streams\SubregionStream.h">
|
||||
<Filter>beast_core\streams</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\CharacterFunctions.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\CharPointer_ASCII.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\CharPointer_UTF8.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\CharPointer_UTF16.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\CharPointer_UTF32.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\Identifier.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\LocalisedStrings.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\NewLine.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\String.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\StringArray.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
@@ -678,9 +687,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\maths\uint24.h">
|
||||
<Filter>beast_core\maths</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\ByteSwap.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\ContainerDeletePolicy.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
@@ -786,18 +792,9 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\system\BoostIncludes.h">
|
||||
<Filter>beast_core\system</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\system\BeastConfigCheck.h">
|
||||
<Filter>beast_core\system</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\system\FunctionalIncludes.h">
|
||||
<Filter>beast_core\system</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\system\StandardHeader.h">
|
||||
<Filter>beast_core\system</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\system\PlatformDefs.h">
|
||||
<Filter>beast_core\system</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\system\Functional.h">
|
||||
<Filter>beast_core\system</Filter>
|
||||
</ClInclude>
|
||||
@@ -813,12 +810,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\containers\HashMap.h">
|
||||
<Filter>beast_core\containers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\StringCharPointerType.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\text\StringFromNumber.h">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\intrusive\ForwardList.h">
|
||||
<Filter>beast\intrusive</Filter>
|
||||
</ClInclude>
|
||||
@@ -849,12 +840,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\SharedObject.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\ContractChecks.h">
|
||||
<Filter>beast_core\diagnostic</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_asio\parsehttp\http_parser.h">
|
||||
<Filter>beast_asio\parsehttp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_asio\async\ComposedAsyncOperation.h">
|
||||
<Filter>beast_asio\async</Filter>
|
||||
</ClInclude>
|
||||
@@ -972,9 +957,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_asio\http\HTTPParserImpl.h">
|
||||
<Filter>beast_asio\http</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_asio\http\UniformResourceLocator.h">
|
||||
<Filter>beast_asio\http</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\mpl\IfCond.h">
|
||||
<Filter>beast\mpl</Filter>
|
||||
</ClInclude>
|
||||
@@ -1047,9 +1029,6 @@
|
||||
<ClInclude Include="..\..\beast\utility\EnableIf.h">
|
||||
<Filter>beast\utility</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\StaticAssert.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\utility\Journal.h">
|
||||
<Filter>beast\utility</Filter>
|
||||
</ClInclude>
|
||||
@@ -1104,6 +1083,84 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\thread\Stoppable.h">
|
||||
<Filter>beast_core\thread</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\http\impl\http-parser\http_parser.h">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\HTTP.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\strings\CharacterFunctions.h">
|
||||
<Filter>beast\strings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\strings\CharPointer_ASCII.h">
|
||||
<Filter>beast\strings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\strings\CharPointer_UTF8.h">
|
||||
<Filter>beast\strings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\strings\CharPointer_UTF16.h">
|
||||
<Filter>beast\strings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\strings\CharPointer_UTF32.h">
|
||||
<Filter>beast\strings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\strings\NewLine.h">
|
||||
<Filter>beast\strings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\strings\String.h">
|
||||
<Filter>beast\strings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\strings\StringCharPointerType.h">
|
||||
<Filter>beast\strings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\strings\StringFromNumber.h">
|
||||
<Filter>beast\strings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\Strings.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\config\CompilerConfig.h">
|
||||
<Filter>beast\config</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\config\PlatformConfig.h">
|
||||
<Filter>beast\config</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\config\StandardConfig.h">
|
||||
<Filter>beast\config</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\Version.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\config\ConfigCheck.h">
|
||||
<Filter>beast\config</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\config\ContractChecks.h">
|
||||
<Filter>beast\config</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\StaticAssert.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\Arithmetic.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\Memory.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\ByteOrder.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\HeapBlock.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\system\StandardIncludes.h">
|
||||
<Filter>beast_core\system</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\http\URL.h">
|
||||
<Filter>beast\http</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\http\ParsedURL.h">
|
||||
<Filter>beast\http</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\modules\beast_core\containers\AbstractFifo.cpp">
|
||||
@@ -1223,9 +1280,6 @@
|
||||
<ClCompile Include="..\..\modules\beast_core\network\Socket.cpp">
|
||||
<Filter>beast_core\network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\network\URL.cpp">
|
||||
<Filter>beast_core\network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\streams\BufferedInputStream.cpp">
|
||||
<Filter>beast_core\streams</Filter>
|
||||
</ClCompile>
|
||||
@@ -1247,18 +1301,12 @@
|
||||
<ClCompile Include="..\..\modules\beast_core\streams\SubregionStream.cpp">
|
||||
<Filter>beast_core\streams</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\text\CharacterFunctions.cpp">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\text\Identifier.cpp">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\text\LocalisedStrings.cpp">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\text\String.cpp">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\text\StringArray.cpp">
|
||||
<Filter>beast_core\text</Filter>
|
||||
</ClCompile>
|
||||
@@ -1508,9 +1556,6 @@
|
||||
<ClCompile Include="..\..\modules\beast_core\containers\HashMap.cpp">
|
||||
<Filter>beast_core\containers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_asio\parsehttp\http_parser.c">
|
||||
<Filter>beast_asio\parsehttp</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_asio\async\SharedHandler.cpp">
|
||||
<Filter>beast_asio\async</Filter>
|
||||
</ClCompile>
|
||||
@@ -1580,9 +1625,6 @@
|
||||
<ClCompile Include="..\..\modules\beast_asio\http\HTTPParser.cpp">
|
||||
<Filter>beast_asio\http</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_asio\http\UniformResourceLocator.cpp">
|
||||
<Filter>beast_asio\http</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_crypto\beast_crypto.cpp">
|
||||
<Filter>beast_crypto</Filter>
|
||||
</ClCompile>
|
||||
@@ -1637,6 +1679,39 @@
|
||||
<ClCompile Include="..\..\modules\beast_core\thread\Stoppable.cpp">
|
||||
<Filter>beast_core\thread</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\http-parser\http_parser.c">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\http-parser\test.c">
|
||||
<Filter>beast\http\impl\http-parser</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\http-parser\contrib\parsertrace.c">
|
||||
<Filter>beast\http\impl\http-parser\contrib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\http-parser\contrib\url_parser.c">
|
||||
<Filter>beast\http\impl\http-parser\contrib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\HTTP.cpp">
|
||||
<Filter>beast\http</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\http_parser.cpp">
|
||||
<Filter>beast\http\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\strings\impl\CharacterFunctions.cpp">
|
||||
<Filter>beast\strings\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\strings\impl\String.cpp">
|
||||
<Filter>beast\strings\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\strings\Strings.cpp">
|
||||
<Filter>beast\strings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\URL.cpp">
|
||||
<Filter>beast\http\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\http\impl\ParsedURL.cpp">
|
||||
<Filter>beast\http\impl</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\..\TODO.txt">
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_MATHSFUNCTIONS_H_INCLUDED
|
||||
#define BEAST_MATHSFUNCTIONS_H_INCLUDED
|
||||
#ifndef BEAST_ARITHMETIC_H_INCLUDED
|
||||
#define BEAST_ARITHMETIC_H_INCLUDED
|
||||
|
||||
namespace beast {
|
||||
|
||||
//==============================================================================
|
||||
// Some indispensible min/max functions
|
||||
|
||||
/** Returns the larger of two values. */
|
||||
@@ -199,7 +200,7 @@ inline void swapVariables (Type& variable1, Type& variable2)
|
||||
@endcode
|
||||
*/
|
||||
template <typename Type, int N>
|
||||
inline int numElementsInArray (Type (&array)[N])
|
||||
int numElementsInArray (Type (&array)[N])
|
||||
{
|
||||
(void) array; // (required to avoid a spurious warning in MS compilers)
|
||||
(void) sizeof (0[array]); // This line should cause an error if you pass an object with a user-defined subscript operator
|
||||
@@ -440,7 +441,7 @@ namespace TypeHelpers
|
||||
template <> struct SmallestFloatType <double> { typedef double type; };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
#endif
|
||||
|
||||
#endif // BEAST_MATHSFUNCTIONS_H_INCLUDED
|
||||
@@ -24,6 +24,9 @@
|
||||
#ifndef BEAST_ATOMIC_H_INCLUDED
|
||||
#define BEAST_ATOMIC_H_INCLUDED
|
||||
|
||||
#include "Config.h"
|
||||
#include "StaticAssert.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
#ifndef BEAST_BYTEORDER_H_INCLUDED
|
||||
#define BEAST_BYTEORDER_H_INCLUDED
|
||||
|
||||
#include "Uncopyable.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
//==============================================================================
|
||||
/** Contains static methods for converting the byte order between different
|
||||
endiannesses.
|
||||
@@ -182,5 +186,109 @@ inline int ByteOrder::bigEndian24Bit (const char* const bytes)
|
||||
inline void ByteOrder::littleEndian24BitToChars (const int value, char* const destBytes) { destBytes[0] = (char)(value & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)((value >> 16) & 0xff); }
|
||||
inline void ByteOrder::bigEndian24BitToChars (const int value, char* const destBytes) { destBytes[0] = (char)((value >> 16) & 0xff); destBytes[1] = (char)((value >> 8) & 0xff); destBytes[2] = (char)(value & 0xff); }
|
||||
|
||||
#endif
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/** Specialized helper class template for swapping bytes.
|
||||
|
||||
Normally you won't use this directly, use the helper function
|
||||
byteSwap instead. You can specialize this class for your
|
||||
own user defined types, as was done for uint24.
|
||||
|
||||
@see swapBytes, uint24
|
||||
*/
|
||||
template <typename IntegralType>
|
||||
struct SwapBytes
|
||||
{
|
||||
inline IntegralType operator() (IntegralType value) const noexcept
|
||||
{
|
||||
return ByteOrder::swap (value);
|
||||
}
|
||||
};
|
||||
|
||||
// Specializations for signed integers
|
||||
|
||||
template <>
|
||||
struct SwapBytes <int16>
|
||||
{
|
||||
inline int16 operator() (int16 value) const noexcept
|
||||
{
|
||||
return static_cast <int16> (ByteOrder::swap (static_cast <uint16> (value)));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct SwapBytes <int32>
|
||||
{
|
||||
inline int32 operator() (int32 value) const noexcept
|
||||
{
|
||||
return static_cast <int32> (ByteOrder::swap (static_cast <uint32> (value)));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct SwapBytes <int64>
|
||||
{
|
||||
inline int64 operator() (int64 value) const noexcept
|
||||
{
|
||||
return static_cast <int64> (ByteOrder::swap (static_cast <uint64> (value)));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Returns a type with the bytes swapped.
|
||||
Little endian becomes big endian and vice versa. The underlying
|
||||
type must be an integral type or behave like one.
|
||||
*/
|
||||
template <class IntegralType>
|
||||
inline IntegralType swapBytes (IntegralType value) noexcept
|
||||
{
|
||||
return detail::SwapBytes <IntegralType> () (value);
|
||||
}
|
||||
|
||||
/** Returns the machine byte-order value to little-endian byte order. */
|
||||
template <typename IntegralType>
|
||||
inline IntegralType toLittleEndian (IntegralType value) noexcept
|
||||
{
|
||||
#if BEAST_LITTLE_ENDIAN
|
||||
return value;
|
||||
#else
|
||||
return swapBytes (value);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Returns the machine byte-order value to big-endian byte order. */
|
||||
template <typename IntegralType>
|
||||
inline IntegralType toBigEndian (IntegralType value) noexcept
|
||||
{
|
||||
#if BEAST_LITTLE_ENDIAN
|
||||
return swapBytes (value);
|
||||
#else
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Returns the machine byte-order value to network byte order. */
|
||||
template <typename IntegralType>
|
||||
inline IntegralType toNetworkByteOrder (IntegralType value) noexcept
|
||||
{
|
||||
return toBigEndian (value);
|
||||
}
|
||||
|
||||
/** Converts from network byte order to machine byte order. */
|
||||
template <typename IntegralType>
|
||||
inline IntegralType fromNetworkByteOrder (IntegralType value) noexcept
|
||||
{
|
||||
#if BEAST_LITTLE_ENDIAN
|
||||
return swapBytes (value);
|
||||
#else
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -26,194 +26,10 @@
|
||||
|
||||
// VFALCO NOTE this is analogous to <boost/config.hpp>
|
||||
|
||||
//==============================================================================
|
||||
/* This file figures out which platform is being built, and defines some macros
|
||||
that the rest of the code can use for OS-specific compilation.
|
||||
|
||||
Macros that will be set here are:
|
||||
|
||||
- One of BEAST_WINDOWS, BEAST_MAC BEAST_LINUX, BEAST_IOS, BEAST_ANDROID, etc.
|
||||
- Either BEAST_32BIT or BEAST_64BIT, depending on the architecture.
|
||||
- Either BEAST_LITTLE_ENDIAN or BEAST_BIG_ENDIAN.
|
||||
- Either BEAST_INTEL or BEAST_PPC
|
||||
- Either BEAST_GCC or BEAST_MSVC
|
||||
*/
|
||||
|
||||
//==============================================================================
|
||||
#if (defined (_WIN32) || defined (_WIN64))
|
||||
#define BEAST_WIN32 1
|
||||
#define BEAST_WINDOWS 1
|
||||
#elif defined (BEAST_ANDROID)
|
||||
#undef BEAST_ANDROID
|
||||
#define BEAST_ANDROID 1
|
||||
#elif defined (LINUX) || defined (__linux__)
|
||||
#define BEAST_LINUX 1
|
||||
#elif defined (__APPLE_CPP__) || defined(__APPLE_CC__)
|
||||
#define Point CarbonDummyPointName // (workaround to avoid definition of "Point" by old Carbon headers)
|
||||
#define Component CarbonDummyCompName
|
||||
#include <CoreFoundation/CoreFoundation.h> // (needed to find out what platform we're using)
|
||||
#undef Point
|
||||
#undef Component
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#define BEAST_IPHONE 1
|
||||
#define BEAST_IOS 1
|
||||
#else
|
||||
#define BEAST_MAC 1
|
||||
#endif
|
||||
#elif defined (__FreeBSD__)
|
||||
#define BEAST_BSD 1
|
||||
#else
|
||||
#error "Unknown platform!"
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if BEAST_WINDOWS
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN64
|
||||
#define BEAST_64BIT 1
|
||||
#else
|
||||
#define BEAST_32BIT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define BEAST_DEBUG 1
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#define BEAST_MINGW 1
|
||||
#ifdef __MINGW64__
|
||||
#define BEAST_64BIT 1
|
||||
#else
|
||||
#define BEAST_32BIT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** If defined, this indicates that the processor is little-endian. */
|
||||
#define BEAST_LITTLE_ENDIAN 1
|
||||
|
||||
#define BEAST_INTEL 1
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if BEAST_MAC || BEAST_IOS
|
||||
|
||||
#if defined (DEBUG) || defined (_DEBUG) || ! (defined (NDEBUG) || defined (_NDEBUG))
|
||||
#define BEAST_DEBUG 1
|
||||
#endif
|
||||
|
||||
#if ! (defined (DEBUG) || defined (_DEBUG) || defined (NDEBUG) || defined (_NDEBUG))
|
||||
#warning "Neither NDEBUG or DEBUG has been defined - you should set one of these to make it clear whether this is a release build,"
|
||||
#endif
|
||||
|
||||
#ifdef __LITTLE_ENDIAN__
|
||||
#define BEAST_LITTLE_ENDIAN 1
|
||||
#else
|
||||
#define BEAST_BIG_ENDIAN 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BEAST_MAC
|
||||
|
||||
#if defined (__ppc__) || defined (__ppc64__)
|
||||
#define BEAST_PPC 1
|
||||
#elif defined (__arm__)
|
||||
#define BEAST_ARM 1
|
||||
#else
|
||||
#define BEAST_INTEL 1
|
||||
#endif
|
||||
|
||||
#ifdef __LP64__
|
||||
#define BEAST_64BIT 1
|
||||
#else
|
||||
#define BEAST_32BIT 1
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4
|
||||
#error "Building for OSX 10.3 is no longer supported!"
|
||||
#endif
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_5
|
||||
#error "To build with 10.4 compatibility, use a 10.5 or 10.6 SDK and set the deployment target to 10.4"
|
||||
#endif
|
||||
#include "Version.h"
|
||||
#include "config/PlatformConfig.h"
|
||||
#include "config/CompilerConfig.h"
|
||||
#include "config/StandardConfig.h"
|
||||
#include "config/ConfigCheck.h"
|
||||
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if BEAST_LINUX || BEAST_ANDROID || BEAST_BSD
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define BEAST_DEBUG 1
|
||||
#endif
|
||||
|
||||
// Allow override for big-endian Linux platforms
|
||||
#if defined (__LITTLE_ENDIAN__) || ! defined (BEAST_BIG_ENDIAN)
|
||||
#define BEAST_LITTLE_ENDIAN 1
|
||||
#undef BEAST_BIG_ENDIAN
|
||||
#else
|
||||
#undef BEAST_LITTLE_ENDIAN
|
||||
#define BEAST_BIG_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#if defined (__LP64__) || defined (_LP64)
|
||||
#define BEAST_64BIT 1
|
||||
#else
|
||||
#define BEAST_32BIT 1
|
||||
#endif
|
||||
|
||||
#if __MMX__ || __SSE__ || __amd64__
|
||||
#ifdef __arm__
|
||||
#define BEAST_ARM 1
|
||||
#else
|
||||
#define BEAST_INTEL 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
// Compiler type macros.
|
||||
|
||||
#ifdef __clang__
|
||||
#define BEAST_CLANG 1
|
||||
#define BEAST_GCC 1
|
||||
#elif defined (__GNUC__)
|
||||
#define BEAST_GCC 1
|
||||
#elif defined (_MSC_VER)
|
||||
#define BEAST_MSVC 1
|
||||
|
||||
#if _MSC_VER < 1500
|
||||
#define BEAST_VC8_OR_EARLIER 1
|
||||
|
||||
#if _MSC_VER < 1400
|
||||
#define BEAST_VC7_OR_EARLIER 1
|
||||
|
||||
#if _MSC_VER < 1300
|
||||
#warning "MSVC 6.0 is no longer supported!"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BEAST_64BIT || ! BEAST_VC7_OR_EARLIER
|
||||
#define BEAST_USE_INTRINSICS 1
|
||||
#endif
|
||||
#else
|
||||
#error unknown compiler
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Handy macro that lets pragma warnings be clicked in the output window
|
||||
//
|
||||
// Usage: #pragma message(BEAST_FILEANDLINE_ "Advertise here!")
|
||||
//
|
||||
// Note that a space following the macro is mandatory for C++11.
|
||||
//
|
||||
// This is here so it can be used in C compilations that include this directly.
|
||||
//
|
||||
#define BEAST_PP_STR2_(x) #x
|
||||
#define BEAST_PP_STR1_(x) BEAST_PP_STR2_(x)
|
||||
#define BEAST_FILEANDLINE_ __FILE__ "(" BEAST_PP_STR1_(__LINE__) "): warning:"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
26
src/beast/beast/HTTP.h
Normal file
26
src/beast/beast/HTTP.h
Normal file
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_HTTP_H_INCLUDED
|
||||
#define BEAST_HTTP_H_INCLUDED
|
||||
|
||||
#include "http/URL.h"
|
||||
#include "http/ParsedURL.h"
|
||||
|
||||
#endif
|
||||
@@ -24,6 +24,42 @@
|
||||
#ifndef BEAST_HEAPBLOCK_H_INCLUDED
|
||||
#define BEAST_HEAPBLOCK_H_INCLUDED
|
||||
|
||||
#include "Memory.h"
|
||||
#include "Uncopyable.h"
|
||||
|
||||
// If the MSVC debug heap headers were included, disable
|
||||
// the macros during the juce include since they conflict.
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
#pragma push_macro("calloc")
|
||||
#pragma push_macro("free")
|
||||
#pragma push_macro("malloc")
|
||||
#pragma push_macro("realloc")
|
||||
#pragma push_macro("_recalloc")
|
||||
#pragma push_macro("_aligned_free")
|
||||
#pragma push_macro("_aligned_malloc")
|
||||
#pragma push_macro("_aligned_offset_malloc")
|
||||
#pragma push_macro("_aligned_realloc")
|
||||
#pragma push_macro("_aligned_recalloc")
|
||||
#pragma push_macro("_aligned_offset_realloc")
|
||||
#pragma push_macro("_aligned_offset_recalloc")
|
||||
#pragma push_macro("_aligned_msize")
|
||||
#undef calloc
|
||||
#undef free
|
||||
#undef malloc
|
||||
#undef realloc
|
||||
#undef _recalloc
|
||||
#undef _aligned_free
|
||||
#undef _aligned_malloc
|
||||
#undef _aligned_offset_malloc
|
||||
#undef _aligned_realloc
|
||||
#undef _aligned_recalloc
|
||||
#undef _aligned_offset_realloc
|
||||
#undef _aligned_offset_recalloc
|
||||
#undef _aligned_msize
|
||||
#endif
|
||||
|
||||
namespace beast {
|
||||
|
||||
#ifndef DOXYGEN
|
||||
namespace HeapBlockHelper
|
||||
{
|
||||
@@ -305,5 +341,23 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
#pragma pop_macro("_aligned_msize")
|
||||
#pragma pop_macro("_aligned_offset_recalloc")
|
||||
#pragma pop_macro("_aligned_offset_realloc")
|
||||
#pragma pop_macro("_aligned_recalloc")
|
||||
#pragma pop_macro("_aligned_realloc")
|
||||
#pragma pop_macro("_aligned_offset_malloc")
|
||||
#pragma pop_macro("_aligned_malloc")
|
||||
#pragma pop_macro("_aligned_free")
|
||||
#pragma pop_macro("_recalloc")
|
||||
#pragma pop_macro("realloc")
|
||||
#pragma pop_macro("malloc")
|
||||
#pragma pop_macro("free")
|
||||
#pragma pop_macro("calloc")
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BEAST_HEAPBLOCK_H_INCLUDED
|
||||
@@ -24,6 +24,8 @@
|
||||
#ifndef BEAST_MEMORY_H_INCLUDED
|
||||
#define BEAST_MEMORY_H_INCLUDED
|
||||
|
||||
namespace beast {
|
||||
|
||||
//==============================================================================
|
||||
/** Fills a block of memory with zeros. */
|
||||
inline void zeromem (void* memory, size_t numBytes) noexcept { memset (memory, 0, numBytes); }
|
||||
@@ -90,5 +92,7 @@ inline Type* createCopyIfNotNull (const Type* pointer) { return pointer != n
|
||||
#define BEAST_AUTORELEASEPOOL
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
27
src/beast/beast/Strings.h
Normal file
27
src/beast/beast/Strings.h
Normal file
@@ -0,0 +1,27 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_STRINGS_H_INCLUDED
|
||||
#define BEAST_STRINGS_H_INCLUDED
|
||||
|
||||
#include "strings/String.h"
|
||||
#include "strings/NewLine.h"
|
||||
|
||||
#endif
|
||||
|
||||
40
src/beast/beast/Version.h
Normal file
40
src/beast/beast/Version.h
Normal file
@@ -0,0 +1,40 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_VERSION_H_INCLUDED
|
||||
#define BEAST_VERSION_H_INCLUDED
|
||||
|
||||
/** Current BEAST version number.
|
||||
See also SystemStats::getBeastVersion() for a string version.
|
||||
*/
|
||||
// VFALCO TODO Replace this with SemanticVerson
|
||||
#define BEAST_MAJOR_VERSION 1
|
||||
#define BEAST_MINOR_VERSION 0
|
||||
#define BEAST_BUILDNUMBER 0
|
||||
|
||||
/** Current Beast version number.
|
||||
Bits 16 to 32 = major version.
|
||||
Bits 8 to 16 = minor version.
|
||||
Bits 0 to 8 = point release.
|
||||
See also SystemStats::getBeastVersion() for a string version.
|
||||
*/
|
||||
#define BEAST_VERSION ((BEAST_MAJOR_VERSION << 16) + (BEAST_MINOR_VERSION << 8) + BEAST_BUILDNUMBER)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,8 +21,14 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_CORE_PLATFORMDEFS_H_INCLUDED
|
||||
#define BEAST_CORE_PLATFORMDEFS_H_INCLUDED
|
||||
#ifndef BEAST_CONFIG_COMPILERCONFIG_H_INCLUDED
|
||||
#define BEAST_CONFIG_COMPILERCONFIG_H_INCLUDED
|
||||
|
||||
// This file has to work when included in a C source file.
|
||||
|
||||
#ifndef BEAST_CONFIG_PLATFORMCONFIG_H_INCLUDED
|
||||
#error "PlatformConfig.h must come first!"
|
||||
#endif
|
||||
|
||||
// This file defines miscellaneous macros for debugging, assertions, etc.
|
||||
|
||||
@@ -84,6 +90,17 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/** Report a fatal error message and terminate the application.
|
||||
Normally you won't call this directly.
|
||||
*/
|
||||
extern void beast_reportFatalError (char const* message, char const* fileName, int lineNumber);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BEAST_DEBUG || DOXYGEN
|
||||
|
||||
/** Writes a string to the standard error stream.
|
||||
@@ -99,17 +116,12 @@
|
||||
#define bassertfalse { beast_LogCurrentAssertion; if (beast::beast_isRunningUnderDebugger()) beast_breakDebugger; BEAST_ANALYZER_NORETURN }
|
||||
|
||||
/** Platform-independent assertion macro.
|
||||
|
||||
This macro gets turned into a no-op when you're building with debugging turned off, so be
|
||||
careful that the expression you pass to it doesn't perform any actions that are vital for the
|
||||
correct behaviour of your program!
|
||||
@see bassertfalse
|
||||
*/
|
||||
#if 0
|
||||
#define bassert(expression) { if (! (expression)) bassertfalse; }
|
||||
#else
|
||||
#define bassert(expression) { if (! (expression)) fatal_error(#expression); }
|
||||
#endif
|
||||
#define bassert(expression) { if (! (expression)) beast_reportFatalError(#expression,__FILE__,__LINE__); }
|
||||
|
||||
#else
|
||||
|
||||
@@ -283,4 +295,11 @@
|
||||
#define override
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace beast {
|
||||
bool beast_isRunningUnderDebugger();
|
||||
void logAssertion (char const* file, int line) noexcept;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -17,8 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_CORE_BEASTCONFIGCHECK_H_INCLUDED
|
||||
#define BEAST_CORE_BEASTCONFIGCHECK_H_INCLUDED
|
||||
#ifndef BEAST_CONFIG_CONFIGCHECK_H_INCLUDED
|
||||
#define BEAST_CONFIG_CONFIGCHECK_H_INCLUDED
|
||||
|
||||
// This file makes sure that BeastConfig.h was included.
|
||||
// It also sets defaults for all config options.
|
||||
@@ -17,8 +17,10 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_CONTRACTCHECKS_H_INCLUDED
|
||||
#define BEAST_CONTRACTCHECKS_H_INCLUDED
|
||||
#ifndef BEAST_CONFIG_CONTRACTCHECKS_H_INCLUDED
|
||||
#define BEAST_CONFIG_CONTRACTCHECKS_H_INCLUDED
|
||||
|
||||
// This file has to work when included in a C source file.
|
||||
|
||||
#if defined (fatal_error) || \
|
||||
defined (fatal_condition) || \
|
||||
@@ -33,15 +35,13 @@
|
||||
#error "Programming by contract macros cannot be overriden!"
|
||||
#endif
|
||||
|
||||
extern void reportFatalError (char const* message, char const* fileName, int lineNumber);
|
||||
|
||||
/** Report a fatal error message and terminate the application.
|
||||
This macro automatically fills in the file and line number
|
||||
Meets this declaration syntax:
|
||||
@code inline void fatal_error (char const* message); @endif
|
||||
@see FatalError
|
||||
*/
|
||||
#define fatal_error(message) reportFatalError (message, __FILE__, __LINE__)
|
||||
#define fatal_error(message) beast_reportFatalError (message, __FILE__, __LINE__)
|
||||
|
||||
/** Reports a fatal error message type if the condition is false
|
||||
The condition is always evaluated regardless of settings.
|
||||
@@ -49,7 +49,7 @@ extern void reportFatalError (char const* message, char const* fileName, int lin
|
||||
@code inline void fatal_condition (bool condition, char const* category); @endcode
|
||||
*/
|
||||
#define fatal_condition(condition,category) static_cast <void> \
|
||||
(((!!(condition)) || (reportFatalError ( \
|
||||
(((!!(condition)) || (beast_reportFatalError ( \
|
||||
category " '" BEAST_STRINGIFY(condition) "' failed.", __FILE__, __LINE__), 0)))
|
||||
|
||||
/** Replacement for assert which generates a fatal error if the condition is false.
|
||||
@@ -65,7 +65,7 @@ extern void reportFatalError (char const* message, char const* fileName, int lin
|
||||
@code inline void fatal_condition (bool condition, char const* category); @endcode
|
||||
*/
|
||||
#define meets_condition(condition,category) static_cast <bool> \
|
||||
(((!!(condition)) || (reportFatalError ( \
|
||||
(((!!(condition)) || (beast_reportFatalError ( \
|
||||
category " '" BEAST_STRINGIFY(condition) "' failed.", __FILE__, __LINE__), false)))
|
||||
|
||||
/** Condition tests for programming by contract.
|
||||
217
src/beast/beast/config/PlatformConfig.h
Normal file
217
src/beast/beast/config/PlatformConfig.h
Normal file
@@ -0,0 +1,217 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Portions of this file are from JUCE.
|
||||
Copyright (c) 2013 - Raw Material Software Ltd.
|
||||
Please visit http://www.juce.com
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_CONFIG_PLATFORMCONFIG_H_INCLUDED
|
||||
#define BEAST_CONFIG_PLATFORMCONFIG_H_INCLUDED
|
||||
|
||||
//==============================================================================
|
||||
/* This file figures out which platform is being built, and defines some macros
|
||||
that the rest of the code can use for OS-specific compilation.
|
||||
|
||||
Macros that will be set here are:
|
||||
|
||||
- One of BEAST_WINDOWS, BEAST_MAC BEAST_LINUX, BEAST_IOS, BEAST_ANDROID, etc.
|
||||
- Either BEAST_32BIT or BEAST_64BIT, depending on the architecture.
|
||||
- Either BEAST_LITTLE_ENDIAN or BEAST_BIG_ENDIAN.
|
||||
- Either BEAST_INTEL or BEAST_PPC
|
||||
- Either BEAST_GCC or BEAST_MSVC
|
||||
*/
|
||||
|
||||
//==============================================================================
|
||||
#if (defined (_WIN32) || defined (_WIN64))
|
||||
#define BEAST_WIN32 1
|
||||
#define BEAST_WINDOWS 1
|
||||
#elif defined (BEAST_ANDROID)
|
||||
#undef BEAST_ANDROID
|
||||
#define BEAST_ANDROID 1
|
||||
#elif defined (LINUX) || defined (__linux__)
|
||||
#define BEAST_LINUX 1
|
||||
#elif defined (__APPLE_CPP__) || defined(__APPLE_CC__)
|
||||
#define Point CarbonDummyPointName // (workaround to avoid definition of "Point" by old Carbon headers)
|
||||
#define Component CarbonDummyCompName
|
||||
#include <CoreFoundation/CoreFoundation.h> // (needed to find out what platform we're using)
|
||||
#undef Point
|
||||
#undef Component
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#define BEAST_IPHONE 1
|
||||
#define BEAST_IOS 1
|
||||
#else
|
||||
#define BEAST_MAC 1
|
||||
#endif
|
||||
#elif defined (__FreeBSD__)
|
||||
#define BEAST_BSD 1
|
||||
#else
|
||||
#error "Unknown platform!"
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if BEAST_WINDOWS
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN64
|
||||
#define BEAST_64BIT 1
|
||||
#else
|
||||
#define BEAST_32BIT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define BEAST_DEBUG 1
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#define BEAST_MINGW 1
|
||||
#ifdef __MINGW64__
|
||||
#define BEAST_64BIT 1
|
||||
#else
|
||||
#define BEAST_32BIT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** If defined, this indicates that the processor is little-endian. */
|
||||
#define BEAST_LITTLE_ENDIAN 1
|
||||
|
||||
#define BEAST_INTEL 1
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if BEAST_MAC || BEAST_IOS
|
||||
|
||||
#if defined (DEBUG) || defined (_DEBUG) || ! (defined (NDEBUG) || defined (_NDEBUG))
|
||||
#define BEAST_DEBUG 1
|
||||
#endif
|
||||
|
||||
#if ! (defined (DEBUG) || defined (_DEBUG) || defined (NDEBUG) || defined (_NDEBUG))
|
||||
#warning "Neither NDEBUG or DEBUG has been defined - you should set one of these to make it clear whether this is a release build,"
|
||||
#endif
|
||||
|
||||
#ifdef __LITTLE_ENDIAN__
|
||||
#define BEAST_LITTLE_ENDIAN 1
|
||||
#else
|
||||
#define BEAST_BIG_ENDIAN 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BEAST_MAC
|
||||
|
||||
#if defined (__ppc__) || defined (__ppc64__)
|
||||
#define BEAST_PPC 1
|
||||
#elif defined (__arm__)
|
||||
#define BEAST_ARM 1
|
||||
#else
|
||||
#define BEAST_INTEL 1
|
||||
#endif
|
||||
|
||||
#ifdef __LP64__
|
||||
#define BEAST_64BIT 1
|
||||
#else
|
||||
#define BEAST_32BIT 1
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4
|
||||
#error "Building for OSX 10.3 is no longer supported!"
|
||||
#endif
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_5
|
||||
#error "To build with 10.4 compatibility, use a 10.5 or 10.6 SDK and set the deployment target to 10.4"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#if BEAST_LINUX || BEAST_ANDROID || BEAST_BSD
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define BEAST_DEBUG 1
|
||||
#endif
|
||||
|
||||
// Allow override for big-endian Linux platforms
|
||||
#if defined (__LITTLE_ENDIAN__) || ! defined (BEAST_BIG_ENDIAN)
|
||||
#define BEAST_LITTLE_ENDIAN 1
|
||||
#undef BEAST_BIG_ENDIAN
|
||||
#else
|
||||
#undef BEAST_LITTLE_ENDIAN
|
||||
#define BEAST_BIG_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#if defined (__LP64__) || defined (_LP64)
|
||||
#define BEAST_64BIT 1
|
||||
#else
|
||||
#define BEAST_32BIT 1
|
||||
#endif
|
||||
|
||||
#if __MMX__ || __SSE__ || __amd64__
|
||||
#ifdef __arm__
|
||||
#define BEAST_ARM 1
|
||||
#else
|
||||
#define BEAST_INTEL 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
// Compiler type macros.
|
||||
|
||||
#ifdef __clang__
|
||||
#define BEAST_CLANG 1
|
||||
#define BEAST_GCC 1
|
||||
#elif defined (__GNUC__)
|
||||
#define BEAST_GCC 1
|
||||
#elif defined (_MSC_VER)
|
||||
#define BEAST_MSVC 1
|
||||
|
||||
#if _MSC_VER < 1500
|
||||
#define BEAST_VC8_OR_EARLIER 1
|
||||
|
||||
#if _MSC_VER < 1400
|
||||
#define BEAST_VC7_OR_EARLIER 1
|
||||
|
||||
#if _MSC_VER < 1300
|
||||
#warning "MSVC 6.0 is no longer supported!"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BEAST_64BIT || ! BEAST_VC7_OR_EARLIER
|
||||
#define BEAST_USE_INTRINSICS 1
|
||||
#endif
|
||||
#else
|
||||
#error unknown compiler
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Handy macro that lets pragma warnings be clicked in the output window
|
||||
//
|
||||
// Usage: #pragma message(BEAST_FILEANDLINE_ "Advertise here!")
|
||||
//
|
||||
// Note that a space following the macro is mandatory for C++11.
|
||||
//
|
||||
// This is here so it can be used in C compilations that include this directly.
|
||||
//
|
||||
#define BEAST_PP_STR2_(x) #x
|
||||
#define BEAST_PP_STR1_(x) BEAST_PP_STR2_(x)
|
||||
#define BEAST_FILEANDLINE_ __FILE__ "(" BEAST_PP_STR1_(__LINE__) "): warning:"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,34 +21,11 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_STANDARDHEADER_H_INCLUDED
|
||||
#define BEAST_STANDARDHEADER_H_INCLUDED
|
||||
#ifndef BEAST_CONFIG_STANDARDCONFIG_H_INCLUDED
|
||||
#define BEAST_CONFIG_STANDARDCONFIG_H_INCLUDED
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Current BEAST version number.
|
||||
|
||||
See also SystemStats::getBeastVersion() for a string version.
|
||||
*/
|
||||
// VFALCO TODO Replace this with SemanticVerson
|
||||
#define BEAST_MAJOR_VERSION 1
|
||||
#define BEAST_MINOR_VERSION 0
|
||||
#define BEAST_BUILDNUMBER 0
|
||||
|
||||
/** Current Beast version number.
|
||||
|
||||
Bits 16 to 32 = major version.
|
||||
Bits 8 to 16 = minor version.
|
||||
Bits 0 to 8 = point release.
|
||||
|
||||
See also SystemStats::getBeastVersion() for a string version.
|
||||
*/
|
||||
#define BEAST_VERSION ((BEAST_MAJOR_VERSION << 16) + (BEAST_MINOR_VERSION << 8) + BEAST_BUILDNUMBER)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef BEAST_CORE_PLATFORMDEFS_H_INCLUDED
|
||||
#error "PlatformDefs.h must be included first"
|
||||
#ifndef BEAST_CONFIG_COMPILERCONFIG_H_INCLUDED
|
||||
#error "CompilerConfig.h must be included first"
|
||||
#endif
|
||||
|
||||
// Now we'll include some common OS headers..
|
||||
@@ -57,45 +34,6 @@
|
||||
#pragma warning (disable: 4514 4245 4100)
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <cfloat>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstdarg>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <new>
|
||||
#include <numeric>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
#include <vector>
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <float.h>
|
||||
#include <locale.h>
|
||||
#include <math.h>
|
||||
#include <memory.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if BEAST_USE_INTRINSICS
|
||||
# include <intrin.h>
|
||||
#endif
|
||||
24
src/beast/beast/http/HTTP.cpp
Normal file
24
src/beast/beast/http/HTTP.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "BeastConfig.h"
|
||||
|
||||
#include "impl/URL.cpp"
|
||||
#include "impl/ParsedURL.cpp"
|
||||
#include "impl/http_parser.cpp"
|
||||
51
src/beast/beast/http/ParsedURL.h
Normal file
51
src/beast/beast/http/ParsedURL.h
Normal file
@@ -0,0 +1,51 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_HTTP_PARSEDURL_H_INCLUDED
|
||||
#define BEAST_HTTP_PARSEDURL_H_INCLUDED
|
||||
|
||||
#include "../Strings.h"
|
||||
#include "URL.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
/** Parses a String containing a URL. */
|
||||
class ParsedURL
|
||||
{
|
||||
public:
|
||||
ParsedURL ();
|
||||
explicit ParsedURL (String const& url);
|
||||
ParsedURL (int error, URL const& url);
|
||||
ParsedURL (ParsedURL const& other);
|
||||
ParsedURL& operator= (ParsedURL const& other);
|
||||
|
||||
/** Zero for success, else a non zero value indicating failure. */
|
||||
int error () const;
|
||||
|
||||
/** The parsed URL if there was no error. */
|
||||
URL url () const;
|
||||
|
||||
private:
|
||||
int m_error;
|
||||
URL m_url;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -17,20 +17,24 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_ASIO_PROTOCOL_UNIFORMRESOURCELOCATOR_H_INCLUDED
|
||||
#define BEAST_ASIO_PROTOCOL_UNIFORMRESOURCELOCATOR_H_INCLUDED
|
||||
#ifndef BEAST_HTTP_URL_H_INCLUDED
|
||||
#define BEAST_HTTP_URL_H_INCLUDED
|
||||
|
||||
#include "../strings/String.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
/** A URL.
|
||||
The accompanying robust parser is hardened against all forms of attack.
|
||||
*/
|
||||
class UniformResourceLocator
|
||||
class URL
|
||||
{
|
||||
public:
|
||||
/** Construct an empty URL. */
|
||||
explicit UniformResourceLocator ();
|
||||
explicit URL ();
|
||||
|
||||
/** Construct a URL from it's components. */
|
||||
UniformResourceLocator (
|
||||
URL (
|
||||
String schema_,
|
||||
String host_,
|
||||
uint16 port_,
|
||||
@@ -41,10 +45,10 @@ public:
|
||||
String userinfo_ = "");
|
||||
|
||||
/** Copy construct a URL. */
|
||||
UniformResourceLocator (UniformResourceLocator const& other);
|
||||
URL (URL const& other);
|
||||
|
||||
/** Copy assign a URL. */
|
||||
UniformResourceLocator& operator= (UniformResourceLocator const& other);
|
||||
URL& operator= (URL const& other);
|
||||
|
||||
/** Returns `true` if this is an empty URL. */
|
||||
bool empty () const;
|
||||
@@ -99,28 +103,6 @@ private:
|
||||
String m_userinfo;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Parses a String containing a URL.
|
||||
*/
|
||||
class ParsedURL
|
||||
{
|
||||
public:
|
||||
ParsedURL ();
|
||||
explicit ParsedURL (String const& url);
|
||||
ParsedURL (int error, UniformResourceLocator const& url);
|
||||
ParsedURL (ParsedURL const& other);
|
||||
ParsedURL& operator= (ParsedURL const& other);
|
||||
|
||||
/** Zero for success, else a non zero value indicating failure. */
|
||||
int error () const;
|
||||
|
||||
/** The parsed URL if there was no error. */
|
||||
UniformResourceLocator url () const;
|
||||
|
||||
private:
|
||||
int m_error;
|
||||
UniformResourceLocator m_url;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -17,139 +17,13 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
UniformResourceLocator::UniformResourceLocator ()
|
||||
: m_port (0)
|
||||
{
|
||||
}
|
||||
#include "../ParsedURL.h"
|
||||
|
||||
UniformResourceLocator::UniformResourceLocator (
|
||||
String scheme_,
|
||||
String host_,
|
||||
uint16 port_,
|
||||
String port_string_,
|
||||
String path_,
|
||||
String query_,
|
||||
String fragment_,
|
||||
String userinfo_)
|
||||
: m_scheme (scheme_)
|
||||
, m_host (host_)
|
||||
, m_port (port_)
|
||||
, m_port_string (port_string_)
|
||||
, m_path (path_)
|
||||
, m_query (query_)
|
||||
, m_fragment (fragment_)
|
||||
, m_userinfo (userinfo_)
|
||||
{
|
||||
}
|
||||
#include "http-parser/http_parser.h"
|
||||
|
||||
UniformResourceLocator::UniformResourceLocator (UniformResourceLocator const& other)
|
||||
: m_scheme (other.m_scheme)
|
||||
, m_host (other.m_host)
|
||||
, m_port (other.m_port)
|
||||
, m_port_string (other.m_port_string)
|
||||
, m_path (other.m_path)
|
||||
, m_query (other.m_query)
|
||||
, m_fragment (other.m_fragment)
|
||||
, m_userinfo (other.m_userinfo)
|
||||
{
|
||||
}
|
||||
#include "../../../modules/beast_core/beast_core.h" // for UnitTest
|
||||
|
||||
UniformResourceLocator& UniformResourceLocator::operator= (UniformResourceLocator const& other)
|
||||
{
|
||||
m_scheme = other.m_scheme;
|
||||
m_host = other.m_host;
|
||||
m_port = other.m_port;
|
||||
m_port_string = other.m_port_string;
|
||||
m_path = other.m_path;
|
||||
m_query = other.m_query;
|
||||
m_fragment = other.m_fragment;
|
||||
m_userinfo = other.m_userinfo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
bool UniformResourceLocator::empty () const
|
||||
{
|
||||
return m_scheme == String::empty;
|
||||
}
|
||||
|
||||
String UniformResourceLocator::scheme () const
|
||||
{
|
||||
return m_scheme;
|
||||
}
|
||||
|
||||
String UniformResourceLocator::host () const
|
||||
{
|
||||
return m_host;
|
||||
}
|
||||
|
||||
String UniformResourceLocator::port_string () const
|
||||
{
|
||||
return m_port_string;
|
||||
}
|
||||
|
||||
uint16 UniformResourceLocator::port () const
|
||||
{
|
||||
return m_port;
|
||||
}
|
||||
|
||||
String UniformResourceLocator::path () const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
String UniformResourceLocator::query () const
|
||||
{
|
||||
return m_query;
|
||||
}
|
||||
|
||||
String UniformResourceLocator::fragment () const
|
||||
{
|
||||
return m_fragment;
|
||||
}
|
||||
|
||||
String UniformResourceLocator::userinfo () const
|
||||
{
|
||||
return m_userinfo;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
From
|
||||
http://en.wikipedia.org/wiki/URI_scheme
|
||||
|
||||
<scheme name> : <hierarchical part> [ ? <query> ] [ # <fragment> ]
|
||||
|
||||
e.g.
|
||||
|
||||
foo://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose
|
||||
*/
|
||||
String UniformResourceLocator::full () const
|
||||
{
|
||||
String s;
|
||||
|
||||
s = scheme () + "://";
|
||||
|
||||
if (userinfo () != String::empty)
|
||||
s = userinfo () + "@";
|
||||
|
||||
s = s + host ();
|
||||
|
||||
if (port () != 0)
|
||||
s = s + ":" + String::fromNumber (port ());
|
||||
|
||||
s = s + path ();
|
||||
|
||||
if (query () != String::empty)
|
||||
s = "?" + query ();
|
||||
|
||||
if (fragment () != String::empty)
|
||||
s = "#" + fragment ();
|
||||
|
||||
return s;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
namespace beast {
|
||||
|
||||
ParsedURL::ParsedURL ()
|
||||
: m_error (0)
|
||||
@@ -231,7 +105,7 @@ ParsedURL::ParsedURL (String const& url)
|
||||
u.field_data [UF_USERINFO].len);
|
||||
}
|
||||
|
||||
m_url = UniformResourceLocator (
|
||||
m_url = URL (
|
||||
scheme_,
|
||||
host_,
|
||||
port_,
|
||||
@@ -243,7 +117,7 @@ ParsedURL::ParsedURL (String const& url)
|
||||
}
|
||||
}
|
||||
|
||||
ParsedURL::ParsedURL (int error, UniformResourceLocator const& url)
|
||||
ParsedURL::ParsedURL (int error, URL const& url)
|
||||
: m_error (error)
|
||||
, m_url (url)
|
||||
{
|
||||
@@ -267,7 +141,7 @@ int ParsedURL::error () const
|
||||
return m_error;
|
||||
}
|
||||
|
||||
UniformResourceLocator ParsedURL::url () const
|
||||
URL ParsedURL::url () const
|
||||
{
|
||||
return m_url;
|
||||
}
|
||||
@@ -302,3 +176,5 @@ public:
|
||||
};
|
||||
|
||||
static ParsedURLTests parsedURLTests;
|
||||
|
||||
}
|
||||
3
src/beast/beast/http/impl/README.md
Normal file
3
src/beast/beast/http/impl/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
git-subtree: "http-parser"
|
||||
remote: https://github.com/joyent/http-parser.git
|
||||
branch: master
|
||||
158
src/beast/beast/http/impl/URL.cpp
Normal file
158
src/beast/beast/http/impl/URL.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../URL.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
URL::URL ()
|
||||
: m_port (0)
|
||||
{
|
||||
}
|
||||
|
||||
URL::URL (
|
||||
String scheme_,
|
||||
String host_,
|
||||
uint16 port_,
|
||||
String port_string_,
|
||||
String path_,
|
||||
String query_,
|
||||
String fragment_,
|
||||
String userinfo_)
|
||||
: m_scheme (scheme_)
|
||||
, m_host (host_)
|
||||
, m_port (port_)
|
||||
, m_port_string (port_string_)
|
||||
, m_path (path_)
|
||||
, m_query (query_)
|
||||
, m_fragment (fragment_)
|
||||
, m_userinfo (userinfo_)
|
||||
{
|
||||
}
|
||||
|
||||
URL::URL (URL const& other)
|
||||
: m_scheme (other.m_scheme)
|
||||
, m_host (other.m_host)
|
||||
, m_port (other.m_port)
|
||||
, m_port_string (other.m_port_string)
|
||||
, m_path (other.m_path)
|
||||
, m_query (other.m_query)
|
||||
, m_fragment (other.m_fragment)
|
||||
, m_userinfo (other.m_userinfo)
|
||||
{
|
||||
}
|
||||
|
||||
URL& URL::operator= (URL const& other)
|
||||
{
|
||||
m_scheme = other.m_scheme;
|
||||
m_host = other.m_host;
|
||||
m_port = other.m_port;
|
||||
m_port_string = other.m_port_string;
|
||||
m_path = other.m_path;
|
||||
m_query = other.m_query;
|
||||
m_fragment = other.m_fragment;
|
||||
m_userinfo = other.m_userinfo;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
bool URL::empty () const
|
||||
{
|
||||
return m_scheme == String::empty;
|
||||
}
|
||||
|
||||
String URL::scheme () const
|
||||
{
|
||||
return m_scheme;
|
||||
}
|
||||
|
||||
String URL::host () const
|
||||
{
|
||||
return m_host;
|
||||
}
|
||||
|
||||
String URL::port_string () const
|
||||
{
|
||||
return m_port_string;
|
||||
}
|
||||
|
||||
uint16 URL::port () const
|
||||
{
|
||||
return m_port;
|
||||
}
|
||||
|
||||
String URL::path () const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
String URL::query () const
|
||||
{
|
||||
return m_query;
|
||||
}
|
||||
|
||||
String URL::fragment () const
|
||||
{
|
||||
return m_fragment;
|
||||
}
|
||||
|
||||
String URL::userinfo () const
|
||||
{
|
||||
return m_userinfo;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
From
|
||||
http://en.wikipedia.org/wiki/URI_scheme
|
||||
|
||||
<scheme name> : <hierarchical part> [ ? <query> ] [ # <fragment> ]
|
||||
|
||||
e.g.
|
||||
|
||||
foo://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose
|
||||
*/
|
||||
String URL::full () const
|
||||
{
|
||||
String s;
|
||||
|
||||
s = scheme () + "://";
|
||||
|
||||
if (userinfo () != String::empty)
|
||||
s = userinfo () + "@";
|
||||
|
||||
s = s + host ();
|
||||
|
||||
if (port () != 0)
|
||||
s = s + ":" + String::fromNumber (port ());
|
||||
|
||||
s = s + path ();
|
||||
|
||||
if (query () != String::empty)
|
||||
s = "?" + query ();
|
||||
|
||||
if (fragment () != String::empty)
|
||||
s = "#" + fragment ();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
36
src/beast/beast/http/impl/http_parser.cpp
Normal file
36
src/beast/beast/http/impl/http_parser.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "BeastConfig.h"
|
||||
|
||||
#include "../../Config.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127) // conditional expression is constant
|
||||
#pragma warning (disable: 4244) // integer conversion, possible loss of data
|
||||
#endif
|
||||
#include "http-parser/http_parser.c"
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -21,8 +21,8 @@
|
||||
#define BEAST_NET_IPENDPOINT_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <ios>
|
||||
#include <sstream>
|
||||
|
||||
#include "../CStdInt.h"
|
||||
#include "../mpl/IfCond.h"
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#include "BeastConfig.h"
|
||||
|
||||
#include "../../modules/beast_core/beast_core.h" // for UnitTest
|
||||
|
||||
#include "../Config.h"
|
||||
|
||||
#include "../../modules/beast_core/beast_core.h" // for UnitTest
|
||||
|
||||
#include "impl/IPEndpoint.cpp"
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#ifndef BEAST_CHARPOINTER_ASCII_H_INCLUDED
|
||||
#define BEAST_CHARPOINTER_ASCII_H_INCLUDED
|
||||
|
||||
namespace beast {
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
@@ -378,5 +379,7 @@ private:
|
||||
CharType* data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BEAST_CHARPOINTER_ASCII_H_INCLUDED
|
||||
@@ -24,6 +24,7 @@
|
||||
#ifndef BEAST_CHARPOINTER_UTF16_H_INCLUDED
|
||||
#define BEAST_CHARPOINTER_UTF16_H_INCLUDED
|
||||
|
||||
namespace beast {
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
@@ -516,4 +517,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
#endif // BEAST_CHARPOINTER_UTF16_H_INCLUDED
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#ifndef BEAST_CHARPOINTER_UTF32_H_INCLUDED
|
||||
#define BEAST_CHARPOINTER_UTF32_H_INCLUDED
|
||||
|
||||
namespace beast {
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
@@ -369,5 +370,7 @@ private:
|
||||
CharType* data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BEAST_CHARPOINTER_UTF32_H_INCLUDED
|
||||
@@ -24,6 +24,12 @@
|
||||
#ifndef BEAST_CHARPOINTER_UTF8_H_INCLUDED
|
||||
#define BEAST_CHARPOINTER_UTF8_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../Atomic.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Wraps a pointer to a null-terminated UTF-8 character string, and provides
|
||||
@@ -570,5 +576,7 @@ private:
|
||||
CharType* data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,9 +21,13 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_CHARACTERFUNCTIONS_H_INCLUDED
|
||||
#define BEAST_CHARACTERFUNCTIONS_H_INCLUDED
|
||||
#ifndef BEAST_STRINGS_CHARACTERFUNCTIONS_H_INCLUDED
|
||||
#define BEAST_STRINGS_CHARACTERFUNCTIONS_H_INCLUDED
|
||||
|
||||
#include "../Config.h"
|
||||
#include "../CStdInt.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
//==============================================================================
|
||||
#if BEAST_WINDOWS && ! DOXYGEN
|
||||
@@ -581,5 +585,7 @@ private:
|
||||
static double mulexp10 (const double value, int exponent) noexcept;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BEAST_CHARACTERFUNCTIONS_H_INCLUDED
|
||||
@@ -24,6 +24,9 @@
|
||||
#ifndef BEAST_NEWLINE_H_INCLUDED
|
||||
#define BEAST_NEWLINE_H_INCLUDED
|
||||
|
||||
#include "../Config.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
//==============================================================================
|
||||
/** This class is used for represent a new-line character sequence.
|
||||
@@ -69,5 +72,7 @@ extern NewLine newLine;
|
||||
*/
|
||||
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, const NewLine&);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BEAST_NEWLINE_H_INCLUDED
|
||||
@@ -21,8 +21,38 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_STRING_H_INCLUDED
|
||||
#define BEAST_STRING_H_INCLUDED
|
||||
#ifndef BEAST_STRINGS_STRING_H_INCLUDED
|
||||
#define BEAST_STRINGS_STRING_H_INCLUDED
|
||||
|
||||
#include "../Config.h"
|
||||
#include "../CStdInt.h"
|
||||
#include "CharacterFunctions.h"
|
||||
#if BEAST_MSVC
|
||||
# pragma warning (push)
|
||||
# pragma warning (disable: 4514 4996)
|
||||
#endif
|
||||
#include "CharPointer_UTF8.h"
|
||||
#include "CharPointer_UTF16.h"
|
||||
#include "CharPointer_UTF32.h"
|
||||
#include "CharPointer_ASCII.h"
|
||||
#if BEAST_MSVC
|
||||
# pragma warning (pop)
|
||||
#endif
|
||||
#include "StringCharPointerType.h"
|
||||
#include "StringFromNumber.h"
|
||||
#include "String.h"
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace beast {
|
||||
|
||||
#if BEAST_NATIVE_WCHAR_IS_UTF8
|
||||
typedef CharPointer_UTF8 CharPointer_wchar_t;
|
||||
#elif BEAST_NATIVE_WCHAR_IS_UTF16
|
||||
typedef CharPointer_UTF16 CharPointer_wchar_t;
|
||||
#else
|
||||
typedef CharPointer_UTF32 CharPointer_wchar_t;
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
@@ -1348,8 +1378,7 @@ std::basic_ostream <wchar_t, traits>& BEAST_CALLTYPE operator<< (std::basic_ostr
|
||||
return stream << stringToWrite.toWideCharPointer();
|
||||
}
|
||||
|
||||
/** Writes a string to an OutputStream as UTF8. */
|
||||
BEAST_API OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const String& stringToWrite);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BEAST_STRING_H_INCLUDED
|
||||
@@ -21,8 +21,10 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_STRINGCHARPOINTERTYPE_H_INCLUDED
|
||||
#define BEAST_STRINGCHARPOINTERTYPE_H_INCLUDED
|
||||
#ifndef BEAST_STRINGS_STRINGCHARPOINTERTYPE_H_INCLUDED
|
||||
#define BEAST_STRINGS_STRINGCHARPOINTERTYPE_H_INCLUDED
|
||||
|
||||
namespace beast {
|
||||
|
||||
/** This is the character encoding type used internally to store the string.
|
||||
|
||||
@@ -50,5 +52,7 @@ typedef CharPointer_UTF8 StringCharPointerType;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,10 +21,14 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_CORE_STRINGFROMNUMBER_H_INCLUDED
|
||||
#define BEAST_CORE_STRINGFROMNUMBER_H_INCLUDED
|
||||
#ifndef BEAST_STRINGS_STRINGFROMNUMBER_H_INCLUDED
|
||||
#define BEAST_STRINGS_STRINGFROMNUMBER_H_INCLUDED
|
||||
|
||||
// This is private!
|
||||
#include "../Arithmetic.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
// VFALCO TODO Put this in namespace detail
|
||||
//
|
||||
class NumberToStringConverters
|
||||
{
|
||||
@@ -156,4 +160,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
23
src/beast/beast/strings/Strings.cpp
Normal file
23
src/beast/beast/strings/Strings.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "BeastConfig.h"
|
||||
|
||||
#include "impl/CharacterFunctions.cpp"
|
||||
#include "impl/String.cpp"
|
||||
@@ -21,7 +21,12 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
//==============================================================================
|
||||
#include <cctype>
|
||||
|
||||
#include "../CharacterFunctions.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
#if BEAST_MSVC
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4514 4996)
|
||||
@@ -147,3 +152,5 @@ double CharacterFunctions::mulexp10 (const double value, int exponent) noexcept
|
||||
|
||||
return negative ? (value / result) : (value * result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,21 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "../String.h"
|
||||
#include "../NewLine.h"
|
||||
|
||||
#include "../../ByteOrder.h"
|
||||
#include "../../Memory.h"
|
||||
#include "../../StaticAssert.h"
|
||||
#include "../../Arithmetic.h"
|
||||
#include "../../HeapBlock.h"
|
||||
|
||||
#include "../../../modules/beast_core/beast_core.h" // for UnitTest
|
||||
|
||||
namespace beast {
|
||||
|
||||
#if BEAST_MSVC
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4514 4996)
|
||||
@@ -32,14 +47,6 @@ NewLine newLine;
|
||||
#error "BEAST_STRINGS_ARE_UNICODE is deprecated! All strings are now unicode by default."
|
||||
#endif
|
||||
|
||||
#if BEAST_NATIVE_WCHAR_IS_UTF8
|
||||
typedef CharPointer_UTF8 CharPointer_wchar_t;
|
||||
#elif BEAST_NATIVE_WCHAR_IS_UTF16
|
||||
typedef CharPointer_UTF16 CharPointer_wchar_t;
|
||||
#else
|
||||
typedef CharPointer_UTF32 CharPointer_wchar_t;
|
||||
#endif
|
||||
|
||||
static inline CharPointer_wchar_t castToCharPointer_wchar_t (const void* t) noexcept
|
||||
{
|
||||
return CharPointer_wchar_t (static_cast <const CharPointer_wchar_t::CharType*> (t));
|
||||
@@ -632,23 +639,6 @@ BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const int64 number)
|
||||
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const float number) { return s1 += String (number); }
|
||||
BEAST_API String& BEAST_CALLTYPE operator<< (String& s1, const double number) { return s1 += String (number); }
|
||||
|
||||
BEAST_API OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const String& text)
|
||||
{
|
||||
const size_t numBytes = text.getNumBytesAsUTF8();
|
||||
|
||||
#if (BEAST_STRING_UTF_TYPE == 8)
|
||||
stream.write (text.getCharPointer().getAddress(), numBytes);
|
||||
#else
|
||||
// (This avoids using toUTF8() to prevent the memory bloat that it would leave behind
|
||||
// if lots of large, persistent strings were to be written to streams).
|
||||
HeapBlock<char> temp (numBytes + 1);
|
||||
CharPointer_UTF8 (temp).writeAll (text.getCharPointer());
|
||||
stream.write (temp, numBytes);
|
||||
#endif
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
BEAST_API String& BEAST_CALLTYPE operator<< (String& string1, const NewLine&)
|
||||
{
|
||||
return string1 += NewLine::getDefault();
|
||||
@@ -1973,6 +1963,8 @@ String String::fromUTF8 (const char* const buffer, int bufferSizeBytes)
|
||||
//==============================================================================
|
||||
//==============================================================================
|
||||
|
||||
#ifdef BEAST_UNITTEST_H_INCLUDED
|
||||
|
||||
class StringTests : public UnitTest
|
||||
{
|
||||
public:
|
||||
@@ -2326,3 +2318,6 @@ public:
|
||||
|
||||
static StringTests stringUnitTests;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -23,8 +23,9 @@
|
||||
|
||||
#include "beast_asio.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
namespace beast {
|
||||
|
||||
# include "../../beast/http/impl/http-parser/http_parser.h"
|
||||
|
||||
#include "async/SharedHandler.cpp"
|
||||
|
||||
@@ -37,10 +38,8 @@ namespace beast
|
||||
|
||||
#include "protocol/HandshakeDetectLogicPROXY.cpp"
|
||||
|
||||
# include "parsehttp/http_parser.h"
|
||||
# include "http/HTTPParserImpl.h"
|
||||
#include "http/HTTPParser.cpp"
|
||||
#include "http/UniformResourceLocator.cpp"
|
||||
#include "http/HTTPClientType.cpp"
|
||||
#include "http/HTTPField.cpp"
|
||||
#include "http/HTTPHeaders.cpp"
|
||||
@@ -61,16 +60,4 @@ namespace beast
|
||||
|
||||
#include "system/BoostUnitTests.cpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127) // conditional expression is constant
|
||||
#pragma warning (disable: 4244) // integer conversion, possible loss of data
|
||||
#endif
|
||||
#include "parsehttp/http_parser.c"
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
|
||||
#include "../../beast/MPL.h"
|
||||
#include "../../beast/Utility.h"
|
||||
#include "../../beast/HTTP.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
@@ -87,7 +88,6 @@ namespace beast
|
||||
# include "http/HTTPRequest.h"
|
||||
# include "http/HTTPResponse.h"
|
||||
# include "http/HTTPParser.h"
|
||||
# include "http/UniformResourceLocator.h"
|
||||
#include "http/HTTPClientType.h"
|
||||
|
||||
# include "protocol/InputParser.h"
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
return m_result;
|
||||
}
|
||||
|
||||
Result const& get (UniformResourceLocator const& url)
|
||||
Result const& get (URL const& url)
|
||||
{
|
||||
boost::asio::io_service io_service;
|
||||
async_get (io_service, nullptr, url);
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void async_get (boost::asio::io_service& io_service, Listener* listener,
|
||||
UniformResourceLocator const& url)
|
||||
URL const& url)
|
||||
{
|
||||
async_get (io_service, url, ListenerHandler (this, listener));
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
//
|
||||
template <typename Handler>
|
||||
void async_get (boost::asio::io_service& io_service,
|
||||
UniformResourceLocator const& url,
|
||||
URL const& url,
|
||||
BOOST_ASIO_MOVE_ARG(Handler) handler)
|
||||
{
|
||||
async_get (io_service, url, newErrorHandler (
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
}
|
||||
|
||||
void async_get (boost::asio::io_service& io_service,
|
||||
UniformResourceLocator const& url, SharedHandlerPtr handler)
|
||||
URL const& url, SharedHandlerPtr handler)
|
||||
{
|
||||
// This automatically dispatches
|
||||
m_async_op = new AsyncGetOp (
|
||||
@@ -143,7 +143,7 @@ private:
|
||||
|
||||
/** Helper function to fill out a Query from a URL. */
|
||||
template <typename Query>
|
||||
static Query queryFromURL (UniformResourceLocator const& url)
|
||||
static Query queryFromURL (URL const& url)
|
||||
{
|
||||
if (url.port () != 0)
|
||||
{
|
||||
@@ -206,7 +206,7 @@ private:
|
||||
public:
|
||||
AsyncGetOp (HTTPClientType& owner,
|
||||
boost::asio::io_service& io_service,
|
||||
UniformResourceLocator const& url,
|
||||
URL const& url,
|
||||
SharedHandlerPtr const& handler,
|
||||
double timeoutSeconds,
|
||||
std::size_t messageLimitBytes,
|
||||
@@ -688,7 +688,7 @@ private:
|
||||
HTTPClientType& m_owner;
|
||||
boost::asio::io_service& m_io_service;
|
||||
boost::asio::io_service& m_strand;
|
||||
UniformResourceLocator m_url;
|
||||
URL m_url;
|
||||
SharedHandlerPtr m_handler;
|
||||
boost::asio::deadline_timer m_timer;
|
||||
resolver m_resolver;
|
||||
|
||||
@@ -47,11 +47,11 @@ public:
|
||||
virtual Result const& result () const = 0;
|
||||
|
||||
virtual Result const& get (
|
||||
UniformResourceLocator const& url) = 0;
|
||||
URL const& url) = 0;
|
||||
|
||||
virtual void async_get (boost::asio::io_service& io_service,
|
||||
Listener* listener,
|
||||
UniformResourceLocator const& url) = 0;
|
||||
URL const& url) = 0;
|
||||
|
||||
/** Cancel any pending asynchronous operations.
|
||||
This must be called before destroying the container if there are
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/out/
|
||||
core
|
||||
tags
|
||||
*.o
|
||||
test
|
||||
test_g
|
||||
test_fast
|
||||
url_parser
|
||||
parsertrace
|
||||
parsertrace_g
|
||||
*.mk
|
||||
*.Makefile
|
||||
*.so.*
|
||||
*.a
|
||||
@@ -1,7 +0,0 @@
|
||||
# update AUTHORS with:
|
||||
# git log --all --reverse --format='%aN <%aE>' | perl -ne 'BEGIN{print "# Authors ordered by first contribution.\n"} print unless $h{$_}; $h{$_} = 1' > AUTHORS
|
||||
Ryan Dahl <ry@tinyclouds.org>
|
||||
Salman Haq <salman.haq@asti-usa.com>
|
||||
Simon Zimmermann <simonz05@gmail.com>
|
||||
Thomas LE ROUX <thomas@november-eleven.fr> LE ROUX Thomas <thomas@procheo.fr>
|
||||
Thomas LE ROUX <thomas@november-eleven.fr> Thomas LE ROUX <thomas@procheo.fr>
|
||||
@@ -1,13 +0,0 @@
|
||||
language: c
|
||||
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
|
||||
script:
|
||||
- "make"
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
irc:
|
||||
- "irc.freenode.net#libuv"
|
||||
@@ -1,41 +0,0 @@
|
||||
# Authors ordered by first contribution.
|
||||
Ryan Dahl <ry@tinyclouds.org>
|
||||
Jeremy Hinegardner <jeremy@hinegardner.org>
|
||||
Sergey Shepelev <temotor@gmail.com>
|
||||
Joe Damato <ice799@gmail.com>
|
||||
tomika <tomika_nospam@freemail.hu>
|
||||
Phoenix Sol <phoenix@burninglabs.com>
|
||||
Cliff Frey <cliff@meraki.com>
|
||||
Ewen Cheslack-Postava <ewencp@cs.stanford.edu>
|
||||
Santiago Gala <sgala@apache.org>
|
||||
Tim Becker <tim.becker@syngenio.de>
|
||||
Jeff Terrace <jterrace@gmail.com>
|
||||
Ben Noordhuis <info@bnoordhuis.nl>
|
||||
Nathan Rajlich <nathan@tootallnate.net>
|
||||
Mark Nottingham <mnot@mnot.net>
|
||||
Aman Gupta <aman@tmm1.net>
|
||||
Tim Becker <tim.becker@kuriositaet.de>
|
||||
Sean Cunningham <sean.cunningham@mandiant.com>
|
||||
Peter Griess <pg@std.in>
|
||||
Salman Haq <salman.haq@asti-usa.com>
|
||||
Cliff Frey <clifffrey@gmail.com>
|
||||
Jon Kolb <jon@b0g.us>
|
||||
Fouad Mardini <f.mardini@gmail.com>
|
||||
Paul Querna <pquerna@apache.org>
|
||||
Felix Geisendörfer <felix@debuggable.com>
|
||||
koichik <koichik@improvement.jp>
|
||||
Andre Caron <andre.l.caron@gmail.com>
|
||||
Ivo Raisr <ivosh@ivosh.net>
|
||||
James McLaughlin <jamie@lacewing-project.org>
|
||||
David Gwynne <loki@animata.net>
|
||||
Thomas LE ROUX <thomas@november-eleven.fr>
|
||||
Randy Rizun <rrizun@ortivawireless.com>
|
||||
Andre Louis Caron <andre.louis.caron@usherbrooke.ca>
|
||||
Simon Zimmermann <simonz05@gmail.com>
|
||||
Erik Dubbelboer <erik@dubbelboer.com>
|
||||
Martell Malone <martellmalone@gmail.com>
|
||||
Bertrand Paquet <bpaquet@octo.com>
|
||||
BogDan Vatra <bogdan@kde.org>
|
||||
Peter Faiman <peter@thepicard.org>
|
||||
Corey Richardson <corey@octayn.net>
|
||||
Tóth Tamás <tomika_nospam@freemail.hu>
|
||||
@@ -1,4 +0,0 @@
|
||||
Contributors must agree to the Contributor License Agreement before patches
|
||||
can be accepted.
|
||||
|
||||
http://spreadsheets2.google.com/viewform?hl=en&formkey=dDJXOGUwbzlYaWM4cHN1MERwQS1CSnc6MQ
|
||||
@@ -1,23 +0,0 @@
|
||||
http_parser.c is based on src/http/ngx_http_parse.c from NGINX copyright
|
||||
Igor Sysoev.
|
||||
|
||||
Additional changes are licensed under the same terms as NGINX and
|
||||
copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
@@ -1,105 +0,0 @@
|
||||
# Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
|
||||
PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
|
||||
SONAME ?= libhttp_parser.so.2.1
|
||||
|
||||
CC?=gcc
|
||||
AR?=ar
|
||||
|
||||
CPPFLAGS += -I.
|
||||
CPPFLAGS_DEBUG = $(CPPFLAGS) -DHTTP_PARSER_STRICT=1
|
||||
CPPFLAGS_DEBUG += $(CPPFLAGS_DEBUG_EXTRA)
|
||||
CPPFLAGS_FAST = $(CPPFLAGS) -DHTTP_PARSER_STRICT=0
|
||||
CPPFLAGS_FAST += $(CPPFLAGS_FAST_EXTRA)
|
||||
|
||||
CFLAGS += -Wall -Wextra -Werror
|
||||
CFLAGS_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA)
|
||||
CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA)
|
||||
CFLAGS_LIB = $(CFLAGS_FAST) -fPIC
|
||||
|
||||
LDFLAGS_LIB = $(LDFLAGS) -shared
|
||||
|
||||
ifneq (darwin,$(PLATFORM))
|
||||
# TODO(bnoordhuis) The native SunOS linker expects -h rather than -soname...
|
||||
LDFLAGS_LIB += -Wl,-soname=$(SONAME)
|
||||
endif
|
||||
|
||||
test: test_g test_fast
|
||||
./test_g
|
||||
./test_fast
|
||||
|
||||
test_g: http_parser_g.o test_g.o
|
||||
$(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@
|
||||
|
||||
test_g.o: test.c http_parser.h Makefile
|
||||
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c test.c -o $@
|
||||
|
||||
http_parser_g.o: http_parser.c http_parser.h Makefile
|
||||
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c http_parser.c -o $@
|
||||
|
||||
test_fast: http_parser.o test.o http_parser.h
|
||||
$(CC) $(CFLAGS_FAST) $(LDFLAGS) http_parser.o test.o -o $@
|
||||
|
||||
test.o: test.c http_parser.h Makefile
|
||||
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c test.c -o $@
|
||||
|
||||
http_parser.o: http_parser.c http_parser.h Makefile
|
||||
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c
|
||||
|
||||
test-run-timed: test_fast
|
||||
while(true) do time ./test_fast > /dev/null; done
|
||||
|
||||
test-valgrind: test_g
|
||||
valgrind ./test_g
|
||||
|
||||
libhttp_parser.o: http_parser.c http_parser.h Makefile
|
||||
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_LIB) -c http_parser.c -o libhttp_parser.o
|
||||
|
||||
library: libhttp_parser.o
|
||||
$(CC) $(LDFLAGS_LIB) -o $(SONAME) $<
|
||||
|
||||
package: http_parser.o
|
||||
$(AR) rcs libhttp_parser.a http_parser.o
|
||||
|
||||
url_parser: http_parser.o contrib/url_parser.c
|
||||
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o $@
|
||||
|
||||
url_parser_g: http_parser_g.o contrib/url_parser.c
|
||||
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o $@
|
||||
|
||||
parsertrace: http_parser.o contrib/parsertrace.c
|
||||
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace
|
||||
|
||||
parsertrace_g: http_parser_g.o contrib/parsertrace.c
|
||||
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g
|
||||
|
||||
tags: http_parser.c http_parser.h test.c
|
||||
ctags $^
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a tags test test_fast test_g \
|
||||
http_parser.tar libhttp_parser.so.* \
|
||||
url_parser url_parser_g parsertrace parsertrace_g
|
||||
|
||||
contrib/url_parser.c: http_parser.h
|
||||
contrib/parsertrace.c: http_parser.h
|
||||
|
||||
.PHONY: clean package test-run test-run-timed test-valgrind
|
||||
@@ -1,180 +0,0 @@
|
||||
HTTP Parser
|
||||
===========
|
||||
|
||||
[](https://travis-ci.org/joyent/http-parser)
|
||||
|
||||
This is a parser for HTTP messages written in C. It parses both requests and
|
||||
responses. The parser is designed to be used in performance HTTP
|
||||
applications. It does not make any syscalls nor allocations, it does not
|
||||
buffer data, it can be interrupted at anytime. Depending on your
|
||||
architecture, it only requires about 40 bytes of data per message
|
||||
stream (in a web server that is per connection).
|
||||
|
||||
Features:
|
||||
|
||||
* No dependencies
|
||||
* Handles persistent streams (keep-alive).
|
||||
* Decodes chunked encoding.
|
||||
* Upgrade support
|
||||
* Defends against buffer overflow attacks.
|
||||
|
||||
The parser extracts the following information from HTTP messages:
|
||||
|
||||
* Header fields and values
|
||||
* Content-Length
|
||||
* Request method
|
||||
* Response status code
|
||||
* Transfer-Encoding
|
||||
* HTTP version
|
||||
* Request URL
|
||||
* Message body
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
One `http_parser` object is used per TCP connection. Initialize the struct
|
||||
using `http_parser_init()` and set the callbacks. That might look something
|
||||
like this for a request parser:
|
||||
|
||||
http_parser_settings settings;
|
||||
settings.on_url = my_url_callback;
|
||||
settings.on_header_field = my_header_field_callback;
|
||||
/* ... */
|
||||
|
||||
http_parser *parser = malloc(sizeof(http_parser));
|
||||
http_parser_init(parser, HTTP_REQUEST);
|
||||
parser->data = my_socket;
|
||||
|
||||
When data is received on the socket execute the parser and check for errors.
|
||||
|
||||
size_t len = 80*1024, nparsed;
|
||||
char buf[len];
|
||||
ssize_t recved;
|
||||
|
||||
recved = recv(fd, buf, len, 0);
|
||||
|
||||
if (recved < 0) {
|
||||
/* Handle error. */
|
||||
}
|
||||
|
||||
/* Start up / continue the parser.
|
||||
* Note we pass recved==0 to signal that EOF has been recieved.
|
||||
*/
|
||||
nparsed = http_parser_execute(parser, &settings, buf, recved);
|
||||
|
||||
if (parser->upgrade) {
|
||||
/* handle new protocol */
|
||||
} else if (nparsed != recved) {
|
||||
/* Handle error. Usually just close the connection. */
|
||||
}
|
||||
|
||||
HTTP needs to know where the end of the stream is. For example, sometimes
|
||||
servers send responses without Content-Length and expect the client to
|
||||
consume input (for the body) until EOF. To tell http_parser about EOF, give
|
||||
`0` as the forth parameter to `http_parser_execute()`. Callbacks and errors
|
||||
can still be encountered during an EOF, so one must still be prepared
|
||||
to receive them.
|
||||
|
||||
Scalar valued message information such as `status_code`, `method`, and the
|
||||
HTTP version are stored in the parser structure. This data is only
|
||||
temporally stored in `http_parser` and gets reset on each new message. If
|
||||
this information is needed later, copy it out of the structure during the
|
||||
`headers_complete` callback.
|
||||
|
||||
The parser decodes the transfer-encoding for both requests and responses
|
||||
transparently. That is, a chunked encoding is decoded before being sent to
|
||||
the on_body callback.
|
||||
|
||||
|
||||
The Special Problem of Upgrade
|
||||
------------------------------
|
||||
|
||||
HTTP supports upgrading the connection to a different protocol. An
|
||||
increasingly common example of this is the Web Socket protocol which sends
|
||||
a request like
|
||||
|
||||
GET /demo HTTP/1.1
|
||||
Upgrade: WebSocket
|
||||
Connection: Upgrade
|
||||
Host: example.com
|
||||
Origin: http://example.com
|
||||
WebSocket-Protocol: sample
|
||||
|
||||
followed by non-HTTP data.
|
||||
|
||||
(See http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75 for more
|
||||
information the Web Socket protocol.)
|
||||
|
||||
To support this, the parser will treat this as a normal HTTP message without a
|
||||
body. Issuing both on_headers_complete and on_message_complete callbacks. However
|
||||
http_parser_execute() will stop parsing at the end of the headers and return.
|
||||
|
||||
The user is expected to check if `parser->upgrade` has been set to 1 after
|
||||
`http_parser_execute()` returns. Non-HTTP data begins at the buffer supplied
|
||||
offset by the return value of `http_parser_execute()`.
|
||||
|
||||
|
||||
Callbacks
|
||||
---------
|
||||
|
||||
During the `http_parser_execute()` call, the callbacks set in
|
||||
`http_parser_settings` will be executed. The parser maintains state and
|
||||
never looks behind, so buffering the data is not necessary. If you need to
|
||||
save certain data for later usage, you can do that from the callbacks.
|
||||
|
||||
There are two types of callbacks:
|
||||
|
||||
* notification `typedef int (*http_cb) (http_parser*);`
|
||||
Callbacks: on_message_begin, on_headers_complete, on_message_complete.
|
||||
* data `typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);`
|
||||
Callbacks: (requests only) on_uri,
|
||||
(common) on_header_field, on_header_value, on_body;
|
||||
|
||||
Callbacks must return 0 on success. Returning a non-zero value indicates
|
||||
error to the parser, making it exit immediately.
|
||||
|
||||
In case you parse HTTP message in chunks (i.e. `read()` request line
|
||||
from socket, parse, read half headers, parse, etc) your data callbacks
|
||||
may be called more than once. Http-parser guarantees that data pointer is only
|
||||
valid for the lifetime of callback. You can also `read()` into a heap allocated
|
||||
buffer to avoid copying memory around if this fits your application.
|
||||
|
||||
Reading headers may be a tricky task if you read/parse headers partially.
|
||||
Basically, you need to remember whether last header callback was field or value
|
||||
and apply following logic:
|
||||
|
||||
(on_header_field and on_header_value shortened to on_h_*)
|
||||
------------------------ ------------ --------------------------------------------
|
||||
| State (prev. callback) | Callback | Description/action |
|
||||
------------------------ ------------ --------------------------------------------
|
||||
| nothing (first call) | on_h_field | Allocate new buffer and copy callback data |
|
||||
| | | into it |
|
||||
------------------------ ------------ --------------------------------------------
|
||||
| value | on_h_field | New header started. |
|
||||
| | | Copy current name,value buffers to headers |
|
||||
| | | list and allocate new buffer for new name |
|
||||
------------------------ ------------ --------------------------------------------
|
||||
| field | on_h_field | Previous name continues. Reallocate name |
|
||||
| | | buffer and append callback data to it |
|
||||
------------------------ ------------ --------------------------------------------
|
||||
| field | on_h_value | Value for current header started. Allocate |
|
||||
| | | new buffer and copy callback data to it |
|
||||
------------------------ ------------ --------------------------------------------
|
||||
| value | on_h_value | Value continues. Reallocate value buffer |
|
||||
| | | and append callback data to it |
|
||||
------------------------ ------------ --------------------------------------------
|
||||
|
||||
|
||||
Parsing URLs
|
||||
------------
|
||||
|
||||
A simplistic zero-copy URL parser is provided as `http_parser_parse_url()`.
|
||||
Users of this library may wish to use it to parse URLs constructed from
|
||||
consecutive `on_url` callbacks.
|
||||
|
||||
See examples of reading in headers:
|
||||
|
||||
* [partial example](http://gist.github.com/155877) in C
|
||||
* [from http-parser tests](http://github.com/joyent/http-parser/blob/37a0ff8/test.c#L403) in C
|
||||
* [from Node library](http://github.com/joyent/node/blob/842eaf4/src/http.js#L284) in Javascript
|
||||
@@ -1,156 +0,0 @@
|
||||
/* Based on src/http/ngx_http_parse.c from NGINX copyright Igor Sysoev
|
||||
*
|
||||
* Additional changes are licensed under the same terms as NGINX and
|
||||
* copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* Dump what the parser finds to stdout as it happen */
|
||||
|
||||
#include "http_parser.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int on_message_begin(http_parser* _) {
|
||||
(void)_;
|
||||
printf("\n***MESSAGE BEGIN***\n\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int on_headers_complete(http_parser* _) {
|
||||
(void)_;
|
||||
printf("\n***HEADERS COMPLETE***\n\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int on_message_complete(http_parser* _) {
|
||||
(void)_;
|
||||
printf("\n***MESSAGE COMPLETE***\n\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int on_url(http_parser* _, const char* at, size_t length) {
|
||||
(void)_;
|
||||
printf("Url: %.*s\n", (int)length, at);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int on_header_field(http_parser* _, const char* at, size_t length) {
|
||||
(void)_;
|
||||
printf("Header field: %.*s\n", (int)length, at);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int on_header_value(http_parser* _, const char* at, size_t length) {
|
||||
(void)_;
|
||||
printf("Header value: %.*s\n", (int)length, at);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int on_body(http_parser* _, const char* at, size_t length) {
|
||||
(void)_;
|
||||
printf("Body: %.*s\n", (int)length, at);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void usage(const char* name) {
|
||||
fprintf(stderr,
|
||||
"Usage: %s $type $filename\n"
|
||||
" type: -x, where x is one of {r,b,q}\n"
|
||||
" parses file as a Response, reQuest, or Both\n",
|
||||
name);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
enum http_parser_type file_type;
|
||||
|
||||
if (argc != 3) {
|
||||
usage(argv[0]);
|
||||
}
|
||||
|
||||
char* type = argv[1];
|
||||
if (type[0] != '-') {
|
||||
usage(argv[0]);
|
||||
}
|
||||
|
||||
switch (type[1]) {
|
||||
/* in the case of "-", type[1] will be NUL */
|
||||
case 'r':
|
||||
file_type = HTTP_RESPONSE;
|
||||
break;
|
||||
case 'q':
|
||||
file_type = HTTP_REQUEST;
|
||||
break;
|
||||
case 'b':
|
||||
file_type = HTTP_BOTH;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
}
|
||||
|
||||
char* filename = argv[2];
|
||||
FILE* file = fopen(filename, "r");
|
||||
if (file == NULL) {
|
||||
perror("fopen");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
long file_length = ftell(file);
|
||||
if (file_length == -1) {
|
||||
perror("ftell");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
char* data = malloc(file_length);
|
||||
if (fread(data, 1, file_length, file) != (size_t)file_length) {
|
||||
fprintf(stderr, "couldn't read entire file\n");
|
||||
free(data);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
http_parser_settings settings;
|
||||
memset(&settings, 0, sizeof(settings));
|
||||
settings.on_message_begin = on_message_begin;
|
||||
settings.on_url = on_url;
|
||||
settings.on_header_field = on_header_field;
|
||||
settings.on_header_value = on_header_value;
|
||||
settings.on_headers_complete = on_headers_complete;
|
||||
settings.on_body = on_body;
|
||||
settings.on_message_complete = on_message_complete;
|
||||
|
||||
http_parser parser;
|
||||
http_parser_init(&parser, file_type);
|
||||
size_t nparsed = http_parser_execute(&parser, &settings, data, file_length);
|
||||
free(data);
|
||||
|
||||
if (nparsed != (size_t)file_length) {
|
||||
fprintf(stderr,
|
||||
"Error: %s (%s)\n",
|
||||
http_errno_description(HTTP_PARSER_ERRNO(&parser)),
|
||||
http_errno_name(HTTP_PARSER_ERRNO(&parser)));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
#include "http_parser.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
dump_url (const char *url, const struct http_parser_url *u)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
printf("\tfield_set: 0x%x, port: %u\n", u->field_set, u->port);
|
||||
for (i = 0; i < UF_MAX; i++) {
|
||||
if ((u->field_set & (1 << i)) == 0) {
|
||||
printf("\tfield_data[%u]: unset\n", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("\tfield_data[%u]: off: %u len: %u part: \"%.*s\n",
|
||||
i,
|
||||
u->field_data[i].off,
|
||||
u->field_data[i].len,
|
||||
u->field_data[i].len,
|
||||
url + u->field_data[i].off);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
if (argc != 3) {
|
||||
printf("Syntax : %s connect|get url\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
struct http_parser_url u;
|
||||
int len = strlen(argv[2]);
|
||||
int connect = strcmp("connect", argv[1]) == 0 ? 1 : 0;
|
||||
printf("Parsing %s, connect %d\n", argv[2], connect);
|
||||
|
||||
int result = http_parser_parse_url(argv[2], len, connect, &u);
|
||||
if (result != 0) {
|
||||
printf("Parse error : %d\n", result);
|
||||
return result;
|
||||
}
|
||||
printf("Parse ok, result : \n");
|
||||
dump_url(argv[2], &u);
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,111 +0,0 @@
|
||||
# This file is used with the GYP meta build system.
|
||||
# http://code.google.com/p/gyp/
|
||||
# To build try this:
|
||||
# svn co http://gyp.googlecode.com/svn/trunk gyp
|
||||
# ./gyp/gyp -f make --depth=`pwd` http_parser.gyp
|
||||
# ./out/Debug/test
|
||||
{
|
||||
'target_defaults': {
|
||||
'default_configuration': 'Debug',
|
||||
'configurations': {
|
||||
# TODO: hoist these out and put them somewhere common, because
|
||||
# RuntimeLibrary MUST MATCH across the entire project
|
||||
'Debug': {
|
||||
'defines': [ 'DEBUG', '_DEBUG' ],
|
||||
'cflags': [ '-Wall', '-Wextra', '-O0', '-g', '-ftrapv' ],
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
'RuntimeLibrary': 1, # static debug
|
||||
},
|
||||
},
|
||||
},
|
||||
'Release': {
|
||||
'defines': [ 'NDEBUG' ],
|
||||
'cflags': [ '-Wall', '-Wextra', '-O3' ],
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
'RuntimeLibrary': 0, # static release
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
},
|
||||
'VCLibrarianTool': {
|
||||
},
|
||||
'VCLinkerTool': {
|
||||
'GenerateDebugInformation': 'true',
|
||||
},
|
||||
},
|
||||
'conditions': [
|
||||
['OS == "win"', {
|
||||
'defines': [
|
||||
'WIN32'
|
||||
],
|
||||
}]
|
||||
],
|
||||
},
|
||||
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'http_parser',
|
||||
'type': 'static_library',
|
||||
'include_dirs': [ '.' ],
|
||||
'direct_dependent_settings': {
|
||||
'defines': [ 'HTTP_PARSER_STRICT=0' ],
|
||||
'include_dirs': [ '.' ],
|
||||
},
|
||||
'defines': [ 'HTTP_PARSER_STRICT=0' ],
|
||||
'sources': [ './http_parser.c', ],
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
# Compile as C++. http_parser.c is actually C99, but C++ is
|
||||
# close enough in this case.
|
||||
'CompileAs': 2,
|
||||
},
|
||||
},
|
||||
}]
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
'target_name': 'http_parser_strict',
|
||||
'type': 'static_library',
|
||||
'include_dirs': [ '.' ],
|
||||
'direct_dependent_settings': {
|
||||
'defines': [ 'HTTP_PARSER_STRICT=1' ],
|
||||
'include_dirs': [ '.' ],
|
||||
},
|
||||
'defines': [ 'HTTP_PARSER_STRICT=1' ],
|
||||
'sources': [ './http_parser.c', ],
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
# Compile as C++. http_parser.c is actually C99, but C++ is
|
||||
# close enough in this case.
|
||||
'CompileAs': 2,
|
||||
},
|
||||
},
|
||||
}]
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
'target_name': 'test-nonstrict',
|
||||
'type': 'executable',
|
||||
'dependencies': [ 'http_parser' ],
|
||||
'sources': [ 'test.c' ]
|
||||
},
|
||||
|
||||
{
|
||||
'target_name': 'test-strict',
|
||||
'type': 'executable',
|
||||
'dependencies': [ 'http_parser_strict' ],
|
||||
'sources': [ 'test.c' ]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,318 +0,0 @@
|
||||
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef http_parser_h
|
||||
#define http_parser_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Also update SONAME in the Makefile whenever you change these. */
|
||||
#define HTTP_PARSER_VERSION_MAJOR 2
|
||||
#define HTTP_PARSER_VERSION_MINOR 1
|
||||
#define HTTP_PARSER_VERSION_PATCH 0
|
||||
|
||||
#include <sys/types.h>
|
||||
#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600)
|
||||
#include <BaseTsd.h>
|
||||
#include <stddef.h>
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
/* Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run
|
||||
* faster
|
||||
*/
|
||||
#ifndef HTTP_PARSER_STRICT
|
||||
# define HTTP_PARSER_STRICT 1
|
||||
#endif
|
||||
|
||||
/* Maximium header size allowed */
|
||||
#define HTTP_MAX_HEADER_SIZE (80*1024)
|
||||
|
||||
|
||||
typedef struct http_parser http_parser;
|
||||
typedef struct http_parser_settings http_parser_settings;
|
||||
|
||||
|
||||
/* Callbacks should return non-zero to indicate an error. The parser will
|
||||
* then halt execution.
|
||||
*
|
||||
* The one exception is on_headers_complete. In a HTTP_RESPONSE parser
|
||||
* returning '1' from on_headers_complete will tell the parser that it
|
||||
* should not expect a body. This is used when receiving a response to a
|
||||
* HEAD request which may contain 'Content-Length' or 'Transfer-Encoding:
|
||||
* chunked' headers that indicate the presence of a body.
|
||||
*
|
||||
* http_data_cb does not return data chunks. It will be call arbitrarally
|
||||
* many times for each string. E.G. you might get 10 callbacks for "on_url"
|
||||
* each providing just a few characters more data.
|
||||
*/
|
||||
typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);
|
||||
typedef int (*http_cb) (http_parser*);
|
||||
|
||||
|
||||
/* Request Methods */
|
||||
#define HTTP_METHOD_MAP(XX) \
|
||||
XX(0, DELETE, DELETE) \
|
||||
XX(1, GET, GET) \
|
||||
XX(2, HEAD, HEAD) \
|
||||
XX(3, POST, POST) \
|
||||
XX(4, PUT, PUT) \
|
||||
/* pathological */ \
|
||||
XX(5, CONNECT, CONNECT) \
|
||||
XX(6, OPTIONS, OPTIONS) \
|
||||
XX(7, TRACE, TRACE) \
|
||||
/* webdav */ \
|
||||
XX(8, COPY, COPY) \
|
||||
XX(9, LOCK, LOCK) \
|
||||
XX(10, MKCOL, MKCOL) \
|
||||
XX(11, MOVE, MOVE) \
|
||||
XX(12, PROPFIND, PROPFIND) \
|
||||
XX(13, PROPPATCH, PROPPATCH) \
|
||||
XX(14, SEARCH, SEARCH) \
|
||||
XX(15, UNLOCK, UNLOCK) \
|
||||
/* subversion */ \
|
||||
XX(16, REPORT, REPORT) \
|
||||
XX(17, MKACTIVITY, MKACTIVITY) \
|
||||
XX(18, CHECKOUT, CHECKOUT) \
|
||||
XX(19, MERGE, MERGE) \
|
||||
/* upnp */ \
|
||||
XX(20, MSEARCH, M-SEARCH) \
|
||||
XX(21, NOTIFY, NOTIFY) \
|
||||
XX(22, SUBSCRIBE, SUBSCRIBE) \
|
||||
XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \
|
||||
/* RFC-5789 */ \
|
||||
XX(24, PATCH, PATCH) \
|
||||
XX(25, PURGE, PURGE) \
|
||||
|
||||
enum http_method
|
||||
{
|
||||
#define XX(num, name, string) HTTP_##name = num,
|
||||
HTTP_METHOD_MAP(XX)
|
||||
#undef XX
|
||||
};
|
||||
|
||||
|
||||
enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
|
||||
|
||||
|
||||
/* Flag values for http_parser.flags field */
|
||||
enum flags
|
||||
{ F_CHUNKED = 1 << 0
|
||||
, F_CONNECTION_KEEP_ALIVE = 1 << 1
|
||||
, F_CONNECTION_CLOSE = 1 << 2
|
||||
, F_TRAILING = 1 << 3
|
||||
, F_UPGRADE = 1 << 4
|
||||
, F_SKIPBODY = 1 << 5
|
||||
};
|
||||
|
||||
|
||||
/* Map for errno-related constants
|
||||
*
|
||||
* The provided argument should be a macro that takes 2 arguments.
|
||||
*/
|
||||
#define HTTP_ERRNO_MAP(XX) \
|
||||
/* No error */ \
|
||||
XX(OK, "success") \
|
||||
\
|
||||
/* Callback-related errors */ \
|
||||
XX(CB_message_begin, "the on_message_begin callback failed") \
|
||||
XX(CB_status_complete, "the on_status_complete callback failed") \
|
||||
XX(CB_url, "the on_url callback failed") \
|
||||
XX(CB_header_field, "the on_header_field callback failed") \
|
||||
XX(CB_header_value, "the on_header_value callback failed") \
|
||||
XX(CB_headers_complete, "the on_headers_complete callback failed") \
|
||||
XX(CB_body, "the on_body callback failed") \
|
||||
XX(CB_message_complete, "the on_message_complete callback failed") \
|
||||
\
|
||||
/* Parsing-related errors */ \
|
||||
XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \
|
||||
XX(HEADER_OVERFLOW, \
|
||||
"too many header bytes seen; overflow detected") \
|
||||
XX(CLOSED_CONNECTION, \
|
||||
"data received after completed connection: close message") \
|
||||
XX(INVALID_VERSION, "invalid HTTP version") \
|
||||
XX(INVALID_STATUS, "invalid HTTP status code") \
|
||||
XX(INVALID_METHOD, "invalid HTTP method") \
|
||||
XX(INVALID_URL, "invalid URL") \
|
||||
XX(INVALID_HOST, "invalid host") \
|
||||
XX(INVALID_PORT, "invalid port") \
|
||||
XX(INVALID_PATH, "invalid path") \
|
||||
XX(INVALID_QUERY_STRING, "invalid query string") \
|
||||
XX(INVALID_FRAGMENT, "invalid fragment") \
|
||||
XX(LF_EXPECTED, "LF character expected") \
|
||||
XX(INVALID_HEADER_TOKEN, "invalid character in header") \
|
||||
XX(INVALID_CONTENT_LENGTH, \
|
||||
"invalid character in content-length header") \
|
||||
XX(INVALID_CHUNK_SIZE, \
|
||||
"invalid character in chunk size header") \
|
||||
XX(INVALID_CONSTANT, "invalid constant string") \
|
||||
XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\
|
||||
XX(STRICT, "strict mode assertion failed") \
|
||||
XX(PAUSED, "parser is paused") \
|
||||
XX(UNKNOWN, "an unknown error occurred")
|
||||
|
||||
|
||||
/* Define HPE_* values for each errno value above */
|
||||
#define HTTP_ERRNO_GEN(n, s) HPE_##n,
|
||||
enum http_errno {
|
||||
HTTP_ERRNO_MAP(HTTP_ERRNO_GEN)
|
||||
};
|
||||
#undef HTTP_ERRNO_GEN
|
||||
|
||||
|
||||
/* Get an http_errno value from an http_parser */
|
||||
#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno)
|
||||
|
||||
|
||||
struct http_parser {
|
||||
/** PRIVATE **/
|
||||
unsigned char type : 2; /* enum http_parser_type */
|
||||
unsigned char flags : 6; /* F_* values from 'flags' enum; semi-public */
|
||||
unsigned char state; /* enum state from http_parser.c */
|
||||
unsigned char header_state; /* enum header_state from http_parser.c */
|
||||
unsigned char index; /* index into current matcher */
|
||||
|
||||
uint32_t nread; /* # bytes read in various scenarios */
|
||||
uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */
|
||||
|
||||
/** READ-ONLY **/
|
||||
unsigned short http_major;
|
||||
unsigned short http_minor;
|
||||
unsigned short status_code; /* responses only */
|
||||
unsigned char method; /* requests only */
|
||||
unsigned char http_errno : 7;
|
||||
|
||||
/* 1 = Upgrade header was present and the parser has exited because of that.
|
||||
* 0 = No upgrade header present.
|
||||
* Should be checked when http_parser_execute() returns in addition to
|
||||
* error checking.
|
||||
*/
|
||||
unsigned char upgrade : 1;
|
||||
|
||||
/** PUBLIC **/
|
||||
void *data; /* A pointer to get hook to the "connection" or "socket" object */
|
||||
};
|
||||
|
||||
|
||||
struct http_parser_settings {
|
||||
http_cb on_message_begin;
|
||||
http_data_cb on_url;
|
||||
http_cb on_status_complete;
|
||||
http_data_cb on_header_field;
|
||||
http_data_cb on_header_value;
|
||||
http_cb on_headers_complete;
|
||||
http_data_cb on_body;
|
||||
http_cb on_message_complete;
|
||||
};
|
||||
|
||||
|
||||
enum http_parser_url_fields
|
||||
{ UF_SCHEMA = 0
|
||||
, UF_HOST = 1
|
||||
, UF_PORT = 2
|
||||
, UF_PATH = 3
|
||||
, UF_QUERY = 4
|
||||
, UF_FRAGMENT = 5
|
||||
, UF_USERINFO = 6
|
||||
, UF_MAX = 7
|
||||
};
|
||||
|
||||
|
||||
/* Result structure for http_parser_parse_url().
|
||||
*
|
||||
* Callers should index into field_data[] with UF_* values iff field_set
|
||||
* has the relevant (1 << UF_*) bit set. As a courtesy to clients (and
|
||||
* because we probably have padding left over), we convert any port to
|
||||
* a uint16_t.
|
||||
*/
|
||||
struct http_parser_url {
|
||||
uint16_t field_set; /* Bitmask of (1 << UF_*) values */
|
||||
uint16_t port; /* Converted UF_PORT string */
|
||||
|
||||
struct {
|
||||
uint16_t off; /* Offset into buffer in which field starts */
|
||||
uint16_t len; /* Length of run in buffer */
|
||||
} field_data[UF_MAX];
|
||||
};
|
||||
|
||||
|
||||
/* Returns the library version. Bits 16-23 contain the major version number,
|
||||
* bits 8-15 the minor version number and bits 0-7 the patch level.
|
||||
* Usage example:
|
||||
*
|
||||
* unsigned long version = http_parser_version();
|
||||
* unsigned major = (version >> 16) & 255;
|
||||
* unsigned minor = (version >> 8) & 255;
|
||||
* unsigned patch = version & 255;
|
||||
* printf("http_parser v%u.%u.%u\n", major, minor, version);
|
||||
*/
|
||||
unsigned long http_parser_version(void);
|
||||
|
||||
void http_parser_init(http_parser *parser, enum http_parser_type type);
|
||||
|
||||
|
||||
size_t http_parser_execute(http_parser *parser,
|
||||
const http_parser_settings *settings,
|
||||
const char *data,
|
||||
size_t len);
|
||||
|
||||
|
||||
/* If http_should_keep_alive() in the on_headers_complete or
|
||||
* on_message_complete callback returns 0, then this should be
|
||||
* the last message on the connection.
|
||||
* If you are the server, respond with the "Connection: close" header.
|
||||
* If you are the client, close the connection.
|
||||
*/
|
||||
int http_should_keep_alive(const http_parser *parser);
|
||||
|
||||
/* Returns a string version of the HTTP method. */
|
||||
const char *http_method_str(enum http_method m);
|
||||
|
||||
/* Return a string name of the given error */
|
||||
const char *http_errno_name(enum http_errno err);
|
||||
|
||||
/* Return a string description of the given error */
|
||||
const char *http_errno_description(enum http_errno err);
|
||||
|
||||
/* Parse a URL; return nonzero on failure */
|
||||
int http_parser_parse_url(const char *buf, size_t buflen,
|
||||
int is_connect,
|
||||
struct http_parser_url *u);
|
||||
|
||||
/* Pause or un-pause the parser; a nonzero value pauses */
|
||||
void http_parser_pause(http_parser *parser, int paused);
|
||||
|
||||
/* Checks if this is the final chunk of the body. */
|
||||
int http_body_is_final(const http_parser *parser);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -180,7 +180,6 @@ namespace beast
|
||||
#include "network/MACAddress.cpp"
|
||||
#include "network/NamedPipe.cpp"
|
||||
#include "network/Socket.cpp"
|
||||
#include "network/URL.cpp"
|
||||
#include "network/IPAddress.cpp"
|
||||
|
||||
#include "streams/BufferedInputStream.cpp"
|
||||
@@ -193,11 +192,9 @@ namespace beast
|
||||
|
||||
#include "system/SystemStats.cpp"
|
||||
|
||||
#include "text/CharacterFunctions.cpp"
|
||||
#include "text/LexicalCast.cpp"
|
||||
#include "text/Identifier.cpp"
|
||||
#include "text/LocalisedStrings.cpp"
|
||||
#include "text/String.cpp"
|
||||
#include "text/StringArray.cpp"
|
||||
#include "text/StringPairArray.cpp"
|
||||
#include "text/StringPool.cpp"
|
||||
@@ -293,6 +290,17 @@ namespace beast
|
||||
|
||||
}
|
||||
|
||||
// Has to be outside the beast namespace
|
||||
extern "C" {
|
||||
void beast_reportFatalError (char const* message, char const* fileName, int lineNumber)
|
||||
{
|
||||
if (beast::beast_isRunningUnderDebugger())
|
||||
beast_breakDebugger;
|
||||
beast::FatalError (message, fileName, lineNumber);
|
||||
BEAST_ANALYZER_NORETURN
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
#pragma pop_macro("calloc")
|
||||
#pragma pop_macro("free")
|
||||
|
||||
@@ -26,13 +26,11 @@
|
||||
|
||||
// TargetPlatform.h should not use anything from BeastConfig.h
|
||||
#include "../../beast/Config.h"
|
||||
#include "system/BeastConfigCheck.h"
|
||||
#include "../../beast/config/ContractChecks.h"
|
||||
|
||||
# include "system/BeforeBoost.h"
|
||||
# include "system/BoostIncludes.h"
|
||||
#include "system/FunctionalIncludes.h"
|
||||
#include "system/PlatformDefs.h"
|
||||
#include "system/StandardHeader.h"
|
||||
|
||||
#if BEAST_MSVC
|
||||
# pragma warning (disable: 4251) // (DLL build warning, must be disabled before pushing the warning state)
|
||||
@@ -43,6 +41,53 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// New header-only library modeled more closely according to boost
|
||||
#include "../../beast/CStdInt.h"
|
||||
#include "../../beast/StaticAssert.h"
|
||||
#include "../../beast/Uncopyable.h"
|
||||
#include "../../beast/Atomic.h"
|
||||
#include "../../beast/Arithmetic.h"
|
||||
#include "../../beast/ByteOrder.h"
|
||||
#include "../../beast/HeapBlock.h"
|
||||
#include "../../beast/Memory.h"
|
||||
#include "../../beast/Intrusive.h"
|
||||
#include "../../beast/Net.h"
|
||||
#include "../../beast/Strings.h"
|
||||
#include "../../beast/TypeTraits.h"
|
||||
#include "../../beast/Thread.h"
|
||||
#include "../../beast/Utility.h"
|
||||
|
||||
#include "system/StandardIncludes.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
class InputStream;
|
||||
class OutputStream;
|
||||
class FileInputStream;
|
||||
class FileOutputStream;
|
||||
|
||||
// Order matters, since headers don't have their own #include lines.
|
||||
// Add new includes to the bottom.
|
||||
|
||||
#include "diagnostic/Throw.h"
|
||||
#include "system/Functional.h"
|
||||
#include "memory/AtomicCounter.h"
|
||||
#include "memory/AtomicFlag.h"
|
||||
#include "memory/AtomicPointer.h"
|
||||
#include "memory/AtomicState.h"
|
||||
#include "threads/SpinDelay.h"
|
||||
#include "memory/StaticObject.h"
|
||||
|
||||
#include "time/AtExitHook.h"
|
||||
#include "diagnostic/LeakChecked.h"
|
||||
#include "time/RelativeTime.h"
|
||||
#include "time/Time.h"
|
||||
#include "threads/ScopedLock.h"
|
||||
#include "threads/CriticalSection.h"
|
||||
#include "containers/ElementComparator.h"
|
||||
|
||||
// If the MSVC debug heap headers were included, disable
|
||||
// the macros during the juce include since they conflict.
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
@@ -73,75 +118,25 @@
|
||||
#undef _aligned_offset_recalloc
|
||||
#undef _aligned_msize
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace beast {
|
||||
extern BEAST_API bool BEAST_CALLTYPE beast_isRunningUnderDebugger();
|
||||
extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) noexcept;
|
||||
}
|
||||
|
||||
// New header-only library modeled more closely according to boost
|
||||
#include "../../beast/CStdInt.h"
|
||||
#include "../../beast/StaticAssert.h"
|
||||
#include "../../beast/Uncopyable.h"
|
||||
#include "../../beast/Atomic.h"
|
||||
#include "../../beast/Intrusive.h"
|
||||
#include "../../beast/Net.h"
|
||||
#include "../../beast/TypeTraits.h"
|
||||
#include "../../beast/Thread.h"
|
||||
#include "../../beast/Utility.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
class InputStream;
|
||||
class OutputStream;
|
||||
class FileInputStream;
|
||||
class FileOutputStream;
|
||||
|
||||
// Order matters, since headers don't have their own #include lines.
|
||||
// Add new includes to the bottom.
|
||||
|
||||
#include "diagnostic/ContractChecks.h"
|
||||
#include "memory/Memory.h"
|
||||
#include "maths/MathsFunctions.h"
|
||||
#include "memory/ByteOrder.h"
|
||||
#include "text/CharacterFunctions.h"
|
||||
|
||||
#if BEAST_MSVC
|
||||
# pragma warning (push)
|
||||
# pragma warning (disable: 4514 4996)
|
||||
#endif
|
||||
#include "text/CharPointer_UTF8.h"
|
||||
#include "text/CharPointer_UTF16.h"
|
||||
#include "text/CharPointer_UTF32.h"
|
||||
#include "text/CharPointer_ASCII.h"
|
||||
#if BEAST_MSVC
|
||||
# pragma warning (pop)
|
||||
#endif
|
||||
|
||||
#include "diagnostic/Throw.h"
|
||||
#include "system/Functional.h"
|
||||
#include "memory/AtomicCounter.h"
|
||||
#include "memory/AtomicFlag.h"
|
||||
#include "memory/AtomicPointer.h"
|
||||
#include "memory/AtomicState.h"
|
||||
#include "threads/SpinDelay.h"
|
||||
#include "memory/StaticObject.h"
|
||||
|
||||
#include "text/StringCharPointerType.h"
|
||||
#include "text/StringFromNumber.h"
|
||||
#include "text/String.h"
|
||||
#include "time/AtExitHook.h"
|
||||
#include "diagnostic/LeakChecked.h"
|
||||
#include "time/RelativeTime.h"
|
||||
#include "time/Time.h"
|
||||
#include "memory/HeapBlock.h"
|
||||
#include "threads/ScopedLock.h"
|
||||
#include "threads/CriticalSection.h"
|
||||
#include "containers/ElementComparator.h"
|
||||
#include "containers/ArrayAllocationBase.h"
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
#pragma pop_macro("_aligned_msize")
|
||||
#pragma pop_macro("_aligned_offset_recalloc")
|
||||
#pragma pop_macro("_aligned_offset_realloc")
|
||||
#pragma pop_macro("_aligned_recalloc")
|
||||
#pragma pop_macro("_aligned_realloc")
|
||||
#pragma pop_macro("_aligned_offset_malloc")
|
||||
#pragma pop_macro("_aligned_malloc")
|
||||
#pragma pop_macro("_aligned_free")
|
||||
#pragma pop_macro("_recalloc")
|
||||
#pragma pop_macro("realloc")
|
||||
#pragma pop_macro("malloc")
|
||||
#pragma pop_macro("free")
|
||||
#pragma pop_macro("calloc")
|
||||
#endif
|
||||
|
||||
#include "containers/Array.h"
|
||||
|
||||
#include "misc/Result.h"
|
||||
#include "text/StringArray.h"
|
||||
#include "memory/MemoryBlock.h"
|
||||
@@ -163,7 +158,6 @@ class FileOutputStream;
|
||||
#include "diagnostic/Debug.h"
|
||||
#include "text/LexicalCast.h"
|
||||
#include "memory/ContainerDeletePolicy.h"
|
||||
#include "memory/ByteSwap.h"
|
||||
#include "maths/Math.h"
|
||||
#include "maths/uint24.h"
|
||||
#include "logging/Logger.h"
|
||||
@@ -200,7 +194,6 @@ class FileOutputStream;
|
||||
#include "files/FileInputStream.h"
|
||||
#include "streams/InputSource.h"
|
||||
#include "streams/FileInputSource.h"
|
||||
#include "text/NewLine.h"
|
||||
#include "streams/OutputStream.h"
|
||||
#include "files/FileOutputStream.h"
|
||||
#include "files/FileSearchPath.h"
|
||||
@@ -212,10 +205,7 @@ class FileOutputStream;
|
||||
#include "logging/Logger.h"
|
||||
#include "maths/Expression.h"
|
||||
#include "maths/Interval.h"
|
||||
#include "maths/MathsFunctions.h"
|
||||
#include "maths/MurmurHash.h"
|
||||
#include "memory/ByteOrder.h"
|
||||
#include "memory/Memory.h"
|
||||
#include "memory/OptionalScopedPointer.h"
|
||||
#include "memory/SharedSingleton.h"
|
||||
#include "memory/WeakReference.h"
|
||||
@@ -228,7 +218,6 @@ class FileOutputStream;
|
||||
#include "threads/ReadWriteLock.h"
|
||||
#include "network/NamedPipe.h"
|
||||
#include "network/Socket.h"
|
||||
#include "network/URL.h"
|
||||
#include "streams/BufferedInputStream.h"
|
||||
#include "streams/MemoryInputStream.h"
|
||||
#include "streams/MemoryOutputStream.h"
|
||||
@@ -279,22 +268,6 @@ class FileOutputStream;
|
||||
|
||||
}
|
||||
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
#pragma pop_macro("_aligned_msize")
|
||||
#pragma pop_macro("_aligned_offset_recalloc")
|
||||
#pragma pop_macro("_aligned_offset_realloc")
|
||||
#pragma pop_macro("_aligned_recalloc")
|
||||
#pragma pop_macro("_aligned_realloc")
|
||||
#pragma pop_macro("_aligned_offset_malloc")
|
||||
#pragma pop_macro("_aligned_malloc")
|
||||
#pragma pop_macro("_aligned_free")
|
||||
#pragma pop_macro("_recalloc")
|
||||
#pragma pop_macro("realloc")
|
||||
#pragma pop_macro("malloc")
|
||||
#pragma pop_macro("free")
|
||||
#pragma pop_macro("calloc")
|
||||
#endif
|
||||
|
||||
#if BEAST_MSVC
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
|
||||
@@ -107,14 +107,6 @@ FatalError::FatalError (char const* message, char const* fileName, int lineNumbe
|
||||
Process::terminate ();
|
||||
}
|
||||
|
||||
void reportFatalError (char const* message, char const* fileName, int lineNumber)
|
||||
{
|
||||
if (beast::beast_isRunningUnderDebugger())
|
||||
beast_breakDebugger;
|
||||
FatalError (message, fileName, lineNumber);
|
||||
BEAST_ANALYZER_NORETURN
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Yes even this class can have a unit test. It's manually triggered though.
|
||||
|
||||
@@ -146,11 +146,4 @@ private:
|
||||
static Reporter* s_reporter;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Report a fatal error message and terminate the application.
|
||||
Normally you won't call this directly.
|
||||
*/
|
||||
extern void reportFatalError (char const* message, char const* fileName, int lineNumber);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -44,7 +44,7 @@ void Logger::writeToLog (const String& message)
|
||||
}
|
||||
|
||||
#if BEAST_LOG_ASSERTIONS || BEAST_DEBUG
|
||||
void BEAST_API BEAST_CALLTYPE logAssertion (const char* const filename, const int lineNum) noexcept
|
||||
void logAssertion (const char* const filename, const int lineNum) noexcept
|
||||
{
|
||||
String m ("BEAST Assertion failure in ");
|
||||
m << File::createFileWithoutCheckingPath (filename).getFileName() << ':' << lineNum;
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
/** Writes a message to the standard error stream.
|
||||
|
||||
This can be called directly, or by using the DBG() macro in
|
||||
PlatformDefs.h (which will avoid calling the method in non-debug builds).
|
||||
CompilerConfig.h (which will avoid calling the method in non-debug builds).
|
||||
*/
|
||||
static void BEAST_CALLTYPE outputDebugString (const String& text);
|
||||
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_BYTESWAP_H_INCLUDED
|
||||
#define BEAST_BYTESWAP_H_INCLUDED
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/** Specialized helper class template for swapping bytes.
|
||||
|
||||
Normally you won't use this directly, use the helper function
|
||||
byteSwap instead. You can specialize this class for your
|
||||
own user defined types, as was done for uint24.
|
||||
|
||||
@see swapBytes, uint24
|
||||
*/
|
||||
template <typename IntegralType>
|
||||
struct SwapBytes
|
||||
{
|
||||
inline IntegralType operator() (IntegralType value) const noexcept
|
||||
{
|
||||
return ByteOrder::swap (value);
|
||||
}
|
||||
};
|
||||
|
||||
// Specializations for signed integers
|
||||
|
||||
template <>
|
||||
struct SwapBytes <int16>
|
||||
{
|
||||
inline int16 operator() (int16 value) const noexcept
|
||||
{
|
||||
return static_cast <int16> (ByteOrder::swap (static_cast <uint16> (value)));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct SwapBytes <int32>
|
||||
{
|
||||
inline int32 operator() (int32 value) const noexcept
|
||||
{
|
||||
return static_cast <int32> (ByteOrder::swap (static_cast <uint32> (value)));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct SwapBytes <int64>
|
||||
{
|
||||
inline int64 operator() (int64 value) const noexcept
|
||||
{
|
||||
return static_cast <int64> (ByteOrder::swap (static_cast <uint64> (value)));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Returns a type with the bytes swapped.
|
||||
Little endian becomes big endian and vice versa. The underlying
|
||||
type must be an integral type or behave like one.
|
||||
*/
|
||||
template <class IntegralType>
|
||||
inline IntegralType swapBytes (IntegralType value) noexcept
|
||||
{
|
||||
return detail::SwapBytes <IntegralType> () (value);
|
||||
}
|
||||
|
||||
/** Returns the machine byte-order value to little-endian byte order. */
|
||||
template <typename IntegralType>
|
||||
inline IntegralType toLittleEndian (IntegralType value) noexcept
|
||||
{
|
||||
#if BEAST_LITTLE_ENDIAN
|
||||
return value;
|
||||
#else
|
||||
return swapBytes (value);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Returns the machine byte-order value to big-endian byte order. */
|
||||
template <typename IntegralType>
|
||||
inline IntegralType toBigEndian (IntegralType value) noexcept
|
||||
{
|
||||
#if BEAST_LITTLE_ENDIAN
|
||||
return swapBytes (value);
|
||||
#else
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Returns the machine byte-order value to network byte order. */
|
||||
template <typename IntegralType>
|
||||
inline IntegralType toNetworkByteOrder (IntegralType value) noexcept
|
||||
{
|
||||
return toBigEndian (value);
|
||||
}
|
||||
|
||||
/** Converts from network byte order to machine byte order. */
|
||||
template <typename IntegralType>
|
||||
inline IntegralType fromNetworkByteOrder (IntegralType value) noexcept
|
||||
{
|
||||
#if BEAST_LITTLE_ENDIAN
|
||||
return swapBytes (value);
|
||||
#else
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -57,114 +57,3 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress,
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class WebInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <WebInputStream>
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
WebInputStream (String address, bool isPost, const MemoryBlock& postData,
|
||||
URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
|
||||
const String& headers, int timeOutMs, StringPairArray* responseHeaders)
|
||||
{
|
||||
if (! address.contains ("://"))
|
||||
address = "http://" + address;
|
||||
|
||||
JNIEnv* env = getEnv();
|
||||
|
||||
jbyteArray postDataArray = 0;
|
||||
|
||||
if (postData.getSize() > 0)
|
||||
{
|
||||
postDataArray = env->NewByteArray (postData.getSize());
|
||||
env->SetByteArrayRegion (postDataArray, 0, postData.getSize(), (const jbyte*) postData.getData());
|
||||
}
|
||||
|
||||
LocalRef<jobject> responseHeaderBuffer (env->NewObject (StringBuffer, StringBuffer.constructor));
|
||||
|
||||
stream = GlobalRef (env->CallStaticObjectMethod (BeastAppActivity,
|
||||
BeastAppActivity.createHTTPStream,
|
||||
javaString (address).get(),
|
||||
(jboolean) isPost,
|
||||
postDataArray,
|
||||
javaString (headers).get(),
|
||||
(jint) timeOutMs,
|
||||
responseHeaderBuffer.get()));
|
||||
|
||||
if (postDataArray != 0)
|
||||
env->DeleteLocalRef (postDataArray);
|
||||
|
||||
if (stream != 0)
|
||||
{
|
||||
StringArray headerLines;
|
||||
|
||||
{
|
||||
LocalRef<jstring> headersString ((jstring) env->CallObjectMethod (responseHeaderBuffer.get(),
|
||||
StringBuffer.toString));
|
||||
headerLines.addLines (beastString (env, headersString));
|
||||
}
|
||||
|
||||
if (responseHeaders != 0)
|
||||
{
|
||||
for (int i = 0; i < headerLines.size(); ++i)
|
||||
{
|
||||
const String& header = headerLines[i];
|
||||
const String key (header.upToFirstOccurrenceOf (": ", false, false));
|
||||
const String value (header.fromFirstOccurrenceOf (": ", false, false));
|
||||
const String previousValue ((*responseHeaders) [key]);
|
||||
|
||||
responseHeaders->set (key, previousValue.isEmpty() ? value : (previousValue + "," + value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~WebInputStream()
|
||||
{
|
||||
if (stream != 0)
|
||||
stream.callVoidMethod (HTTPStream.release);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool isExhausted() { return stream != nullptr && stream.callBooleanMethod (HTTPStream.isExhausted); }
|
||||
int64 getTotalLength() { return stream != nullptr ? stream.callLongMethod (HTTPStream.getTotalLength) : 0; }
|
||||
int64 getPosition() { return stream != nullptr ? stream.callLongMethod (HTTPStream.getPosition) : 0; }
|
||||
bool setPosition (int64 wantedPos) { return stream != nullptr && stream.callBooleanMethod (HTTPStream.setPosition, (jlong) wantedPos); }
|
||||
|
||||
int read (void* buffer, int bytesToRead)
|
||||
{
|
||||
bassert (buffer != nullptr && bytesToRead >= 0);
|
||||
|
||||
if (stream == nullptr)
|
||||
return 0;
|
||||
|
||||
JNIEnv* env = getEnv();
|
||||
|
||||
jbyteArray javaArray = env->NewByteArray (bytesToRead);
|
||||
|
||||
int numBytes = stream.callIntMethod (HTTPStream.read, javaArray, (jint) bytesToRead);
|
||||
|
||||
if (numBytes > 0)
|
||||
env->GetByteArrayRegion (javaArray, 0, numBytes, static_cast <jbyte*> (buffer));
|
||||
|
||||
env->DeleteLocalRef (javaArray);
|
||||
return numBytes;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
GlobalRef stream;
|
||||
};
|
||||
|
||||
InputStream* URL::createNativeStream (const String& address, bool isPost, const MemoryBlock& postData,
|
||||
OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
|
||||
const String& headers, const int timeOutMs, StringPairArray* responseHeaders)
|
||||
{
|
||||
ScopedPointer <WebInputStream> wi (new WebInputStream (address, isPost, postData,
|
||||
progressCallback, progressCallbackContext,
|
||||
headers, timeOutMs, responseHeaders));
|
||||
|
||||
return wi->stream != 0 ? wi.release() : nullptr;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ void Process::setPriority (ProcessPriority prior)
|
||||
pthread_setschedparam (pthread_self(), policy, ¶m);
|
||||
}
|
||||
|
||||
BEAST_API bool BEAST_CALLTYPE beast_isRunningUnderDebugger()
|
||||
bool beast_isRunningUnderDebugger()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,399 +57,3 @@ bool Process::openEmailWithAttachments (const String& /* targetEmailAddress */,
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class WebInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <WebInputStream>
|
||||
{
|
||||
public:
|
||||
WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_,
|
||||
URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
|
||||
const String& headers_, int timeOutMs_, StringPairArray* responseHeaders)
|
||||
: socketHandle (-1), levelsOfRedirection (0),
|
||||
address (address_), headers (headers_), postData (postData_), position (0),
|
||||
finished (false), isPost (isPost_), timeOutMs (timeOutMs_)
|
||||
{
|
||||
createConnection (progressCallback, progressCallbackContext);
|
||||
|
||||
if (responseHeaders != nullptr && ! isError())
|
||||
{
|
||||
for (int i = 0; i < headerLines.size(); ++i)
|
||||
{
|
||||
const String& headersEntry = headerLines[i];
|
||||
const String key (headersEntry.upToFirstOccurrenceOf (": ", false, false));
|
||||
const String value (headersEntry.fromFirstOccurrenceOf (": ", false, false));
|
||||
const String previousValue ((*responseHeaders) [key]);
|
||||
responseHeaders->set (key, previousValue.isEmpty() ? value : (previousValue + "," + value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~WebInputStream()
|
||||
{
|
||||
closeSocket();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool isError() const { return socketHandle < 0; }
|
||||
bool isExhausted() { return finished; }
|
||||
int64 getPosition() { return position; }
|
||||
|
||||
int64 getTotalLength()
|
||||
{
|
||||
//xxx to do
|
||||
return -1;
|
||||
}
|
||||
|
||||
int read (void* buffer, int bytesToRead)
|
||||
{
|
||||
if (finished || isError())
|
||||
return 0;
|
||||
|
||||
fd_set readbits;
|
||||
FD_ZERO (&readbits);
|
||||
FD_SET (socketHandle, &readbits);
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = bmax (1, timeOutMs / 1000);
|
||||
tv.tv_usec = 0;
|
||||
|
||||
if (select (socketHandle + 1, &readbits, 0, 0, &tv) <= 0)
|
||||
return 0; // (timeout)
|
||||
|
||||
const int bytesRead = bmax (0, (int) recv (socketHandle, buffer, bytesToRead, MSG_WAITALL));
|
||||
if (bytesRead == 0)
|
||||
finished = true;
|
||||
position += bytesRead;
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
bool setPosition (int64 wantedPos)
|
||||
{
|
||||
if (isError())
|
||||
return false;
|
||||
|
||||
if (wantedPos != position)
|
||||
{
|
||||
finished = false;
|
||||
|
||||
if (wantedPos < position)
|
||||
{
|
||||
closeSocket();
|
||||
position = 0;
|
||||
createConnection (0, 0);
|
||||
}
|
||||
|
||||
skipNextBytes (wantedPos - position);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
private:
|
||||
int socketHandle, levelsOfRedirection;
|
||||
StringArray headerLines;
|
||||
String address, headers;
|
||||
MemoryBlock postData;
|
||||
int64 position;
|
||||
bool finished;
|
||||
const bool isPost;
|
||||
const int timeOutMs;
|
||||
|
||||
void closeSocket()
|
||||
{
|
||||
if (socketHandle >= 0)
|
||||
close (socketHandle);
|
||||
|
||||
socketHandle = -1;
|
||||
levelsOfRedirection = 0;
|
||||
}
|
||||
|
||||
void createConnection (URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext)
|
||||
{
|
||||
closeSocket();
|
||||
|
||||
uint32 timeOutTime = Time::getMillisecondCounter();
|
||||
|
||||
if (timeOutMs == 0)
|
||||
timeOutTime += 60000;
|
||||
else if (timeOutMs < 0)
|
||||
timeOutTime = 0xffffffff;
|
||||
else
|
||||
timeOutTime += timeOutMs;
|
||||
|
||||
String hostName, hostPath;
|
||||
int hostPort;
|
||||
if (! decomposeURL (address, hostName, hostPath, hostPort))
|
||||
return;
|
||||
|
||||
String serverName, proxyName, proxyPath;
|
||||
int proxyPort = 0;
|
||||
int port = 0;
|
||||
|
||||
const String proxyURL (getenv ("http_proxy"));
|
||||
if (proxyURL.startsWithIgnoreCase ("http://"))
|
||||
{
|
||||
if (! decomposeURL (proxyURL, proxyName, proxyPath, proxyPort))
|
||||
return;
|
||||
|
||||
serverName = proxyName;
|
||||
port = proxyPort;
|
||||
}
|
||||
else
|
||||
{
|
||||
serverName = hostName;
|
||||
port = hostPort;
|
||||
}
|
||||
|
||||
struct addrinfo hints;
|
||||
zerostruct (hints);
|
||||
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_NUMERICSERV;
|
||||
|
||||
struct addrinfo* result = nullptr;
|
||||
if (getaddrinfo (serverName.toUTF8(), String (port).toUTF8(), &hints, &result) != 0 || result == 0)
|
||||
return;
|
||||
|
||||
socketHandle = socket (result->ai_family, result->ai_socktype, 0);
|
||||
|
||||
if (socketHandle == -1)
|
||||
{
|
||||
freeaddrinfo (result);
|
||||
return;
|
||||
}
|
||||
|
||||
int receiveBufferSize = 16384;
|
||||
setsockopt (socketHandle, SOL_SOCKET, SO_RCVBUF, (char*) &receiveBufferSize, sizeof (receiveBufferSize));
|
||||
setsockopt (socketHandle, SOL_SOCKET, SO_KEEPALIVE, 0, 0);
|
||||
|
||||
#if BEAST_MAC
|
||||
setsockopt (socketHandle, SOL_SOCKET, SO_NOSIGPIPE, 0, 0);
|
||||
#endif
|
||||
|
||||
if (connect (socketHandle, result->ai_addr, result->ai_addrlen) == -1)
|
||||
{
|
||||
closeSocket();
|
||||
freeaddrinfo (result);
|
||||
return;
|
||||
}
|
||||
|
||||
freeaddrinfo (result);
|
||||
|
||||
{
|
||||
const MemoryBlock requestHeader (createRequestHeader (hostName, hostPort, proxyName, proxyPort,
|
||||
hostPath, address, headers, postData, isPost));
|
||||
|
||||
if (! sendHeader (socketHandle, requestHeader, timeOutTime, progressCallback, progressCallbackContext))
|
||||
{
|
||||
closeSocket();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String responseHeader (readResponse (socketHandle, timeOutTime));
|
||||
|
||||
if (responseHeader.isNotEmpty())
|
||||
{
|
||||
headerLines = StringArray::fromLines (responseHeader);
|
||||
|
||||
const int statusCode = responseHeader.fromFirstOccurrenceOf (" ", false, false)
|
||||
.substring (0, 3).getIntValue();
|
||||
|
||||
//int contentLength = findHeaderItem (lines, "Content-Length:").getIntValue();
|
||||
//bool isChunked = findHeaderItem (lines, "Transfer-Encoding:").equalsIgnoreCase ("chunked");
|
||||
|
||||
String location (findHeaderItem (headerLines, "Location:"));
|
||||
|
||||
if (statusCode >= 300 && statusCode < 400 && location.isNotEmpty())
|
||||
{
|
||||
if (! location.startsWithIgnoreCase ("http://"))
|
||||
location = "http://" + location;
|
||||
|
||||
if (++levelsOfRedirection <= 3)
|
||||
{
|
||||
address = location;
|
||||
createConnection (progressCallback, progressCallbackContext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
levelsOfRedirection = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
closeSocket();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static String readResponse (const int socketHandle, const uint32 timeOutTime)
|
||||
{
|
||||
int bytesRead = 0, numConsecutiveLFs = 0;
|
||||
MemoryBlock buffer (1024, true);
|
||||
|
||||
while (numConsecutiveLFs < 2 && bytesRead < 32768
|
||||
&& Time::getMillisecondCounter() <= timeOutTime)
|
||||
{
|
||||
fd_set readbits;
|
||||
FD_ZERO (&readbits);
|
||||
FD_SET (socketHandle, &readbits);
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = bmax (1, (int) (timeOutTime - Time::getMillisecondCounter()) / 1000);
|
||||
tv.tv_usec = 0;
|
||||
|
||||
if (select (socketHandle + 1, &readbits, 0, 0, &tv) <= 0)
|
||||
return String::empty; // (timeout)
|
||||
|
||||
buffer.ensureSize (bytesRead + 8, true);
|
||||
char* const dest = (char*) buffer.getData() + bytesRead;
|
||||
|
||||
if (recv (socketHandle, dest, 1, 0) == -1)
|
||||
return String::empty;
|
||||
|
||||
const char lastByte = *dest;
|
||||
++bytesRead;
|
||||
|
||||
if (lastByte == '\n')
|
||||
++numConsecutiveLFs;
|
||||
else if (lastByte != '\r')
|
||||
numConsecutiveLFs = 0;
|
||||
}
|
||||
|
||||
const String header (CharPointer_UTF8 ((const char*) buffer.getData()));
|
||||
|
||||
if (header.startsWithIgnoreCase ("HTTP/"))
|
||||
return header.trimEnd();
|
||||
|
||||
return String::empty;
|
||||
}
|
||||
|
||||
static void writeValueIfNotPresent (MemoryOutputStream& dest, const String& headers, const String& key, const String& value)
|
||||
{
|
||||
if (! headers.containsIgnoreCase (key))
|
||||
dest << "\r\n" << key << ' ' << value;
|
||||
}
|
||||
|
||||
static void writeHost (MemoryOutputStream& dest, const bool isPost, const String& path, const String& host, const int port)
|
||||
{
|
||||
dest << (isPost ? "POST " : "GET ") << path << " HTTP/1.0\r\nHost: " << host;
|
||||
|
||||
if (port > 0)
|
||||
dest << ':' << port;
|
||||
}
|
||||
|
||||
static MemoryBlock createRequestHeader (const String& hostName, const int hostPort,
|
||||
const String& proxyName, const int proxyPort,
|
||||
const String& hostPath, const String& originalURL,
|
||||
const String& userHeaders, const MemoryBlock& postData,
|
||||
const bool isPost)
|
||||
{
|
||||
MemoryOutputStream header;
|
||||
|
||||
if (proxyName.isEmpty())
|
||||
writeHost (header, isPost, hostPath, hostName, hostPort);
|
||||
else
|
||||
writeHost (header, isPost, originalURL, proxyName, proxyPort);
|
||||
|
||||
writeValueIfNotPresent (header, userHeaders, "User-Agent:", "BEAST/" BEAST_STRINGIFY(BEAST_MAJOR_VERSION)
|
||||
"." BEAST_STRINGIFY(BEAST_MINOR_VERSION)
|
||||
"." BEAST_STRINGIFY(BEAST_BUILDNUMBER));
|
||||
writeValueIfNotPresent (header, userHeaders, "Connection:", "Close");
|
||||
|
||||
if (isPost)
|
||||
writeValueIfNotPresent (header, userHeaders, "Content-Length:", String ((int) postData.getSize()));
|
||||
|
||||
header << "\r\n" << userHeaders
|
||||
<< "\r\n" << postData;
|
||||
|
||||
return header.getMemoryBlock();
|
||||
}
|
||||
|
||||
static bool sendHeader (int socketHandle, const MemoryBlock& requestHeader, const uint32 timeOutTime,
|
||||
URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext)
|
||||
{
|
||||
size_t totalHeaderSent = 0;
|
||||
|
||||
while (totalHeaderSent < requestHeader.getSize())
|
||||
{
|
||||
if (Time::getMillisecondCounter() > timeOutTime)
|
||||
return false;
|
||||
|
||||
const int numToSend = bmin (1024, (int) (requestHeader.getSize() - totalHeaderSent));
|
||||
|
||||
if (send (socketHandle, static_cast <const char*> (requestHeader.getData()) + totalHeaderSent, numToSend, 0) != numToSend)
|
||||
return false;
|
||||
|
||||
totalHeaderSent += numToSend;
|
||||
|
||||
if (progressCallback != nullptr && ! progressCallback (progressCallbackContext, totalHeaderSent, requestHeader.getSize()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool decomposeURL (const String& url, String& host, String& path, int& port)
|
||||
{
|
||||
if (! url.startsWithIgnoreCase ("http://"))
|
||||
return false;
|
||||
|
||||
const int nextSlash = url.indexOfChar (7, '/');
|
||||
int nextColon = url.indexOfChar (7, ':');
|
||||
if (nextColon > nextSlash && nextSlash > 0)
|
||||
nextColon = -1;
|
||||
|
||||
if (nextColon >= 0)
|
||||
{
|
||||
host = url.substring (7, nextColon);
|
||||
|
||||
if (nextSlash >= 0)
|
||||
port = url.substring (nextColon + 1, nextSlash).getIntValue();
|
||||
else
|
||||
port = url.substring (nextColon + 1).getIntValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
port = 80;
|
||||
|
||||
if (nextSlash >= 0)
|
||||
host = url.substring (7, nextSlash);
|
||||
else
|
||||
host = url.substring (7);
|
||||
}
|
||||
|
||||
if (nextSlash >= 0)
|
||||
path = url.substring (nextSlash);
|
||||
else
|
||||
path = "/";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static String findHeaderItem (const StringArray& lines, const String& itemName)
|
||||
{
|
||||
for (int i = 0; i < lines.size(); ++i)
|
||||
if (lines[i].startsWithIgnoreCase (itemName))
|
||||
return lines[i].substring (itemName.length()).trim();
|
||||
|
||||
return String::empty;
|
||||
}
|
||||
};
|
||||
|
||||
InputStream* URL::createNativeStream (const String& address, bool isPost, const MemoryBlock& postData,
|
||||
OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
|
||||
const String& headers, const int timeOutMs, StringPairArray* responseHeaders)
|
||||
{
|
||||
ScopedPointer <WebInputStream> wi (new WebInputStream (address, isPost, postData,
|
||||
progressCallback, progressCallbackContext,
|
||||
headers, timeOutMs, responseHeaders));
|
||||
|
||||
return wi->isError() ? nullptr : wi.release();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ void Process::setPriority (const ProcessPriority prior)
|
||||
pthread_setschedparam (pthread_self(), policy, ¶m);
|
||||
}
|
||||
|
||||
BEAST_API bool BEAST_CALLTYPE beast_isRunningUnderDebugger()
|
||||
bool beast_isRunningUnderDebugger()
|
||||
{
|
||||
// XXX not implemented for FreeBSD!
|
||||
bassertfalse;
|
||||
|
||||
@@ -329,9 +329,7 @@ bool Process::openDocument (const String& fileName, const String& parameters)
|
||||
String cmdString (fileName.replace (" ", "\\ ",false));
|
||||
cmdString << " " << parameters;
|
||||
|
||||
if (URL::isProbablyAWebsiteURL (fileName)
|
||||
|| cmdString.startsWithIgnoreCase ("file:")
|
||||
|| URL::isProbablyAnEmailAddress (fileName)
|
||||
if ( cmdString.startsWithIgnoreCase ("file:")
|
||||
|| File::createFileWithoutCheckingPath (fileName).isDirectory()
|
||||
|| ! isFileExecutable (fileName))
|
||||
{
|
||||
|
||||
@@ -59,399 +59,3 @@ bool Process::openEmailWithAttachments (const String& /* targetEmailAddress */,
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class WebInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <WebInputStream>
|
||||
{
|
||||
public:
|
||||
WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_,
|
||||
URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
|
||||
const String& headers_, int timeOutMs_, StringPairArray* responseHeaders)
|
||||
: socketHandle (-1), levelsOfRedirection (0),
|
||||
address (address_), headers (headers_), postData (postData_), position (0),
|
||||
finished (false), isPost (isPost_), timeOutMs (timeOutMs_)
|
||||
{
|
||||
createConnection (progressCallback, progressCallbackContext);
|
||||
|
||||
if (responseHeaders != nullptr && ! isError())
|
||||
{
|
||||
for (int i = 0; i < headerLines.size(); ++i)
|
||||
{
|
||||
const String& headersEntry = headerLines[i];
|
||||
const String key (headersEntry.upToFirstOccurrenceOf (": ", false, false));
|
||||
const String value (headersEntry.fromFirstOccurrenceOf (": ", false, false));
|
||||
const String previousValue ((*responseHeaders) [key]);
|
||||
responseHeaders->set (key, previousValue.isEmpty() ? value : (previousValue + "," + value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~WebInputStream()
|
||||
{
|
||||
closeSocket();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool isError() const { return socketHandle < 0; }
|
||||
bool isExhausted() { return finished; }
|
||||
int64 getPosition() { return position; }
|
||||
|
||||
int64 getTotalLength()
|
||||
{
|
||||
//xxx to do
|
||||
return -1;
|
||||
}
|
||||
|
||||
int read (void* buffer, int bytesToRead)
|
||||
{
|
||||
if (finished || isError())
|
||||
return 0;
|
||||
|
||||
fd_set readbits;
|
||||
FD_ZERO (&readbits);
|
||||
FD_SET (socketHandle, &readbits);
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = bmax (1, timeOutMs / 1000);
|
||||
tv.tv_usec = 0;
|
||||
|
||||
if (select (socketHandle + 1, &readbits, 0, 0, &tv) <= 0)
|
||||
return 0; // (timeout)
|
||||
|
||||
const int bytesRead = bmax (0, (int) recv (socketHandle, buffer, bytesToRead, MSG_WAITALL));
|
||||
if (bytesRead == 0)
|
||||
finished = true;
|
||||
position += bytesRead;
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
bool setPosition (int64 wantedPos)
|
||||
{
|
||||
if (isError())
|
||||
return false;
|
||||
|
||||
if (wantedPos != position)
|
||||
{
|
||||
finished = false;
|
||||
|
||||
if (wantedPos < position)
|
||||
{
|
||||
closeSocket();
|
||||
position = 0;
|
||||
createConnection (0, 0);
|
||||
}
|
||||
|
||||
skipNextBytes (wantedPos - position);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
private:
|
||||
int socketHandle, levelsOfRedirection;
|
||||
StringArray headerLines;
|
||||
String address, headers;
|
||||
MemoryBlock postData;
|
||||
int64 position;
|
||||
bool finished;
|
||||
const bool isPost;
|
||||
const int timeOutMs;
|
||||
|
||||
void closeSocket()
|
||||
{
|
||||
if (socketHandle >= 0)
|
||||
close (socketHandle);
|
||||
|
||||
socketHandle = -1;
|
||||
levelsOfRedirection = 0;
|
||||
}
|
||||
|
||||
void createConnection (URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext)
|
||||
{
|
||||
closeSocket();
|
||||
|
||||
uint32 timeOutTime = Time::getMillisecondCounter();
|
||||
|
||||
if (timeOutMs == 0)
|
||||
timeOutTime += 60000;
|
||||
else if (timeOutMs < 0)
|
||||
timeOutTime = 0xffffffff;
|
||||
else
|
||||
timeOutTime += timeOutMs;
|
||||
|
||||
String hostName, hostPath;
|
||||
int hostPort;
|
||||
if (! decomposeURL (address, hostName, hostPath, hostPort))
|
||||
return;
|
||||
|
||||
String serverName, proxyName, proxyPath;
|
||||
int proxyPort = 0;
|
||||
int port = 0;
|
||||
|
||||
const String proxyURL (getenv ("http_proxy"));
|
||||
if (proxyURL.startsWithIgnoreCase ("http://"))
|
||||
{
|
||||
if (! decomposeURL (proxyURL, proxyName, proxyPath, proxyPort))
|
||||
return;
|
||||
|
||||
serverName = proxyName;
|
||||
port = proxyPort;
|
||||
}
|
||||
else
|
||||
{
|
||||
serverName = hostName;
|
||||
port = hostPort;
|
||||
}
|
||||
|
||||
struct addrinfo hints;
|
||||
zerostruct (hints);
|
||||
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_NUMERICSERV;
|
||||
|
||||
struct addrinfo* result = nullptr;
|
||||
if (getaddrinfo (serverName.toUTF8(), String (port).toUTF8(), &hints, &result) != 0 || result == 0)
|
||||
return;
|
||||
|
||||
socketHandle = socket (result->ai_family, result->ai_socktype, 0);
|
||||
|
||||
if (socketHandle == -1)
|
||||
{
|
||||
freeaddrinfo (result);
|
||||
return;
|
||||
}
|
||||
|
||||
int receiveBufferSize = 16384;
|
||||
setsockopt (socketHandle, SOL_SOCKET, SO_RCVBUF, (char*) &receiveBufferSize, sizeof (receiveBufferSize));
|
||||
setsockopt (socketHandle, SOL_SOCKET, SO_KEEPALIVE, 0, 0);
|
||||
|
||||
#if BEAST_MAC
|
||||
setsockopt (socketHandle, SOL_SOCKET, SO_NOSIGPIPE, 0, 0);
|
||||
#endif
|
||||
|
||||
if (connect (socketHandle, result->ai_addr, result->ai_addrlen) == -1)
|
||||
{
|
||||
closeSocket();
|
||||
freeaddrinfo (result);
|
||||
return;
|
||||
}
|
||||
|
||||
freeaddrinfo (result);
|
||||
|
||||
{
|
||||
const MemoryBlock requestHeader (createRequestHeader (hostName, hostPort, proxyName, proxyPort,
|
||||
hostPath, address, headers, postData, isPost));
|
||||
|
||||
if (! sendHeader (socketHandle, requestHeader, timeOutTime, progressCallback, progressCallbackContext))
|
||||
{
|
||||
closeSocket();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String responseHeader (readResponse (socketHandle, timeOutTime));
|
||||
|
||||
if (responseHeader.isNotEmpty())
|
||||
{
|
||||
headerLines = StringArray::fromLines (responseHeader);
|
||||
|
||||
const int statusCode = responseHeader.fromFirstOccurrenceOf (" ", false, false)
|
||||
.substring (0, 3).getIntValue();
|
||||
|
||||
//int contentLength = findHeaderItem (lines, "Content-Length:").getIntValue();
|
||||
//bool isChunked = findHeaderItem (lines, "Transfer-Encoding:").equalsIgnoreCase ("chunked");
|
||||
|
||||
String location (findHeaderItem (headerLines, "Location:"));
|
||||
|
||||
if (statusCode >= 300 && statusCode < 400 && location.isNotEmpty())
|
||||
{
|
||||
if (! location.startsWithIgnoreCase ("http://"))
|
||||
location = "http://" + location;
|
||||
|
||||
if (++levelsOfRedirection <= 3)
|
||||
{
|
||||
address = location;
|
||||
createConnection (progressCallback, progressCallbackContext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
levelsOfRedirection = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
closeSocket();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static String readResponse (const int socketHandle, const uint32 timeOutTime)
|
||||
{
|
||||
int bytesRead = 0, numConsecutiveLFs = 0;
|
||||
MemoryBlock buffer (1024, true);
|
||||
|
||||
while (numConsecutiveLFs < 2 && bytesRead < 32768
|
||||
&& Time::getMillisecondCounter() <= timeOutTime)
|
||||
{
|
||||
fd_set readbits;
|
||||
FD_ZERO (&readbits);
|
||||
FD_SET (socketHandle, &readbits);
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_sec = bmax (1, (int) (timeOutTime - Time::getMillisecondCounter()) / 1000);
|
||||
tv.tv_usec = 0;
|
||||
|
||||
if (select (socketHandle + 1, &readbits, 0, 0, &tv) <= 0)
|
||||
return String::empty; // (timeout)
|
||||
|
||||
buffer.ensureSize (bytesRead + 8, true);
|
||||
char* const dest = (char*) buffer.getData() + bytesRead;
|
||||
|
||||
if (recv (socketHandle, dest, 1, 0) == -1)
|
||||
return String::empty;
|
||||
|
||||
const char lastByte = *dest;
|
||||
++bytesRead;
|
||||
|
||||
if (lastByte == '\n')
|
||||
++numConsecutiveLFs;
|
||||
else if (lastByte != '\r')
|
||||
numConsecutiveLFs = 0;
|
||||
}
|
||||
|
||||
const String header (CharPointer_UTF8 ((const char*) buffer.getData()));
|
||||
|
||||
if (header.startsWithIgnoreCase ("HTTP/"))
|
||||
return header.trimEnd();
|
||||
|
||||
return String::empty;
|
||||
}
|
||||
|
||||
static void writeValueIfNotPresent (MemoryOutputStream& dest, const String& headers, const String& key, const String& value)
|
||||
{
|
||||
if (! headers.containsIgnoreCase (key))
|
||||
dest << "\r\n" << key << ' ' << value;
|
||||
}
|
||||
|
||||
static void writeHost (MemoryOutputStream& dest, const bool isPost, const String& path, const String& host, const int port)
|
||||
{
|
||||
dest << (isPost ? "POST " : "GET ") << path << " HTTP/1.0\r\nHost: " << host;
|
||||
|
||||
if (port > 0)
|
||||
dest << ':' << port;
|
||||
}
|
||||
|
||||
static MemoryBlock createRequestHeader (const String& hostName, const int hostPort,
|
||||
const String& proxyName, const int proxyPort,
|
||||
const String& hostPath, const String& originalURL,
|
||||
const String& userHeaders, const MemoryBlock& postData,
|
||||
const bool isPost)
|
||||
{
|
||||
MemoryOutputStream header;
|
||||
|
||||
if (proxyName.isEmpty())
|
||||
writeHost (header, isPost, hostPath, hostName, hostPort);
|
||||
else
|
||||
writeHost (header, isPost, originalURL, proxyName, proxyPort);
|
||||
|
||||
writeValueIfNotPresent (header, userHeaders, "User-Agent:", "BEAST/" BEAST_STRINGIFY(BEAST_MAJOR_VERSION)
|
||||
"." BEAST_STRINGIFY(BEAST_MINOR_VERSION)
|
||||
"." BEAST_STRINGIFY(BEAST_BUILDNUMBER));
|
||||
writeValueIfNotPresent (header, userHeaders, "Connection:", "Close");
|
||||
|
||||
if (isPost)
|
||||
writeValueIfNotPresent (header, userHeaders, "Content-Length:", String ((int) postData.getSize()));
|
||||
|
||||
header << "\r\n" << userHeaders
|
||||
<< "\r\n" << postData;
|
||||
|
||||
return header.getMemoryBlock();
|
||||
}
|
||||
|
||||
static bool sendHeader (int socketHandle, const MemoryBlock& requestHeader, const uint32 timeOutTime,
|
||||
URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext)
|
||||
{
|
||||
size_t totalHeaderSent = 0;
|
||||
|
||||
while (totalHeaderSent < requestHeader.getSize())
|
||||
{
|
||||
if (Time::getMillisecondCounter() > timeOutTime)
|
||||
return false;
|
||||
|
||||
const int numToSend = bmin (1024, (int) (requestHeader.getSize() - totalHeaderSent));
|
||||
|
||||
if (send (socketHandle, static_cast <const char*> (requestHeader.getData()) + totalHeaderSent, numToSend, 0) != numToSend)
|
||||
return false;
|
||||
|
||||
totalHeaderSent += numToSend;
|
||||
|
||||
if (progressCallback != nullptr && ! progressCallback (progressCallbackContext, totalHeaderSent, requestHeader.getSize()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool decomposeURL (const String& url, String& host, String& path, int& port)
|
||||
{
|
||||
if (! url.startsWithIgnoreCase ("http://"))
|
||||
return false;
|
||||
|
||||
const int nextSlash = url.indexOfChar (7, '/');
|
||||
int nextColon = url.indexOfChar (7, ':');
|
||||
if (nextColon > nextSlash && nextSlash > 0)
|
||||
nextColon = -1;
|
||||
|
||||
if (nextColon >= 0)
|
||||
{
|
||||
host = url.substring (7, nextColon);
|
||||
|
||||
if (nextSlash >= 0)
|
||||
port = url.substring (nextColon + 1, nextSlash).getIntValue();
|
||||
else
|
||||
port = url.substring (nextColon + 1).getIntValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
port = 80;
|
||||
|
||||
if (nextSlash >= 0)
|
||||
host = url.substring (7, nextSlash);
|
||||
else
|
||||
host = url.substring (7);
|
||||
}
|
||||
|
||||
if (nextSlash >= 0)
|
||||
path = url.substring (nextSlash);
|
||||
else
|
||||
path = "/";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static String findHeaderItem (const StringArray& lines, const String& itemName)
|
||||
{
|
||||
for (int i = 0; i < lines.size(); ++i)
|
||||
if (lines[i].startsWithIgnoreCase (itemName))
|
||||
return lines[i].substring (itemName.length()).trim();
|
||||
|
||||
return String::empty;
|
||||
}
|
||||
};
|
||||
|
||||
InputStream* URL::createNativeStream (const String& address, bool isPost, const MemoryBlock& postData,
|
||||
OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
|
||||
const String& headers, const int timeOutMs, StringPairArray* responseHeaders)
|
||||
{
|
||||
ScopedPointer <WebInputStream> wi (new WebInputStream (address, isPost, postData,
|
||||
progressCallback, progressCallbackContext,
|
||||
headers, timeOutMs, responseHeaders));
|
||||
|
||||
return wi->isError() ? nullptr : wi.release();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ void Process::setPriority (const ProcessPriority prior)
|
||||
pthread_setschedparam (pthread_self(), policy, ¶m);
|
||||
}
|
||||
|
||||
BEAST_API bool BEAST_CALLTYPE beast_isRunningUnderDebugger()
|
||||
bool beast_isRunningUnderDebugger()
|
||||
{
|
||||
static char testResult = 0;
|
||||
|
||||
|
||||
@@ -294,135 +294,3 @@ private:
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class WebInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <WebInputStream>
|
||||
{
|
||||
public:
|
||||
WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_,
|
||||
URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
|
||||
const String& headers_, int timeOutMs_, StringPairArray* responseHeaders)
|
||||
: address (address_), headers (headers_), postData (postData_), position (0),
|
||||
finished (false), isPost (isPost_), timeOutMs (timeOutMs_)
|
||||
{
|
||||
BEAST_AUTORELEASEPOOL
|
||||
{
|
||||
createConnection (progressCallback, progressCallbackContext);
|
||||
|
||||
if (responseHeaders != nullptr && connection != nullptr && connection->headers != nil)
|
||||
{
|
||||
NSEnumerator* enumerator = [connection->headers keyEnumerator];
|
||||
NSString* key;
|
||||
|
||||
while ((key = [enumerator nextObject]) != nil)
|
||||
responseHeaders->set (nsStringToBeast (key),
|
||||
nsStringToBeast ((NSString*) [connection->headers objectForKey: key]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool isError() const { return connection == nullptr; }
|
||||
int64 getTotalLength() { return connection == nullptr ? -1 : connection->contentLength; }
|
||||
bool isExhausted() { return finished; }
|
||||
int64 getPosition() { return position; }
|
||||
|
||||
int read (void* buffer, int bytesToRead)
|
||||
{
|
||||
bassert (buffer != nullptr && bytesToRead >= 0);
|
||||
|
||||
if (finished || isError())
|
||||
return 0;
|
||||
|
||||
BEAST_AUTORELEASEPOOL
|
||||
{
|
||||
const int bytesRead = connection->read (static_cast <char*> (buffer), bytesToRead);
|
||||
position += bytesRead;
|
||||
|
||||
if (bytesRead == 0)
|
||||
finished = true;
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
}
|
||||
|
||||
bool setPosition (int64 wantedPos)
|
||||
{
|
||||
if (wantedPos != position)
|
||||
{
|
||||
finished = false;
|
||||
|
||||
if (wantedPos < position)
|
||||
{
|
||||
connection = nullptr;
|
||||
position = 0;
|
||||
createConnection (0, 0);
|
||||
}
|
||||
|
||||
skipNextBytes (wantedPos - position);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
ScopedPointer<URLConnectionState> connection;
|
||||
String address, headers;
|
||||
MemoryBlock postData;
|
||||
int64 position;
|
||||
bool finished;
|
||||
const bool isPost;
|
||||
const int timeOutMs;
|
||||
|
||||
void createConnection (URL::OpenStreamProgressCallback* progressCallback,
|
||||
void* progressCallbackContext)
|
||||
{
|
||||
bassert (connection == nullptr);
|
||||
|
||||
NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL: [NSURL URLWithString: beastStringToNS (address)]
|
||||
cachePolicy: NSURLRequestReloadIgnoringLocalCacheData
|
||||
timeoutInterval: timeOutMs <= 0 ? 60.0 : (timeOutMs / 1000.0)];
|
||||
|
||||
if (req != nil)
|
||||
{
|
||||
[req setHTTPMethod: nsStringLiteral (isPost ? "POST" : "GET")];
|
||||
//[req setCachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData];
|
||||
|
||||
StringArray headerLines;
|
||||
headerLines.addLines (headers);
|
||||
headerLines.removeEmptyStrings (true);
|
||||
|
||||
for (int i = 0; i < headerLines.size(); ++i)
|
||||
{
|
||||
const String key (headerLines[i].upToFirstOccurrenceOf (":", false, false).trim());
|
||||
const String value (headerLines[i].fromFirstOccurrenceOf (":", false, false).trim());
|
||||
|
||||
if (key.isNotEmpty() && value.isNotEmpty())
|
||||
[req addValue: beastStringToNS (value) forHTTPHeaderField: beastStringToNS (key)];
|
||||
}
|
||||
|
||||
if (isPost && postData.getSize() > 0)
|
||||
[req setHTTPBody: [NSData dataWithBytes: postData.getData()
|
||||
length: postData.getSize()]];
|
||||
|
||||
connection = new URLConnectionState (req);
|
||||
|
||||
if (! connection->start (progressCallback, progressCallbackContext))
|
||||
connection = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
InputStream* URL::createNativeStream (const String& address, bool isPost, const MemoryBlock& postData,
|
||||
OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
|
||||
const String& headers, const int timeOutMs, StringPairArray* responseHeaders)
|
||||
{
|
||||
ScopedPointer <WebInputStream> wi (new WebInputStream (address, isPost, postData,
|
||||
progressCallback, progressCallbackContext,
|
||||
headers, timeOutMs, responseHeaders));
|
||||
|
||||
return wi->isError() ? nullptr : wi.release();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ void Process::setPriority (ProcessPriority)
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
BEAST_API bool BEAST_CALLTYPE beast_isRunningUnderDebugger()
|
||||
bool beast_isRunningUnderDebugger()
|
||||
{
|
||||
static char testResult = 0;
|
||||
|
||||
|
||||
@@ -21,298 +21,6 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef INTERNET_FLAG_NEED_FILE
|
||||
#define INTERNET_FLAG_NEED_FILE 0x00000010
|
||||
#endif
|
||||
|
||||
#ifndef INTERNET_OPTION_DISABLE_AUTODIAL
|
||||
#define INTERNET_OPTION_DISABLE_AUTODIAL 70
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
class WebInputStream
|
||||
: public InputStream
|
||||
, LeakChecked <WebInputStream>
|
||||
{
|
||||
public:
|
||||
WebInputStream (const String& address_, bool isPost_, const MemoryBlock& postData_,
|
||||
URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
|
||||
const String& headers_, int timeOutMs_, StringPairArray* responseHeaders)
|
||||
: connection (0), request (0),
|
||||
address (address_), headers (headers_), postData (postData_), position (0),
|
||||
finished (false), isPost (isPost_), timeOutMs (timeOutMs_)
|
||||
{
|
||||
createConnection (progressCallback, progressCallbackContext);
|
||||
|
||||
if (responseHeaders != nullptr && ! isError())
|
||||
{
|
||||
DWORD bufferSizeBytes = 4096;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
HeapBlock<char> buffer ((size_t) bufferSizeBytes);
|
||||
|
||||
if (HttpQueryInfo (request, HTTP_QUERY_RAW_HEADERS_CRLF, buffer.getData(), &bufferSizeBytes, 0))
|
||||
{
|
||||
StringArray headersArray;
|
||||
headersArray.addLines (reinterpret_cast <const WCHAR*> (buffer.getData()));
|
||||
|
||||
for (int i = 0; i < headersArray.size(); ++i)
|
||||
{
|
||||
const String& header = headersArray[i];
|
||||
const String key (header.upToFirstOccurrenceOf (": ", false, false));
|
||||
const String value (header.fromFirstOccurrenceOf (": ", false, false));
|
||||
const String previousValue ((*responseHeaders) [key]);
|
||||
|
||||
responseHeaders->set (key, previousValue.isEmpty() ? value : (previousValue + "," + value));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~WebInputStream()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool isError() const { return request == 0; }
|
||||
bool isExhausted() { return finished; }
|
||||
int64 getPosition() { return position; }
|
||||
|
||||
int64 getTotalLength()
|
||||
{
|
||||
if (! isError())
|
||||
{
|
||||
DWORD index = 0, result = 0, size = sizeof (result);
|
||||
|
||||
if (HttpQueryInfo (request, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &result, &size, &index))
|
||||
return (int64) result;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int read (void* buffer, int bytesToRead)
|
||||
{
|
||||
bassert (buffer != nullptr && bytesToRead >= 0);
|
||||
DWORD bytesRead = 0;
|
||||
|
||||
if (! (finished || isError()))
|
||||
{
|
||||
InternetReadFile (request, buffer, (DWORD) bytesToRead, &bytesRead);
|
||||
position += bytesRead;
|
||||
|
||||
if (bytesRead == 0)
|
||||
finished = true;
|
||||
}
|
||||
|
||||
return (int) bytesRead;
|
||||
}
|
||||
|
||||
bool setPosition (int64 wantedPos)
|
||||
{
|
||||
if (isError())
|
||||
return false;
|
||||
|
||||
if (wantedPos != position)
|
||||
{
|
||||
finished = false;
|
||||
position = (int64) InternetSetFilePointer (request, (LONG) wantedPos, 0, FILE_BEGIN, 0);
|
||||
|
||||
if (position == wantedPos)
|
||||
return true;
|
||||
|
||||
if (wantedPos < position)
|
||||
{
|
||||
close();
|
||||
position = 0;
|
||||
createConnection (0, 0);
|
||||
}
|
||||
|
||||
skipNextBytes (wantedPos - position);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
HINTERNET connection, request;
|
||||
String address, headers;
|
||||
MemoryBlock postData;
|
||||
int64 position;
|
||||
bool finished;
|
||||
const bool isPost;
|
||||
int timeOutMs;
|
||||
|
||||
void close()
|
||||
{
|
||||
if (request != 0)
|
||||
{
|
||||
InternetCloseHandle (request);
|
||||
request = 0;
|
||||
}
|
||||
|
||||
if (connection != 0)
|
||||
{
|
||||
InternetCloseHandle (connection);
|
||||
connection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void createConnection (URL::OpenStreamProgressCallback* progressCallback,
|
||||
void* progressCallbackContext)
|
||||
{
|
||||
static HINTERNET sessionHandle = InternetOpen (_T("beast"), INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
|
||||
|
||||
close();
|
||||
|
||||
if (sessionHandle != 0)
|
||||
{
|
||||
// break up the url..
|
||||
const int fileNumChars = 65536;
|
||||
const int serverNumChars = 2048;
|
||||
const int usernameNumChars = 1024;
|
||||
const int passwordNumChars = 1024;
|
||||
HeapBlock<TCHAR> file (fileNumChars), server (serverNumChars),
|
||||
username (usernameNumChars), password (passwordNumChars);
|
||||
|
||||
URL_COMPONENTS uc = { 0 };
|
||||
uc.dwStructSize = sizeof (uc);
|
||||
uc.lpszUrlPath = file;
|
||||
uc.dwUrlPathLength = fileNumChars;
|
||||
uc.lpszHostName = server;
|
||||
uc.dwHostNameLength = serverNumChars;
|
||||
uc.lpszUserName = username;
|
||||
uc.dwUserNameLength = usernameNumChars;
|
||||
uc.lpszPassword = password;
|
||||
uc.dwPasswordLength = passwordNumChars;
|
||||
|
||||
if (InternetCrackUrl (address.toWideCharPointer(), 0, 0, &uc))
|
||||
openConnection (uc, sessionHandle, progressCallback, progressCallbackContext);
|
||||
}
|
||||
}
|
||||
|
||||
void openConnection (URL_COMPONENTS& uc, HINTERNET sessionHandle,
|
||||
URL::OpenStreamProgressCallback* progressCallback,
|
||||
void* progressCallbackContext)
|
||||
{
|
||||
int disable = 1;
|
||||
InternetSetOption (sessionHandle, INTERNET_OPTION_DISABLE_AUTODIAL, &disable, sizeof (disable));
|
||||
|
||||
if (timeOutMs == 0)
|
||||
timeOutMs = 30000;
|
||||
else if (timeOutMs < 0)
|
||||
timeOutMs = -1;
|
||||
|
||||
applyTimeout (sessionHandle, INTERNET_OPTION_CONNECT_TIMEOUT);
|
||||
applyTimeout (sessionHandle, INTERNET_OPTION_RECEIVE_TIMEOUT);
|
||||
applyTimeout (sessionHandle, INTERNET_OPTION_SEND_TIMEOUT);
|
||||
applyTimeout (sessionHandle, INTERNET_OPTION_DATA_RECEIVE_TIMEOUT);
|
||||
applyTimeout (sessionHandle, INTERNET_OPTION_DATA_SEND_TIMEOUT);
|
||||
|
||||
const bool isFtp = address.startsWithIgnoreCase ("ftp:");
|
||||
|
||||
connection = InternetConnect (sessionHandle, uc.lpszHostName, uc.nPort,
|
||||
uc.lpszUserName, uc.lpszPassword,
|
||||
isFtp ? (DWORD) INTERNET_SERVICE_FTP
|
||||
: (DWORD) INTERNET_SERVICE_HTTP,
|
||||
0, 0);
|
||||
if (connection != 0)
|
||||
{
|
||||
if (isFtp)
|
||||
request = FtpOpenFile (connection, uc.lpszUrlPath, GENERIC_READ,
|
||||
FTP_TRANSFER_TYPE_BINARY | INTERNET_FLAG_NEED_FILE, 0);
|
||||
else
|
||||
openHTTPConnection (uc, progressCallback, progressCallbackContext);
|
||||
}
|
||||
}
|
||||
|
||||
void applyTimeout (HINTERNET sessionHandle, const DWORD option)
|
||||
{
|
||||
InternetSetOption (sessionHandle, option, &timeOutMs, sizeof (timeOutMs));
|
||||
}
|
||||
|
||||
void openHTTPConnection (URL_COMPONENTS& uc, URL::OpenStreamProgressCallback* progressCallback,
|
||||
void* progressCallbackContext)
|
||||
{
|
||||
const TCHAR* mimeTypes[] = { _T("*/*"), nullptr };
|
||||
|
||||
DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES;
|
||||
|
||||
if (address.startsWithIgnoreCase ("https:"))
|
||||
flags |= INTERNET_FLAG_SECURE; // (this flag only seems necessary if the OS is running IE6 -
|
||||
// IE7 seems to automatically work out when it's https)
|
||||
|
||||
request = HttpOpenRequest (connection, isPost ? _T("POST") : _T("GET"),
|
||||
uc.lpszUrlPath, 0, 0, mimeTypes, flags, 0);
|
||||
|
||||
if (request != 0)
|
||||
{
|
||||
INTERNET_BUFFERS buffers = { 0 };
|
||||
buffers.dwStructSize = sizeof (INTERNET_BUFFERS);
|
||||
buffers.lpcszHeader = headers.toWideCharPointer();
|
||||
buffers.dwHeadersLength = (DWORD) headers.length();
|
||||
buffers.dwBufferTotal = (DWORD) postData.getSize();
|
||||
|
||||
if (HttpSendRequestEx (request, &buffers, 0, HSR_INITIATE, 0))
|
||||
{
|
||||
int bytesSent = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const int bytesToDo = bmin (1024, (int) postData.getSize() - bytesSent);
|
||||
DWORD bytesDone = 0;
|
||||
|
||||
if (bytesToDo > 0
|
||||
&& ! InternetWriteFile (request,
|
||||
static_cast <const char*> (postData.getData()) + bytesSent,
|
||||
(DWORD) bytesToDo, &bytesDone))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (bytesToDo == 0 || (int) bytesDone < bytesToDo)
|
||||
{
|
||||
if (HttpEndRequest (request, 0, 0, 0))
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
bytesSent += bytesDone;
|
||||
|
||||
if (progressCallback != nullptr
|
||||
&& ! progressCallback (progressCallbackContext, bytesSent, (int) postData.getSize()))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close();
|
||||
}
|
||||
};
|
||||
|
||||
InputStream* URL::createNativeStream (const String& address, bool isPost, const MemoryBlock& postData,
|
||||
OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
|
||||
const String& headers, const int timeOutMs, StringPairArray* responseHeaders)
|
||||
{
|
||||
ScopedPointer <WebInputStream> wi (new WebInputStream (address, isPost, postData,
|
||||
progressCallback, progressCallbackContext,
|
||||
headers, timeOutMs, responseHeaders));
|
||||
|
||||
return wi->isError() ? nullptr : wi.release();
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
struct GetAdaptersInfoHelper
|
||||
{
|
||||
bool callGetAdaptersInfo()
|
||||
|
||||
@@ -257,7 +257,7 @@ void Process::setPriority (ProcessPriority prior)
|
||||
}
|
||||
}
|
||||
|
||||
BEAST_API bool BEAST_CALLTYPE beast_isRunningUnderDebugger()
|
||||
bool beast_isRunningUnderDebugger()
|
||||
{
|
||||
return IsDebuggerPresent() != FALSE;
|
||||
}
|
||||
|
||||
@@ -414,3 +414,20 @@ BEAST_API bool OutputStream::writeTypeBigEndian <float> (float v) { return write
|
||||
|
||||
template <>
|
||||
BEAST_API bool OutputStream::writeTypeBigEndian <double> (double v) { return writeDoubleBigEndian (v); }
|
||||
|
||||
BEAST_API OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const String& text)
|
||||
{
|
||||
const size_t numBytes = text.getNumBytesAsUTF8();
|
||||
|
||||
#if (BEAST_STRING_UTF_TYPE == 8)
|
||||
stream.write (text.getCharPointer().getAddress(), numBytes);
|
||||
#else
|
||||
// (This avoids using toUTF8() to prevent the memory bloat that it would leave behind
|
||||
// if lots of large, persistent strings were to be written to streams).
|
||||
HeapBlock<char> temp (numBytes + 1);
|
||||
CharPointer_UTF8 (temp).writeAll (text.getCharPointer());
|
||||
stream.write (temp, numBytes);
|
||||
#endif
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
@@ -293,4 +293,7 @@ BEAST_API OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, InputSt
|
||||
*/
|
||||
BEAST_API OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const NewLine&);
|
||||
|
||||
/** Writes a string to an OutputStream as UTF8. */
|
||||
BEAST_API OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const String& stringToWrite);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
// TargetPlatform.h should not use anything from BeastConfig.h
|
||||
#include "../../../beast/Config.h"
|
||||
#include "BeastConfigCheck.h"
|
||||
|
||||
// This file should be included before including any boost headers.
|
||||
// If you don't include this file, and you include boost headers,
|
||||
|
||||
78
src/beast/modules/beast_core/system/StandardIncludes.h
Normal file
78
src/beast/modules/beast_core/system/StandardIncludes.h
Normal file
@@ -0,0 +1,78 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Portions of this file are from JUCE.
|
||||
Copyright (c) 2013 - Raw Material Software Ltd.
|
||||
Please visit http://www.juce.com
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_STANDARDINCLUDES_H_INCLUDED
|
||||
#define BEAST_STANDARDINCLUDES_H_INCLUDED
|
||||
|
||||
// Include some common OS headers..
|
||||
#if BEAST_MSVC
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4514 4245 4100)
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <cfloat>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstdarg>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <new>
|
||||
#include <numeric>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
#include <vector>
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <float.h>
|
||||
#include <locale.h>
|
||||
#include <math.h>
|
||||
#include <memory.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// undef symbols that are sometimes set by misguided 3rd-party headers..
|
||||
#undef check
|
||||
#undef TYPE_BOOL
|
||||
#undef max
|
||||
#undef min
|
||||
|
||||
#endif
|
||||
@@ -30,7 +30,7 @@
|
||||
see BeastConfig.h.
|
||||
*/
|
||||
|
||||
#include "../../../beast/beast/Config.h"
|
||||
#include "../../../beast/beast/config/PlatformConfig.h"
|
||||
|
||||
#if BEAST_IOS || BEAST_MAC
|
||||
# define BEAST_HAVE_NATIVE_SQLITE 1
|
||||
|
||||
@@ -25,5 +25,7 @@
|
||||
#include "../beast/modules/beast_db/beast_db.cpp"
|
||||
#include "../beast/modules/beast_sqdb/beast_sqdb.cpp"
|
||||
|
||||
#include "../beast/beast/http/HTTP.cpp"
|
||||
#include "../beast/beast/net/Net.cpp"
|
||||
#include "../beast/beast/strings/Strings.cpp"
|
||||
#include "../beast/beast/utility/Utility.cpp"
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_MANAGER_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_MANAGER_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** Maintains the list of chosen validators.
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
/** Add a live source of validators from a trusted URL.
|
||||
The URL will be contacted periodically to update the list.
|
||||
*/
|
||||
virtual void addURL (UniformResourceLocator const& url) = 0;
|
||||
virtual void addURL (URL const& url) = 0;
|
||||
|
||||
/** Add a live source of validators.
|
||||
The caller loses ownership of the object.
|
||||
@@ -79,6 +79,7 @@ public:
|
||||
virtual void receiveValidation (ReceivedValidation const& rv) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_SOURCE_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_SOURCE_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** A source of validator descriptors. */
|
||||
class Source
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
virtual Result fetch (CancelCallback& callback, Journal journal) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_TYPES_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_TYPES_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
typedef RipplePublicKey PublicKey;
|
||||
typedef RipplePublicKeyHash PublicKeyHash;
|
||||
@@ -25,6 +25,7 @@ struct CancelCallback
|
||||
virtual bool shouldCancel () = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_CANCELCALLBACKS_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_CANCELCALLBACKS_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
// Dummy CancelCallback that does nothing
|
||||
//
|
||||
@@ -49,6 +49,7 @@ private:
|
||||
bool m_interrupted;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_CHOSENLIST_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_CHOSENLIST_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
class ChosenList : public SharedObject
|
||||
{
|
||||
@@ -59,6 +59,7 @@ private:
|
||||
MapType m_map;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_LOGIC_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_LOGIC_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
// Tunable constants
|
||||
enum
|
||||
@@ -400,6 +400,7 @@ public:
|
||||
//----------------------------------------------------------------------
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -84,8 +84,8 @@ What determines that a validator is good?
|
||||
the behavior is measured.
|
||||
*/
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
class ManagerImp
|
||||
: public Manager
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
addStaticSource (SourceFile::New (file));
|
||||
}
|
||||
|
||||
void addURL (UniformResourceLocator const& url)
|
||||
void addURL (URL const& url)
|
||||
{
|
||||
addSource (SourceURL::New (url));
|
||||
}
|
||||
@@ -308,3 +308,4 @@ Validators::Manager* Validators::Manager::New (Stoppable& parent, Journal journa
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
Source::Result::Result ()
|
||||
: success (false)
|
||||
@@ -21,3 +21,4 @@ void Source::Result::swapWith (Result& other)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_SOURCEDESC_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_SOURCEDESC_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** Additional state information associated with a Source. */
|
||||
struct SourceDesc
|
||||
@@ -52,6 +52,7 @@ struct SourceDesc
|
||||
|
||||
typedef DynamicList <SourceDesc> SourcesType;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
class SourceFileImp : public SourceFile
|
||||
{
|
||||
@@ -56,3 +56,4 @@ SourceFile* SourceFile::New (File const& file)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_SOURCEFILE_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_SOURCEFILE_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** Provides validators from a text file.
|
||||
Typically this will come from a local configuration file.
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
static SourceFile* New (File const& path);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
class SourceStringsImp : public SourceStrings
|
||||
{
|
||||
@@ -70,3 +70,4 @@ SourceStrings* SourceStrings::New (
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_SOURCESTRINGS_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_SOURCESTRINGS_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** Provides validators from a set of Validator strings.
|
||||
Typically this will come from a local configuration file.
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
String name, StringArray const& strings);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
class SourceURLImp : public SourceURL
|
||||
{
|
||||
public:
|
||||
explicit SourceURLImp (UniformResourceLocator const& url)
|
||||
explicit SourceURLImp (URL const& url)
|
||||
: m_url (url)
|
||||
{
|
||||
}
|
||||
@@ -57,13 +57,13 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
UniformResourceLocator m_url;
|
||||
URL m_url;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
SourceURL* SourceURL::New (
|
||||
UniformResourceLocator const& url)
|
||||
URL const& url)
|
||||
{
|
||||
ScopedPointer <SourceURL> object (
|
||||
new SourceURLImp (url));
|
||||
@@ -72,3 +72,4 @@ SourceURL* SourceURL::New (
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
#ifndef RIPPLE_VALIDATORS_SOURCEURL_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_SOURCEURL_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** Provides validators from a trusted URI (e.g. HTTPS)
|
||||
*/
|
||||
/** Provides validators from a trusted URI (e.g. HTTPS) */
|
||||
class SourceURL : public Source
|
||||
{
|
||||
public:
|
||||
static SourceURL* New (UniformResourceLocator const& url);
|
||||
static SourceURL* New (URL const& url);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_STORE_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_STORE_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** Abstract persistence for Validators data. */
|
||||
class Store
|
||||
@@ -29,6 +29,7 @@ protected:
|
||||
Store () { }
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
StoreSqdb::StoreSqdb (Journal journal)
|
||||
: m_journal (journal)
|
||||
@@ -343,3 +343,4 @@ Error StoreSqdb::init ()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_STORESQDB_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_STORESQDB_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** Database persistence for Validators using SQLite */
|
||||
class StoreSqdb : public Store
|
||||
@@ -36,6 +36,7 @@ private:
|
||||
sqdb::session m_session;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
class Tests : public UnitTest
|
||||
{
|
||||
@@ -220,3 +220,4 @@ public:
|
||||
static Tests tests;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
struct Utilities::Helpers
|
||||
{
|
||||
@@ -252,3 +252,4 @@ PublicKey Utilities::stringToPublicKey (std::string const& s)
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#ifndef RIPPLE_VALIDATORS_UTILITIES_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_UTILITIES_H_INCLUDED
|
||||
|
||||
namespace Validators
|
||||
{
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
|
||||
/** Common code for Validators classes.
|
||||
*/
|
||||
@@ -67,6 +67,7 @@ public:
|
||||
Source::Info& info, std::string const& line, Journal journal);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user