JSON-RPC 2.0
JSON-RPC 2.0 Modern C++ Library
|
Base class for framed transport mechanisms. More...
#include <framed_transport.hpp>
Static Protected Member Functions | |
static void | FrameMessage (std::ostream &output, const std::string &message) |
Constructs a framed message. | |
static auto | ReadHeadersFromStream (std::istream &input) -> HeaderMap |
static auto | ReadContentLengthFromStream (std::istream &input) -> int |
static auto | ReadContent (std::istream &input, std::size_t content_length) -> std::string |
Reads content from the input stream based on the content length. | |
static auto | ReceiveFramedMessage (std::istream &input) -> std::string |
Receives a framed message. | |
Static Protected Attributes | |
static constexpr const char * | kHeaderDelimiter = "\r\n\r\n" |
The delimiter used to separate headers from the message content. | |
Friends | |
class | FramedTransportTest |
Base class for framed transport mechanisms.
Provides modular functionality for sending and receiving framed messages.
Definition at line 18 of file framed_transport.hpp.
|
staticprotected |
Constructs a framed message.
Constructs a JSON message as a string with additional headers for Content-Length and Content-Type, similar to HTTP.
output | The output stream to write the framed message. |
message | The message to be framed. |
Definition at line 9 of file framed_transport.cpp.
Referenced by jsonrpc::transport::FramedPipeTransport::SendMessage(), jsonrpc::transport::FramedSocketTransport::SendMessage(), and jsonrpc::transport::FramedStdioTransport::SendMessage().
|
staticprotected |
Reads content from the input stream based on the content length.
input | The input stream to read the content from. |
content_length | The length of the content to be read. |
Definition at line 47 of file framed_transport.cpp.
|
staticprotected |
Definition at line 38 of file framed_transport.cpp.
|
staticprotected |
Definition at line 17 of file framed_transport.cpp.
References jsonrpc::utils::Trim().
|
staticprotected |
Receives a framed message.
Reads headers to determine the content length, then reads the message content based on that length.
input | The input stream to read the framed message. |
Definition at line 57 of file framed_transport.cpp.
|
friend |
Definition at line 70 of file framed_transport.hpp.
|
staticconstexprprotected |
The delimiter used to separate headers from the message content.
Definition at line 24 of file framed_transport.hpp.