mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-04 18:55:49 +00:00
Update for beast changes:
* Use simplified http::headers * Use new beast::http::message: - Call beast::http::prepare - message::method is now a string * Remove deprecated_http
This commit is contained in:
@@ -242,20 +242,28 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\bind_handler.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\buffers_debug.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\buffer_cat.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\buffer_concepts.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\consuming_buffers.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\base64.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\bind_handler.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\buffer_cat.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\buffer_concepts.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\ci_char_traits.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\const_container.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\empty_base_optimization.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\get_lowest_layer.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\integer_sequence.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\is_call_possible.hpp">
|
||||
@@ -272,6 +280,8 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\stream\debug_ostream.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\stream_concepts.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\temp_dir.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\unit_test\amount.hpp">
|
||||
@@ -305,15 +315,21 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\handler_alloc.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\handler_concepts.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\basic_headers.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\basic_parser.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\basic_parser_v1.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\chunk_encode.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\body_type.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\detail\basic_parser.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\detail\basic_parser_v1.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\detail\write_preparation.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\detail\chunk_encode.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\detail\has_content_length.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\empty_body.hpp">
|
||||
</ClInclude>
|
||||
@@ -323,9 +339,9 @@
|
||||
</ClInclude>
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\basic_headers.ipp">
|
||||
</None>
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\basic_parser.ipp">
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\basic_parser_v1.ipp">
|
||||
</None>
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\message.ipp">
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\message_v1.ipp">
|
||||
</None>
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\read.ipp">
|
||||
</None>
|
||||
@@ -333,9 +349,9 @@
|
||||
</None>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\message.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\method.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\message_v1.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\parser.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\parser_v1.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\parse_error.hpp">
|
||||
</ClInclude>
|
||||
@@ -371,11 +387,15 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\static_streambuf.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\static_string.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\streambuf.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\streambuf_readstream.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\type_check.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\stream_concepts.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\to_string.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\websocket.hpp">
|
||||
</ClInclude>
|
||||
@@ -429,23 +449,12 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\websocket\ssl.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\websocket\static_string.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\websocket\stream.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\websocket\teardown.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\write_streambuf.hpp">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\beast\test\http\nodejs-parser\http_parser.c">
|
||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\beast\test\http\nodejs-parser\http_parser.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\beast\test\http\nodejs_parser.cpp">
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\beast\test\http\nodejs_parser.hpp">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ed25519-donna\curve25519-donna-32bit.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ed25519-donna\curve25519-donna-64bit.h">
|
||||
@@ -1629,8 +1638,6 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\beast\cxx17\type_traits.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\beast\deprecated_http.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\beast\hash\endian.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\beast\hash\fnv1a.h">
|
||||
@@ -3465,7 +3472,7 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\server\impl\SSLWSPeer.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\server\JsonWriter.h">
|
||||
<ClInclude Include="..\..\src\ripple\server\json_body.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\server\make_Server.h">
|
||||
</ClInclude>
|
||||
|
||||
@@ -478,15 +478,6 @@
|
||||
<Filter Include="sqlite\sqlite">
|
||||
<UniqueIdentifier>{D2A046B6-8986-92AC-082F-15B3A01B8E40}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="test">
|
||||
<UniqueIdentifier>{D5859751-012E-81F5-D121-159FE9A25436}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="test\http">
|
||||
<UniqueIdentifier>{F9ABC269-E86E-1034-C5DE-E9E5B48772DB}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="test\http\nodejs-parser">
|
||||
<UniqueIdentifier>{617863D3-DC6A-1DDA-ACA5-7DC92DCEAFB3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="websocketpp_02">
|
||||
<UniqueIdentifier>{96CE200F-2670-323E-3B37-B90DBC0EDA11}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -546,10 +537,10 @@
|
||||
<ClInclude Include="..\..\src\beast\include\beast\bind_handler.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\buffers_debug.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\buffer_cat.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\buffer_cat.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\buffer_concepts.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\consuming_buffers.hpp">
|
||||
@@ -558,6 +549,15 @@
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\base64.hpp">
|
||||
<Filter>include\beast\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\bind_handler.hpp">
|
||||
<Filter>include\beast\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\buffer_cat.hpp">
|
||||
<Filter>include\beast\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\buffer_concepts.hpp">
|
||||
<Filter>include\beast\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\ci_char_traits.hpp">
|
||||
<Filter>include\beast\detail</Filter>
|
||||
</ClInclude>
|
||||
@@ -567,6 +567,9 @@
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\empty_base_optimization.hpp">
|
||||
<Filter>include\beast\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\get_lowest_layer.hpp">
|
||||
<Filter>include\beast\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\integer_sequence.hpp">
|
||||
<Filter>include\beast\detail</Filter>
|
||||
</ClInclude>
|
||||
@@ -591,6 +594,9 @@
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\stream\debug_ostream.hpp">
|
||||
<Filter>include\beast\detail\stream</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\stream_concepts.hpp">
|
||||
<Filter>include\beast\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\detail\temp_dir.hpp">
|
||||
<Filter>include\beast\detail</Filter>
|
||||
</ClInclude>
|
||||
@@ -639,19 +645,28 @@
|
||||
<ClInclude Include="..\..\src\beast\include\beast\handler_alloc.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\handler_concepts.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\basic_headers.hpp">
|
||||
<Filter>include\beast\http</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\basic_parser.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\basic_parser_v1.hpp">
|
||||
<Filter>include\beast\http</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\chunk_encode.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\body_type.hpp">
|
||||
<Filter>include\beast\http</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\detail\basic_parser.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\detail\basic_parser_v1.hpp">
|
||||
<Filter>include\beast\http\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\detail\write_preparation.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\detail\chunk_encode.hpp">
|
||||
<Filter>include\beast\http\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\detail\has_content_length.hpp">
|
||||
<Filter>include\beast\http\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\empty_body.hpp">
|
||||
@@ -666,10 +681,10 @@
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\basic_headers.ipp">
|
||||
<Filter>include\beast\http\impl</Filter>
|
||||
</None>
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\basic_parser.ipp">
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\basic_parser_v1.ipp">
|
||||
<Filter>include\beast\http\impl</Filter>
|
||||
</None>
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\message.ipp">
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\message_v1.ipp">
|
||||
<Filter>include\beast\http\impl</Filter>
|
||||
</None>
|
||||
<None Include="..\..\src\beast\include\beast\http\impl\read.ipp">
|
||||
@@ -681,10 +696,10 @@
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\message.hpp">
|
||||
<Filter>include\beast\http</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\method.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\message_v1.hpp">
|
||||
<Filter>include\beast\http</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\parser.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\parser_v1.hpp">
|
||||
<Filter>include\beast\http</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\http\parse_error.hpp">
|
||||
@@ -738,13 +753,19 @@
|
||||
<ClInclude Include="..\..\src\beast\include\beast\static_streambuf.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\static_string.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\streambuf.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\streambuf_readstream.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\type_check.hpp">
|
||||
<ClInclude Include="..\..\src\beast\include\beast\stream_concepts.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\to_string.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\websocket.hpp">
|
||||
@@ -825,9 +846,6 @@
|
||||
<ClInclude Include="..\..\src\beast\include\beast\websocket\ssl.hpp">
|
||||
<Filter>include\beast\websocket</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\websocket\static_string.hpp">
|
||||
<Filter>include\beast\websocket</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\beast\include\beast\websocket\stream.hpp">
|
||||
<Filter>include\beast\websocket</Filter>
|
||||
</ClInclude>
|
||||
@@ -837,18 +855,6 @@
|
||||
<ClInclude Include="..\..\src\beast\include\beast\write_streambuf.hpp">
|
||||
<Filter>include\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\beast\test\http\nodejs-parser\http_parser.c">
|
||||
<Filter>test\http\nodejs-parser</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\beast\test\http\nodejs-parser\http_parser.h">
|
||||
<Filter>test\http\nodejs-parser</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\beast\test\http\nodejs_parser.cpp">
|
||||
<Filter>test\http</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\beast\test\http\nodejs_parser.hpp">
|
||||
<Filter>test\http</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ed25519-donna\curve25519-donna-32bit.h">
|
||||
<Filter>ed25519-donna</Filter>
|
||||
</ClInclude>
|
||||
@@ -2151,9 +2157,6 @@
|
||||
<ClInclude Include="..\..\src\ripple\beast\cxx17\type_traits.h">
|
||||
<Filter>ripple\beast\cxx17</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\beast\deprecated_http.h">
|
||||
<Filter>ripple\beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\beast\hash\endian.h">
|
||||
<Filter>ripple\beast\hash</Filter>
|
||||
</ClInclude>
|
||||
@@ -3924,7 +3927,7 @@
|
||||
<ClInclude Include="..\..\src\ripple\server\impl\SSLWSPeer.h">
|
||||
<Filter>ripple\server\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\server\JsonWriter.h">
|
||||
<ClInclude Include="..\..\src\ripple\server\json_body.h">
|
||||
<Filter>ripple\server</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\server\make_Server.h">
|
||||
|
||||
@@ -1110,7 +1110,6 @@ for tu_style in ['classic', 'unity']:
|
||||
cc_flags = {}
|
||||
|
||||
object_builder.add_source_files(
|
||||
'src/beast/test/http/nodejs_parser.cpp',
|
||||
'src/ripple/beast/unity/beast_hash_unity.cpp',
|
||||
'src/ripple/unity/beast.cpp',
|
||||
'src/ripple/unity/lz4.c',
|
||||
|
||||
@@ -1,480 +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_DEPRECATED_HTTP_H
|
||||
#define BEAST_DEPRECATED_HTTP_H
|
||||
|
||||
#include <beast/http/method.hpp>
|
||||
#include <beast/http/headers.hpp>
|
||||
#include <beast/http/basic_parser.hpp>
|
||||
#include <beast/http/rfc2616.hpp>
|
||||
#include <beast/write_streambuf.hpp>
|
||||
#include <beast/test/http/nodejs_parser.hpp>
|
||||
#include <beast/detail/ci_char_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace beast {
|
||||
namespace deprecated_http {
|
||||
|
||||
/** Container for the HTTP content-body. */
|
||||
class body
|
||||
{
|
||||
private:
|
||||
using buffer_type = boost::asio::streambuf;
|
||||
|
||||
// Hack: use unique_ptr because streambuf cant be moved
|
||||
std::unique_ptr <buffer_type> buf_;
|
||||
|
||||
public:
|
||||
using const_buffers_type = buffer_type::const_buffers_type;
|
||||
|
||||
body();
|
||||
body (body&& other);
|
||||
body& operator= (body&& other);
|
||||
|
||||
body (body const&) = delete;
|
||||
body& operator= (body const&) = delete;
|
||||
|
||||
template <class = void>
|
||||
void
|
||||
clear();
|
||||
|
||||
void
|
||||
write (void const* data, std::size_t bytes);
|
||||
|
||||
template <class ConstBufferSequence>
|
||||
void
|
||||
write (ConstBufferSequence const& buffers);
|
||||
|
||||
std::size_t
|
||||
size() const;
|
||||
|
||||
const_buffers_type
|
||||
data() const;
|
||||
};
|
||||
|
||||
template <class = void>
|
||||
std::string
|
||||
to_string (body const& b)
|
||||
{
|
||||
std::string s;
|
||||
auto const& data (b.data());
|
||||
auto const n (boost::asio::buffer_size (data));
|
||||
s.resize (n);
|
||||
boost::asio::buffer_copy (
|
||||
boost::asio::buffer (&s[0], n), data);
|
||||
return s;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
body::body()
|
||||
: buf_ (std::make_unique <buffer_type>())
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
body::body (body&& other)
|
||||
: buf_ (std::move(other.buf_))
|
||||
{
|
||||
other.clear();
|
||||
}
|
||||
|
||||
inline
|
||||
body&
|
||||
body::operator= (body&& other)
|
||||
{
|
||||
buf_ = std::move(other.buf_);
|
||||
other.clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class>
|
||||
void
|
||||
body::clear()
|
||||
{
|
||||
buf_ = std::make_unique <buffer_type>();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
body::write (void const* data, std::size_t bytes)
|
||||
{
|
||||
buf_->commit (boost::asio::buffer_copy (buf_->prepare (bytes),
|
||||
boost::asio::const_buffers_1 (data, bytes)));
|
||||
}
|
||||
|
||||
template <class ConstBufferSequence>
|
||||
void
|
||||
body::write (ConstBufferSequence const& buffers)
|
||||
{
|
||||
for (auto const& buffer : buffers)
|
||||
write (boost::asio::buffer_cast <void const*> (buffer),
|
||||
boost::asio::buffer_size (buffer));
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
body::size() const
|
||||
{
|
||||
return buf_->size();
|
||||
}
|
||||
|
||||
inline
|
||||
auto
|
||||
body::data() const
|
||||
-> const_buffers_type
|
||||
{
|
||||
return buf_->data();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
std::pair<int, int>
|
||||
http_1_0()
|
||||
{
|
||||
return std::pair<int, int>(1, 0);
|
||||
}
|
||||
|
||||
inline
|
||||
std::pair<int, int>
|
||||
http_1_1()
|
||||
{
|
||||
return std::pair<int, int>(1, 1);
|
||||
}
|
||||
|
||||
class message
|
||||
{
|
||||
private:
|
||||
bool request_;
|
||||
|
||||
// request
|
||||
beast::http::method_t method_;
|
||||
std::string url_;
|
||||
|
||||
// response
|
||||
int status_;
|
||||
std::string reason_;
|
||||
|
||||
// message
|
||||
std::pair<int, int> version_;
|
||||
bool keep_alive_;
|
||||
bool upgrade_;
|
||||
|
||||
public:
|
||||
~message() = default;
|
||||
message (message const&) = default;
|
||||
message (message&& other) = default;
|
||||
message& operator= (message const&) = default;
|
||||
message& operator= (message&& other) = default;
|
||||
|
||||
template <class = void>
|
||||
message();
|
||||
|
||||
// Memberspace
|
||||
beast::http::headers<std::allocator<char>> headers;
|
||||
|
||||
bool
|
||||
request() const
|
||||
{
|
||||
return request_;
|
||||
}
|
||||
|
||||
void
|
||||
request (bool value)
|
||||
{
|
||||
request_ = value;
|
||||
}
|
||||
|
||||
// Request
|
||||
|
||||
void
|
||||
method (beast::http::method_t http_method)
|
||||
{
|
||||
method_ = http_method;
|
||||
}
|
||||
|
||||
beast::http::method_t
|
||||
method() const
|
||||
{
|
||||
return method_;
|
||||
}
|
||||
|
||||
void
|
||||
url (std::string const& s)
|
||||
{
|
||||
url_ = s;
|
||||
}
|
||||
|
||||
std::string const&
|
||||
url() const
|
||||
{
|
||||
return url_;
|
||||
}
|
||||
|
||||
/** Returns `false` if this is not the last message.
|
||||
When keep_alive returns `false`:
|
||||
* Server roles respond with a "Connection: close" header.
|
||||
* Client roles close the connection.
|
||||
*/
|
||||
bool
|
||||
keep_alive() const
|
||||
{
|
||||
return keep_alive_;
|
||||
}
|
||||
|
||||
/** Set the keep_alive setting. */
|
||||
void
|
||||
keep_alive (bool value)
|
||||
{
|
||||
keep_alive_ = value;
|
||||
}
|
||||
|
||||
/** Returns `true` if this is an HTTP Upgrade message.
|
||||
@note Upgrade messages have no content body.
|
||||
*/
|
||||
bool
|
||||
upgrade() const
|
||||
{
|
||||
return upgrade_;
|
||||
}
|
||||
|
||||
/** Set the upgrade setting. */
|
||||
void
|
||||
upgrade (bool value)
|
||||
{
|
||||
upgrade_ = value;
|
||||
}
|
||||
|
||||
int
|
||||
status() const
|
||||
{
|
||||
return status_;
|
||||
}
|
||||
|
||||
void
|
||||
status (int code)
|
||||
{
|
||||
status_ = code;
|
||||
}
|
||||
|
||||
std::string const&
|
||||
reason() const
|
||||
{
|
||||
return reason_;
|
||||
}
|
||||
|
||||
void
|
||||
reason (std::string const& text)
|
||||
{
|
||||
reason_ = text;
|
||||
}
|
||||
|
||||
// Message
|
||||
|
||||
void
|
||||
version (int major, int minor)
|
||||
{
|
||||
version_ = std::make_pair (major, minor);
|
||||
}
|
||||
|
||||
void
|
||||
version (std::pair<int, int> p)
|
||||
{
|
||||
version_ = p;
|
||||
}
|
||||
|
||||
std::pair<int, int>
|
||||
version() const
|
||||
{
|
||||
return version_;
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <class>
|
||||
message::message()
|
||||
: request_ (true)
|
||||
, method_ (beast::http::method_t::http_get)
|
||||
, url_ ("/")
|
||||
, status_ (200)
|
||||
, version_ (1, 1)
|
||||
, keep_alive_ (false)
|
||||
, upgrade_ (false)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <class Streambuf>
|
||||
void
|
||||
write (Streambuf& stream, message const& m)
|
||||
{
|
||||
if (m.request())
|
||||
{
|
||||
beast::write (stream, to_string(m.method()));
|
||||
beast::write (stream, " ");
|
||||
beast::write (stream, m.url());
|
||||
beast::write (stream, " HTTP/");
|
||||
beast::write (stream, std::to_string(m.version().first));
|
||||
beast::write (stream, ".");
|
||||
beast::write (stream, std::to_string(m.version().second));
|
||||
}
|
||||
else
|
||||
{
|
||||
beast::write (stream, "HTTP/");
|
||||
beast::write (stream, std::to_string(m.version().first));
|
||||
beast::write (stream, ".");
|
||||
beast::write (stream, std::to_string(m.version().second));
|
||||
beast::write (stream, " ");
|
||||
beast::write (stream, std::to_string(m.status()));
|
||||
beast::write (stream, " ");
|
||||
beast::write (stream, m.reason());
|
||||
}
|
||||
beast::write (stream, "\r\n");
|
||||
write_fields(stream, m.headers);
|
||||
beast::write (stream, "\r\n");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class parser
|
||||
: public beast::http::nodejs_basic_parser<parser>
|
||||
{
|
||||
message& m_;
|
||||
std::function<void(void const*, std::size_t)> write_body_;
|
||||
std::string field_;
|
||||
std::string value_;
|
||||
|
||||
public:
|
||||
parser(parser&&) = default;
|
||||
parser(parser const&) = delete;
|
||||
parser& operator=(parser&&) = delete;
|
||||
parser& operator=(parser const&) = delete;
|
||||
|
||||
/** Construct a parser for HTTP request or response.
|
||||
The headers plus request or status line are stored in message.
|
||||
The content-body, if any, is passed as a series of calls to
|
||||
the write_body function. Transfer encodings are applied before
|
||||
any data is passed to the write_body function.
|
||||
*/
|
||||
parser(std::function<void(void const*, std::size_t)> write_body,
|
||||
message& m, bool request)
|
||||
: nodejs_basic_parser(request)
|
||||
, m_(m)
|
||||
, write_body_(std::move(write_body))
|
||||
{
|
||||
m_.request(request);
|
||||
}
|
||||
|
||||
parser(message& m, body& b, bool request)
|
||||
: nodejs_basic_parser(request)
|
||||
, m_(m)
|
||||
{
|
||||
write_body_ = [&b](void const* data, std::size_t size)
|
||||
{
|
||||
b.write(data, size);
|
||||
};
|
||||
m_.request(request);
|
||||
}
|
||||
|
||||
//private:
|
||||
|
||||
void flush()
|
||||
{
|
||||
if(! value_.empty())
|
||||
{
|
||||
rfc2616::trim_right_in_place(value_);
|
||||
// VFALCO could std::move
|
||||
m_.headers.insert(field_, value_);
|
||||
field_.clear();
|
||||
value_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
on_start()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
on_headers_complete(error_code&)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
on_request(http::method_t method, std::string const& url,
|
||||
int major, int minor, bool keep_alive, bool upgrade)
|
||||
{
|
||||
m_.method(method);
|
||||
m_.url(url);
|
||||
m_.version(major, minor);
|
||||
m_.keep_alive(keep_alive);
|
||||
m_.upgrade(upgrade);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
on_response(int status, std::string const& text,
|
||||
int major, int minor, bool keep_alive, bool upgrade)
|
||||
{
|
||||
m_.status(status);
|
||||
m_.reason(text);
|
||||
m_.version(major, minor);
|
||||
m_.keep_alive(keep_alive);
|
||||
m_.upgrade(upgrade);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
on_field(std::string const& field, std::string const& value)
|
||||
{
|
||||
m_.headers.insert(field, value);
|
||||
}
|
||||
|
||||
void
|
||||
on_body(void const* data, std::size_t bytes, error_code&)
|
||||
{
|
||||
write_body_(data, bytes);
|
||||
}
|
||||
|
||||
void
|
||||
on_complete()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // deprecated_http
|
||||
} // beast
|
||||
|
||||
#endif
|
||||
@@ -23,7 +23,9 @@
|
||||
#include <ripple/overlay/impl/PeerImp.h>
|
||||
#include <ripple/overlay/impl/Tuning.h>
|
||||
#include <ripple/json/json_reader.h>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <beast/to_string.hpp>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -45,13 +47,6 @@ ConnectAttempt::ConnectAttempt (Application& app, boost::asio::io_service& io_se
|
||||
context, io_service))
|
||||
, socket_ (ssl_bundle_->socket)
|
||||
, stream_ (ssl_bundle_->stream)
|
||||
, parser_ (
|
||||
[&](void const* data, std::size_t size)
|
||||
{
|
||||
body_.commit(boost::asio::buffer_copy(body_.prepare(size),
|
||||
boost::asio::buffer(data, size)));
|
||||
}
|
||||
, response_, false)
|
||||
, slot_ (slot)
|
||||
{
|
||||
JLOG(journal_.debug()) <<
|
||||
@@ -244,11 +239,13 @@ ConnectAttempt::onWrite (error_code ec)
|
||||
return;
|
||||
if(ec)
|
||||
return fail("onWrite", ec);
|
||||
onRead(error_code(), 0);
|
||||
beast::http::async_read(stream_, read_buf_, response_,
|
||||
strand_.wrap(std::bind(&ConnectAttempt::onRead,
|
||||
shared_from_this(), beast::asio::placeholders::error)));
|
||||
}
|
||||
|
||||
void
|
||||
ConnectAttempt::onRead (error_code ec, std::size_t bytes_transferred)
|
||||
ConnectAttempt::onRead (error_code ec)
|
||||
{
|
||||
cancelTimer();
|
||||
|
||||
@@ -267,35 +264,7 @@ ConnectAttempt::onRead (error_code ec, std::size_t bytes_transferred)
|
||||
}
|
||||
if(ec)
|
||||
return fail("onRead", ec);
|
||||
if(auto stream = journal_.trace())
|
||||
{
|
||||
if(bytes_transferred > 0)
|
||||
stream << "onRead: " << bytes_transferred << " bytes";
|
||||
else
|
||||
stream << "onRead";
|
||||
}
|
||||
|
||||
if (! ec)
|
||||
{
|
||||
write_buf_.commit(bytes_transferred);
|
||||
auto bytes_consumed = parser_.write(
|
||||
write_buf_.data(), ec);
|
||||
if (! ec)
|
||||
{
|
||||
write_buf_.consume (bytes_consumed);
|
||||
if (parser_.complete())
|
||||
return processResponse(response_, body_);
|
||||
}
|
||||
}
|
||||
|
||||
if (ec)
|
||||
return fail("onRead", ec);
|
||||
|
||||
setTimer();
|
||||
stream_.async_read_some (write_buf_.prepare (Tuning::readBufferBytes),
|
||||
strand_.wrap (std::bind (&ConnectAttempt::onRead,
|
||||
shared_from_this(), beast::asio::placeholders::error,
|
||||
beast::asio::placeholders::bytes_transferred)));
|
||||
processResponse();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -321,7 +290,7 @@ ConnectAttempt::makeRequest (bool crawl,
|
||||
request_type
|
||||
{
|
||||
request_type m;
|
||||
m.method = beast::http::method_t::http_get;
|
||||
m.method = "GET";
|
||||
m.url = "/";
|
||||
m.version = 11;
|
||||
m.headers.insert ("User-Agent", BuildInfo::getFullVersionString());
|
||||
@@ -333,16 +302,14 @@ ConnectAttempt::makeRequest (bool crawl,
|
||||
return m;
|
||||
}
|
||||
|
||||
template <class Streambuf>
|
||||
void
|
||||
ConnectAttempt::processResponse (beast::deprecated_http::message const& m,
|
||||
Streambuf const& body)
|
||||
ConnectAttempt::processResponse()
|
||||
{
|
||||
if (response_.status() == 503)
|
||||
if (response_.status == 503)
|
||||
{
|
||||
Json::Value json;
|
||||
Json::Reader r;
|
||||
auto const success = r.parse(to_string(body), json);
|
||||
auto const success = r.parse(beast::to_string(response_.body.data()), json);
|
||||
if (success)
|
||||
{
|
||||
if (json.isObject() && json.isMember("peer-ips"))
|
||||
@@ -369,10 +336,10 @@ ConnectAttempt::processResponse (beast::deprecated_http::message const& m,
|
||||
}
|
||||
}
|
||||
|
||||
if (! OverlayImpl::isPeerUpgrade(m))
|
||||
if (! OverlayImpl::isPeerUpgrade(response_))
|
||||
{
|
||||
JLOG(journal_.info()) <<
|
||||
"HTTP Response: " << m.status() << " " << m.reason();
|
||||
"HTTP Response: " << response_.status << " " << response_.reason;
|
||||
return close();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
#include <ripple/beast/utility/WrappedSink.h>
|
||||
#include <beast/placeholders.hpp>
|
||||
#include <beast/streambuf.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/message_v1.hpp>
|
||||
#include <beast/http/empty_body.hpp>
|
||||
#include <beast/http/parser.hpp>
|
||||
#include <beast/http/parser_v1.hpp>
|
||||
#include <boost/asio/basic_waitable_timer.hpp>
|
||||
#include <boost/asio/buffers_iterator.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
@@ -56,7 +56,10 @@ private:
|
||||
using endpoint_type = boost::asio::ip::tcp::endpoint;
|
||||
|
||||
using request_type =
|
||||
beast::http::request<beast::http::empty_body>;
|
||||
beast::http::request_v1<beast::http::empty_body>;
|
||||
|
||||
using response_type =
|
||||
beast::http::response_v1<beast::http::streambuf_body>;
|
||||
|
||||
Application& app_;
|
||||
std::uint32_t const id_;
|
||||
@@ -70,10 +73,7 @@ private:
|
||||
beast::asio::ssl_bundle::socket_type& socket_;
|
||||
beast::asio::ssl_bundle::stream_type& stream_;
|
||||
beast::streambuf read_buf_;
|
||||
beast::streambuf write_buf_;
|
||||
beast::deprecated_http::message response_;
|
||||
beast::streambuf body_;
|
||||
beast::deprecated_http::parser parser_;
|
||||
response_type response_;
|
||||
PeerFinder::Slot::ptr slot_;
|
||||
request_type req_;
|
||||
|
||||
@@ -103,7 +103,7 @@ private:
|
||||
void onConnect (error_code ec);
|
||||
void onHandshake (error_code ec);
|
||||
void onWrite (error_code ec);
|
||||
void onRead (error_code ec, std::size_t bytes_transferred);
|
||||
void onRead (error_code ec);
|
||||
void onShutdown (error_code ec);
|
||||
|
||||
static
|
||||
@@ -111,9 +111,7 @@ private:
|
||||
makeRequest (bool crawl,
|
||||
boost::asio::ip::address const& remote_address);
|
||||
|
||||
template <class Streambuf>
|
||||
void processResponse (beast::deprecated_http::message const& m,
|
||||
Streambuf const& body);
|
||||
void processResponse();
|
||||
|
||||
template <class = void>
|
||||
static
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/basics/make_SSLContext.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/server/JsonWriter.h>
|
||||
#include <ripple/server/json_body.h>
|
||||
#include <ripple/server/SimpleWriter.h>
|
||||
#include <ripple/overlay/Cluster.h>
|
||||
#include <ripple/overlay/impl/ConnectAttempt.h>
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <ripple/beast/core/ByteOrder.h>
|
||||
#include <beast/detail/base64.hpp>
|
||||
#include <ripple/beast/core/LexicalCast.h>
|
||||
#include <beast/http.hpp>
|
||||
#include <beast/http/rfc2616.hpp>
|
||||
#include <beast/detail/ci_char_traits.hpp>
|
||||
#include <ripple/beast/utility/WrappedSink.h>
|
||||
@@ -324,16 +325,16 @@ OverlayImpl::isPeerUpgrade(http_request_type const& request)
|
||||
}
|
||||
|
||||
bool
|
||||
OverlayImpl::isPeerUpgrade(beast::deprecated_http::message const& request)
|
||||
OverlayImpl::isPeerUpgrade(http_response_type const& response)
|
||||
{
|
||||
if (! request.upgrade())
|
||||
if (! is_upgrade(response))
|
||||
return false;
|
||||
if(response.status != 101)
|
||||
return false;
|
||||
auto const versions = parse_ProtocolVersions(
|
||||
request.headers["Upgrade"]);
|
||||
response.headers["Upgrade"]);
|
||||
if (versions.size() == 0)
|
||||
return false;
|
||||
if(! request.request() && request.status() != 101)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -349,47 +350,39 @@ std::shared_ptr<Writer>
|
||||
OverlayImpl::makeRedirectResponse (PeerFinder::Slot::ptr const& slot,
|
||||
http_request_type const& request, address_type remote_address)
|
||||
{
|
||||
Json::Value json(Json::objectValue);
|
||||
beast::http::response_v1<json_body> msg;
|
||||
msg.version = request.version;
|
||||
msg.status = 503;
|
||||
msg.reason = "Service Unavailable";
|
||||
msg.headers.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.headers.insert("Remote-Address", remote_address.to_string());
|
||||
msg.headers.insert("Content-Type", "application/json");
|
||||
msg.body = Json::objectValue;
|
||||
{
|
||||
auto const result = m_peerFinder->redirect(slot);
|
||||
Json::Value& ips = (json["peer-ips"] = Json::arrayValue);
|
||||
Json::Value& ips = (msg.body["peer-ips"] = Json::arrayValue);
|
||||
for (auto const& _ : m_peerFinder->redirect(slot))
|
||||
ips.append(_.address.to_string());
|
||||
}
|
||||
|
||||
beast::deprecated_http::message m;
|
||||
m.request(false);
|
||||
m.status(503);
|
||||
m.reason("Service Unavailable");
|
||||
m.headers.insert("Remote-Address", remote_address.to_string());
|
||||
m.version(std::make_pair(request.version / 10, request.version % 10));
|
||||
if (request.version == 10)
|
||||
{
|
||||
//?
|
||||
}
|
||||
auto const response = make_JsonWriter (m, json);
|
||||
return response;
|
||||
prepare(msg, beast::http::connection::close);
|
||||
return std::make_shared<SimpleWriter>(msg);
|
||||
}
|
||||
|
||||
std::shared_ptr<Writer>
|
||||
OverlayImpl::makeErrorResponse (PeerFinder::Slot::ptr const& slot,
|
||||
http_request_type const& request,
|
||||
address_type remote_address,
|
||||
std::string msg)
|
||||
std::string text)
|
||||
{
|
||||
beast::deprecated_http::message m;
|
||||
m.version(std::make_pair(request.version / 10, request.version % 10));
|
||||
m.request(false);
|
||||
m.status(400);
|
||||
m.reason("Bad Request");
|
||||
m.headers.insert("Remote-Address", remote_address.to_string());
|
||||
|
||||
auto response = std::make_shared<SimpleWriter> (std::move(m));
|
||||
|
||||
if (!msg.empty())
|
||||
response->body (msg);
|
||||
|
||||
return response;
|
||||
beast::http::response_v1<beast::http::string_body> msg;
|
||||
msg.version = request.version;
|
||||
msg.status = 400;
|
||||
msg.reason = "Bad Request";
|
||||
msg.headers.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.headers.insert("Remote-Address", remote_address.to_string());
|
||||
msg.body = text;
|
||||
prepare(msg, beast::http::connection::close);
|
||||
return std::make_shared<SimpleWriter>(msg);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -891,14 +884,15 @@ OverlayImpl::processRequest (http_request_type const& req,
|
||||
if (req.url != "/crawl")
|
||||
return false;
|
||||
|
||||
beast::deprecated_http::message resp;
|
||||
resp.request(false);
|
||||
resp.status(200);
|
||||
resp.reason("OK");
|
||||
resp.version(std::make_pair(req.version / 10, req.version % 10));
|
||||
Json::Value v;
|
||||
v["overlay"] = crawl();
|
||||
handoff.response = make_JsonWriter(resp, v);
|
||||
beast::http::response_v1<json_body> msg;
|
||||
msg.version = req.version;
|
||||
msg.status = 200;
|
||||
msg.reason = "OK";
|
||||
msg.headers.insert("Server", BuildInfo::getFullVersionString());
|
||||
msg.headers.insert("Content-Type", "application/json");
|
||||
msg.body["overlay"] = crawl();
|
||||
prepare(msg, beast::http::connection::close);
|
||||
handoff.response = std::make_shared<SimpleWriter>(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <ripple/overlay/Overlay.h>
|
||||
#include <ripple/overlay/impl/Manifest.h>
|
||||
#include <ripple/overlay/impl/TrafficCount.h>
|
||||
#include <ripple/beast/deprecated_http.h>
|
||||
#include <ripple/server/Handoff.h>
|
||||
#include <ripple/server/ServerHandler.h>
|
||||
#include <ripple/basics/Resolver.h>
|
||||
@@ -259,7 +258,7 @@ public:
|
||||
|
||||
static
|
||||
bool
|
||||
isPeerUpgrade (beast::deprecated_http::message const& request);
|
||||
isPeerUpgrade (http_response_type const& response);
|
||||
|
||||
static
|
||||
std::string
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/beast/core/SemanticVersion.h>
|
||||
#include <ripple/beast/utility/weak_fn.h>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <algorithm>
|
||||
@@ -599,10 +600,9 @@ void PeerImp::doAccept()
|
||||
|
||||
// TODO Apply headers to connection state.
|
||||
|
||||
auto resp = makeResponse(
|
||||
beast::write (write_buffer_, makeResponse(
|
||||
! overlay_.peerFinder().config().peerPrivate,
|
||||
request_, remote_address_, *sharedValue);
|
||||
beast::deprecated_http::write (write_buffer_, resp);
|
||||
request_, remote_address_, *sharedValue));
|
||||
|
||||
auto const protocol = BuildInfo::make_protocol(hello_.protoversion());
|
||||
JLOG(journal_.info()) << "Protocol: " << to_string(protocol);
|
||||
@@ -641,17 +641,16 @@ void PeerImp::doAccept()
|
||||
onWriteResponse(error_code(), 0);
|
||||
}
|
||||
|
||||
beast::deprecated_http::message
|
||||
http_response_type
|
||||
PeerImp::makeResponse (bool crawl,
|
||||
http_request_type const& req,
|
||||
beast::IP::Endpoint remote,
|
||||
uint256 const& sharedValue)
|
||||
{
|
||||
beast::deprecated_http::message resp;
|
||||
resp.request(false);
|
||||
resp.status(101);
|
||||
resp.reason("Switching Protocols");
|
||||
resp.version(std::make_pair(req.version / 10, req.version % 10));
|
||||
http_response_type resp;
|
||||
resp.status = 101;
|
||||
resp.reason = "Switching Protocols";
|
||||
resp.version = req.version;
|
||||
resp.headers.insert("Connection", "Upgrade");
|
||||
resp.headers.insert("Upgrade", "RTXP/1.2");
|
||||
resp.headers.insert("Connect-AS", "Peer");
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <beast/streambuf.hpp>
|
||||
#include <ripple/beast/asio/ssl_bundle.h>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/parser.hpp>
|
||||
#include <beast/http/parser_v1.hpp>
|
||||
#include <ripple/beast/utility/WrappedSink.h>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
@@ -154,8 +154,8 @@ private:
|
||||
PeerFinder::Slot::ptr slot_;
|
||||
beast::streambuf read_buffer_;
|
||||
http_request_type request_;
|
||||
beast::deprecated_http::message response_;
|
||||
beast::http::headers<std::allocator<char>> const& headers_;
|
||||
http_response_type response_;
|
||||
beast::http::headers const& headers_;
|
||||
beast::streambuf write_buffer_;
|
||||
std::queue<Message::pointer> send_queue_;
|
||||
bool gracefulClose_ = false;
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
template <class Buffers>
|
||||
PeerImp (Application& app, std::unique_ptr<beast::asio::ssl_bundle>&& ssl_bundle,
|
||||
Buffers const& buffers, PeerFinder::Slot::ptr&& slot,
|
||||
beast::deprecated_http::message&& response, Resource::Consumer usage,
|
||||
http_response_type&& response, Resource::Consumer usage,
|
||||
protocol::TMHello const& hello,
|
||||
PublicKey const& publicKey, id_t id,
|
||||
OverlayImpl& overlay);
|
||||
@@ -360,7 +360,7 @@ private:
|
||||
void
|
||||
doAccept();
|
||||
|
||||
beast::deprecated_http::message
|
||||
http_response_type
|
||||
makeResponse (bool crawl, http_request_type const& req,
|
||||
beast::IP::Endpoint remoteAddress,
|
||||
uint256 const& sharedValue);
|
||||
@@ -477,7 +477,7 @@ private:
|
||||
template <class Buffers>
|
||||
PeerImp::PeerImp (Application& app, std::unique_ptr<beast::asio::ssl_bundle>&& ssl_bundle,
|
||||
Buffers const& buffers, PeerFinder::Slot::ptr&& slot,
|
||||
beast::deprecated_http::message&& response, Resource::Consumer usage,
|
||||
http_response_type&& response, Resource::Consumer usage,
|
||||
protocol::TMHello const& hello,
|
||||
PublicKey const& publicKey, id_t id,
|
||||
OverlayImpl& overlay)
|
||||
|
||||
@@ -154,7 +154,7 @@ buildHello (
|
||||
}
|
||||
|
||||
void
|
||||
appendHello (beast::http::headers<std::allocator<char>>& h,
|
||||
appendHello (beast::http::headers& h,
|
||||
protocol::TMHello const& hello)
|
||||
{
|
||||
//h.append ("Protocol-Versions",...
|
||||
@@ -222,7 +222,7 @@ parse_ProtocolVersions(boost::string_ref const& value)
|
||||
}
|
||||
|
||||
boost::optional<protocol::TMHello>
|
||||
parseHello (bool request, beast::http::headers<std::allocator<char>> const& h, beast::Journal journal)
|
||||
parseHello (bool request, beast::http::headers const& h, beast::Journal journal)
|
||||
{
|
||||
// protocol version in TMHello is obsolete,
|
||||
// it is supplanted by the values in the headers.
|
||||
|
||||
@@ -59,14 +59,14 @@ buildHello (uint256 const& sharedValue,
|
||||
|
||||
/** Insert HTTP headers based on the TMHello protocol message. */
|
||||
void
|
||||
appendHello (beast::http::headers<std::allocator<char>>& h, protocol::TMHello const& hello);
|
||||
appendHello (beast::http::headers& h, protocol::TMHello const& hello);
|
||||
|
||||
/** Parse HTTP headers into TMHello protocol message.
|
||||
@return A protocol message on success; an empty optional
|
||||
if the parsing failed.
|
||||
*/
|
||||
boost::optional<protocol::TMHello>
|
||||
parseHello (bool request, beast::http::headers<std::allocator<char>> const& h, beast::Journal journal);
|
||||
parseHello (bool request, beast::http::headers const& h, beast::Journal journal);
|
||||
|
||||
/** Validate and store the public key in the TMHello.
|
||||
This includes signature verification on the shared value.
|
||||
|
||||
@@ -72,7 +72,7 @@ struct Handler
|
||||
/** @} */
|
||||
|
||||
/** Called when we have a complete HTTP request. */
|
||||
// VFALCO TODO Pass the beast::deprecated_http::message as a parameter
|
||||
// VFALCO TODO Pass the message as a template arg
|
||||
virtual void onRequest (Session& session) = 0;
|
||||
|
||||
/** Called when the session ends.
|
||||
|
||||
@@ -21,18 +21,17 @@
|
||||
#define RIPPLE_SERVER_HANDOFF_H_INCLUDED
|
||||
|
||||
#include <ripple/server/Writer.h>
|
||||
#include <ripple/beast/deprecated_http.h>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/message_v1.hpp>
|
||||
#include <beast/http/streambuf_body.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
using http_request_type =
|
||||
beast::http::request<beast::http::streambuf_body>;
|
||||
beast::http::request_v1<beast::http::streambuf_body>;
|
||||
|
||||
using http_response_type =
|
||||
beast::deprecated_http::message;
|
||||
beast::http::response_v1<beast::http::streambuf_body>;
|
||||
|
||||
/** Used to indicate the result of a server connection handoff. */
|
||||
struct Handoff
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
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 RIPPLE_SERVER_JSONWRITER_H_INCLUDED
|
||||
#define RIPPLE_SERVER_JSONWRITER_H_INCLUDED
|
||||
|
||||
#include <ripple/beast/deprecated_http.h>
|
||||
#include <ripple/server/Writer.h>
|
||||
#include <ripple/json/json_value.h>
|
||||
#include <beast/streambuf.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <sstream>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
namespace detail {
|
||||
|
||||
/** Writer that sends to Streambufs sequentially. */
|
||||
template <class Streambuf>
|
||||
class message_writer : public Writer
|
||||
{
|
||||
private:
|
||||
Streambuf prebody_;
|
||||
Streambuf body_;
|
||||
std::size_t hint_ = 0;
|
||||
std::vector<boost::asio::const_buffer> data_;
|
||||
|
||||
public:
|
||||
message_writer (Streambuf&& prebody, Streambuf&& body);
|
||||
|
||||
bool
|
||||
complete() override;
|
||||
|
||||
bool
|
||||
prepare (std::size_t n, std::function<void(void)>) override;
|
||||
|
||||
std::vector<boost::asio::const_buffer>
|
||||
data() override;
|
||||
|
||||
void
|
||||
consume (std::size_t n) override;
|
||||
|
||||
private:
|
||||
std::vector<boost::asio::const_buffer>
|
||||
data(Streambuf& buf);
|
||||
};
|
||||
|
||||
template <class Streambuf>
|
||||
message_writer<Streambuf>::message_writer (
|
||||
Streambuf&& prebody, Streambuf&& body)
|
||||
: prebody_(std::move(prebody))
|
||||
, body_(std::move(body))
|
||||
{
|
||||
}
|
||||
|
||||
template <class Streambuf>
|
||||
bool
|
||||
message_writer<Streambuf>::complete()
|
||||
{
|
||||
return prebody_.size() == 0 && body_.size() == 0;
|
||||
}
|
||||
|
||||
template <class Streambuf>
|
||||
bool
|
||||
message_writer<Streambuf>::prepare (
|
||||
std::size_t n, std::function<void(void)>)
|
||||
{
|
||||
hint_ = n;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class Streambuf>
|
||||
std::vector<boost::asio::const_buffer>
|
||||
message_writer<Streambuf>::data()
|
||||
{
|
||||
return (prebody_.size() > 0) ?
|
||||
data(prebody_) : data(body_);
|
||||
}
|
||||
|
||||
template <class Streambuf>
|
||||
void
|
||||
message_writer<Streambuf>::consume (std::size_t n)
|
||||
{
|
||||
if (prebody_.size() > 0)
|
||||
return prebody_.consume(n);
|
||||
body_.consume(n);
|
||||
}
|
||||
|
||||
template <class Streambuf>
|
||||
std::vector<boost::asio::const_buffer>
|
||||
message_writer<Streambuf>::data(Streambuf& buf)
|
||||
{
|
||||
data_.resize(0);
|
||||
for (auto iter = buf.data().begin();
|
||||
hint_ > 0 && iter != buf.data().end(); ++iter)
|
||||
{
|
||||
auto const n = std::min(hint_,
|
||||
boost::asio::buffer_size(*iter));
|
||||
data_.emplace_back(boost::asio::buffer_cast<
|
||||
void const*>(*iter), n);
|
||||
hint_ -= n;
|
||||
}
|
||||
return data_;
|
||||
}
|
||||
|
||||
} // detail
|
||||
|
||||
using streambufs_writer = detail::message_writer<beast::streambuf>;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Write a Json::Value to a Streambuf. */
|
||||
template <class Streambuf>
|
||||
void
|
||||
write(Streambuf& buf, Json::Value const& json)
|
||||
{
|
||||
stream(json,
|
||||
[&buf](void const* data, std::size_t n)
|
||||
{
|
||||
buf.commit(boost::asio::buffer_copy(
|
||||
buf.prepare(n), boost::asio::buffer(data, n)));
|
||||
});
|
||||
}
|
||||
|
||||
/** Returns a Writer that streams the provided HTTP message and Json body.
|
||||
The message is modified to include the correct headers.
|
||||
*/
|
||||
template <class = void>
|
||||
std::shared_ptr<Writer>
|
||||
make_JsonWriter (beast::deprecated_http::message& m, Json::Value const& json)
|
||||
{
|
||||
beast::streambuf prebody;
|
||||
beast::streambuf body;
|
||||
write(body, json);
|
||||
// VFALCO TODO Better way to set a field
|
||||
m.headers.erase ("Content-Length");
|
||||
m.headers.insert("Content-Length", std::to_string(body.size()));
|
||||
m.headers.erase ("Content-Type");
|
||||
m.headers.insert("Content-Type", "application/json");
|
||||
beast::deprecated_http::write(prebody, m);
|
||||
return std::make_shared<streambufs_writer>(
|
||||
std::move(prebody), std::move(body));
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <ripple/core/Config.h>
|
||||
#include <ripple/server/Port.h>
|
||||
#include <ripple/overlay/Overlay.h>
|
||||
#include <ripple/beast/deprecated_http.h>
|
||||
#include <ripple/beast/utility/Journal.h>
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include <ripple/server/Writer.h>
|
||||
#include <ripple/server/WSSession.h>
|
||||
#include <ripple/beast/deprecated_http.h>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <ripple/beast/net/IPEndpoint.h>
|
||||
#include <ripple/beast/utility/Journal.h>
|
||||
|
||||
@@ -21,87 +21,59 @@
|
||||
#define RIPPLE_SERVER_SIMPLEWRITER_H_INCLUDED
|
||||
|
||||
#include <ripple/server/Writer.h>
|
||||
#include <ripple/beast/deprecated_http.h>
|
||||
#include <beast/http/message_v1.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <beast/streambuf.hpp>
|
||||
#include <beast/write_streambuf.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
/** Writer that sends a simple HTTP response with a message body. */
|
||||
/// Deprecated: Writer that serializes a HTTP/1 message
|
||||
class SimpleWriter : public Writer
|
||||
{
|
||||
private:
|
||||
beast::deprecated_http::message message_;
|
||||
beast::streambuf streambuf_;
|
||||
std::string body_;
|
||||
bool prepared_ = false;
|
||||
beast::streambuf sb_;
|
||||
|
||||
public:
|
||||
template<bool isRequest, class Body, class Headers>
|
||||
explicit
|
||||
SimpleWriter(beast::deprecated_http::message&& message)
|
||||
: message_(std::forward<beast::deprecated_http::message>(message))
|
||||
SimpleWriter(beast::http::message_v1<
|
||||
isRequest, Body, Headers> const& msg)
|
||||
{
|
||||
}
|
||||
|
||||
beast::deprecated_http::message&
|
||||
message()
|
||||
{
|
||||
return message_;
|
||||
beast::write(sb_, msg);
|
||||
}
|
||||
|
||||
bool
|
||||
complete() override
|
||||
{
|
||||
return streambuf_.size() == 0;
|
||||
return sb_.size() == 0;
|
||||
}
|
||||
|
||||
void
|
||||
consume (std::size_t bytes) override
|
||||
{
|
||||
streambuf_.consume(bytes);
|
||||
sb_.consume(bytes);
|
||||
}
|
||||
|
||||
bool
|
||||
prepare (std::size_t bytes,
|
||||
prepare(std::size_t bytes,
|
||||
std::function<void(void)>) override
|
||||
{
|
||||
if (! prepared_)
|
||||
do_prepare();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<boost::asio::const_buffer>
|
||||
data() override
|
||||
{
|
||||
auto const& buf = streambuf_.data();
|
||||
auto const& buf = sb_.data();
|
||||
std::vector<boost::asio::const_buffer> result;
|
||||
result.reserve(std::distance(buf.begin(), buf.end()));
|
||||
for (auto const& b : buf)
|
||||
result.push_back(b);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Set the content body. */
|
||||
void
|
||||
body (std::string const& s)
|
||||
{
|
||||
body_ = s;
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
do_prepare()
|
||||
{
|
||||
prepared_ = true;
|
||||
message_.headers.erase("Content-Length");
|
||||
message_.headers.insert("Content-Length",
|
||||
std::to_string(body_.size()));
|
||||
beast::deprecated_http::write(streambuf_, message_);
|
||||
beast::write(streambuf_, body_);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <ripple/beast/asio/ssl_error.h> // for is_short_read?
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/parser.hpp>
|
||||
#include <beast/http/parser_v1.hpp>
|
||||
#include <beast/http/streambuf_body.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/ssl/stream.hpp>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <ripple/protocol/BuildInfo.h>
|
||||
#include <beast/websocket.hpp>
|
||||
#include <beast/streambuf.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/message_v1.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace ripple {
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_address,
|
||||
beast::http::message<true, Body, Headers>&& request,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
boost::asio::io_service& io_service,
|
||||
beast::Journal journal);
|
||||
|
||||
@@ -148,7 +148,7 @@ BaseWSPeer<Impl>::BaseWSPeer(
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_address,
|
||||
beast::http::message<true, Body, Headers>&& request,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
boost::asio::io_service& io_service,
|
||||
beast::Journal journal)
|
||||
: BasePeer<Impl>(port, handler, remote_address,
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_address,
|
||||
beast::http::message<true, Body, Headers>&& request,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
socket_type&& socket,
|
||||
beast::Journal journal);
|
||||
|
||||
@@ -63,7 +63,7 @@ PlainWSPeer::PlainWSPeer(
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_address,
|
||||
beast::http::message<true, Body, Headers>&& request,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
socket_type&& socket,
|
||||
beast::Journal journal)
|
||||
: BaseWSPeer(port, handler, remote_address, std::move(request),
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_endpoint,
|
||||
beast::http::message<true, Body, Headers>&& request,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
std::unique_ptr<
|
||||
beast::asio::ssl_bundle>&& ssl_bundle,
|
||||
beast::Journal journal);
|
||||
@@ -73,7 +73,7 @@ SSLWSPeer::SSLWSPeer(
|
||||
Port const& port,
|
||||
Handler& handler,
|
||||
endpoint_type remote_endpoint,
|
||||
beast::http::message<true, Body, Headers>&& request,
|
||||
beast::http::request_v1<Body, Headers>&& request,
|
||||
std::unique_ptr<
|
||||
beast::asio::ssl_bundle>&& ssl_bundle,
|
||||
beast::Journal journal)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <ripple/app/misc/NetworkOPs.h>
|
||||
#include <ripple/beast/net/IPAddressConversion.h>
|
||||
#include <ripple/json/json_reader.h>
|
||||
#include <ripple/server/JsonWriter.h>
|
||||
#include <ripple/server/json_body.h>
|
||||
#include <ripple/server/make_ServerHandler.h>
|
||||
#include <ripple/server/impl/JSONRPCUtil.h>
|
||||
#include <ripple/server/impl/ServerHandlerImp.h>
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <ripple/rpc/impl/Tuning.h>
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <beast/detail/base64.hpp>
|
||||
#include <beast/http/headers.hpp>
|
||||
#include <beast/http/rfc2616.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
@@ -203,10 +204,9 @@ Json::Output makeOutput (Session& session)
|
||||
}
|
||||
|
||||
// HACK!
|
||||
template<class Allocator>
|
||||
static
|
||||
std::map<std::string, std::string>
|
||||
build_map(beast::http::headers<Allocator> const& h)
|
||||
build_map(beast::http::headers const& h)
|
||||
{
|
||||
std::map <std::string, std::string> c;
|
||||
for (auto const& e : h)
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <ripple/json/to_string.h>
|
||||
#include <ripple/net/InfoSub.h>
|
||||
#include <ripple/server/Handler.h>
|
||||
#include <ripple/server/JsonWriter.h>
|
||||
#include <ripple/server/ServerHandler.h>
|
||||
#include <ripple/server/Session.h>
|
||||
#include <ripple/server/WSSession.h>
|
||||
@@ -62,7 +61,12 @@ public:
|
||||
if(! sp)
|
||||
return;
|
||||
beast::streambuf sb;
|
||||
write(sb, jv);
|
||||
stream(jv,
|
||||
[&](void const* data, std::size_t n)
|
||||
{
|
||||
sb.commit(boost::asio::buffer_copy(
|
||||
sb.prepare(n), boost::asio::buffer(data, n)));
|
||||
});
|
||||
auto m = std::make_shared<
|
||||
StreambufWSMsg<decltype(sb)>>(
|
||||
std::move(sb));
|
||||
|
||||
76
src/ripple/server/json_body.h
Normal file
76
src/ripple/server/json_body.h
Normal file
@@ -0,0 +1,76 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
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 RIPPLE_SERVER_JSON_BODY_H
|
||||
#define RIPPLE_SERVER_JSON_BODY_H
|
||||
|
||||
#include <ripple/json/json_value.h>
|
||||
#include <beast/streambuf.hpp>
|
||||
#include <beast/http/body_type.hpp>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
/// Body that holds JSON
|
||||
struct json_body
|
||||
{
|
||||
using value_type = Json::Value;
|
||||
|
||||
class writer
|
||||
{
|
||||
beast::streambuf sb_;
|
||||
|
||||
public:
|
||||
template<bool isRequest, class Headers>
|
||||
explicit
|
||||
writer(beast::http::message<
|
||||
isRequest, json_body, Headers> const& m)
|
||||
{
|
||||
stream(m.body,
|
||||
[&](void const* data, std::size_t n)
|
||||
{
|
||||
sb_.commit(boost::asio::buffer_copy(
|
||||
sb_.prepare(n), boost::asio::buffer(data, n)));
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
init(beast::http::error_code&)
|
||||
{
|
||||
}
|
||||
|
||||
std::uint64_t
|
||||
content_length() const
|
||||
{
|
||||
return sb_.size();
|
||||
}
|
||||
|
||||
template<class Write>
|
||||
boost::tribool
|
||||
operator()(beast::http::resume_context&&,
|
||||
beast::http::error_code&, Write&& write)
|
||||
{
|
||||
write(sb_.data());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -18,12 +18,11 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/beast/deprecated_http.h>
|
||||
#include <ripple/test/JSONRPCClient.h>
|
||||
#include <ripple/json/json_reader.h>
|
||||
#include <ripple/json/to_string.h>
|
||||
#include <ripple/server/Port.h>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/message_v1.hpp>
|
||||
#include <beast/http/streambuf_body.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
@@ -107,8 +106,8 @@ public:
|
||||
using namespace boost::asio;
|
||||
using namespace std::string_literals;
|
||||
|
||||
request<string_body> req;
|
||||
req.method = method_t::http_post;
|
||||
request_v1<string_body> req;
|
||||
req.method = "POST";
|
||||
req.url = "/";
|
||||
req.version = 11;
|
||||
req.headers.insert("Content-Type", "application/json; charset=UTF-8");
|
||||
@@ -124,9 +123,10 @@ public:
|
||||
}
|
||||
req.body = to_string(jr);
|
||||
}
|
||||
prepare(req);
|
||||
write(stream_, req);
|
||||
|
||||
response<streambuf_body> res;
|
||||
response_v1<streambuf_body> res;
|
||||
read(stream_, bin_, res);
|
||||
|
||||
Json::Reader jr;
|
||||
|
||||
Reference in New Issue
Block a user