8#include <aws/core/Core_EXPORTS.h>
9#include <aws/core/http/HttpTypes.h>
10#include <aws/core/utils/event/EventHeader.h>
11#include <aws/core/utils/event/EventMessage.h>
12#include <aws/core/utils/event/EventStreamErrors.h>
13#include <aws/core/utils/memory/stl/AWSString.h>
14#include <aws/core/utils/memory/stl/AWSStreamFwd.h>
15#include <aws/core/utils/memory/stl/AWSStringStream.h>
46 inline operator bool()
const {
return !m_failure; }
59 m_internalError = EventStreamErrors::EVENT_STREAM_NO_ERROR;
60 m_headersBytesReceived = 0;
61 m_payloadBytesReceived = 0;
79 return m_internalError;
90 return m_message.GetHeadersLength() == m_headersBytesReceived && m_message.GetPayloadLength() == m_payloadBytesReceived;
96 inline virtual void SetMessageMetadata(
size_t totalLength,
size_t headersLength,
size_t payloadLength)
98 m_message.SetTotalLength(totalLength);
99 m_message.SetHeadersLength(headersLength);
100 m_message.SetPayloadLength(payloadLength);
101 assert(totalLength == 12 + headersLength + payloadLength + 4);
102 if (totalLength != headersLength + payloadLength + 16)
104 AWS_LOG_WARN(
"EventStreamHandler",
"Message total length mismatch.");
113 m_message.WriteEventPayload(data, dataLength);
114 m_payloadBytesReceived += dataLength;
132 m_message.InsertEventHeader(eventHeaderName, eventHeaderValue);
133 m_headersBytesReceived += eventHeaderLength;
141 using SrcT = Aws::Utils::Event::EventHeaderValueCollection::value_type;
142 using DstT = Http::HeaderValueCollection::value_type;
143 std::transform(m_message.GetEventHeaders().cbegin(), m_message.GetEventHeaders().cend(),
144 std::inserter(output, output.end()),
147 return DstT(src.first, src.second.ToString());
161 size_t m_headersBytesReceived;
162 size_t m_payloadBytesReceived;
virtual void SetMessageMetadata(size_t totalLength, size_t headersLength, size_t payloadLength)
virtual bool IsMessageCompleted()
void SetInternalError(int errorCode=0)
virtual const Http::HeaderValueCollection GetEventHeadersAsHttpHeaders() const
virtual Aws::Vector< unsigned char > && GetEventPayloadWithOwnership()
virtual ~EventStreamHandler()=default
virtual void InsertMessageEventHeader(const String &eventHeaderName, size_t eventHeaderLength, const Aws::Utils::Event::EventHeaderValue &eventHeaderValue)
virtual Aws::String GetEventPayloadAsString()
EventStreamErrors GetInternalError()
virtual void WriteMessageEventPayload(const unsigned char *data, size_t dataLength)
virtual const Aws::Utils::Event::EventHeaderValueCollection & GetEventHeaders()
Aws::Map< Aws::String, Aws::String > HeaderValueCollection
Aws::Map< Aws::String, EventHeaderValue > EventHeaderValueCollection
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
std::vector< T, Aws::Allocator< T > > Vector