Ed Tanous | 40e9b92 | 2024-09-10 13:50:16 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // SPDX-FileCopyrightText: Copyright OpenBMC Authors |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 3 | #pragma once |
Ed Tanous | 41fe81c | 2024-09-02 15:08:41 -0700 | [diff] [blame] | 4 | #include "boost_formatters.hpp" |
Ed Tanous | b289614 | 2024-01-31 15:25:47 -0800 | [diff] [blame] | 5 | #include "http_body.hpp" |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 6 | #include "http_request.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame^] | 7 | #include "logging.hpp" |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 8 | |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 9 | #include <boost/asio/buffer.hpp> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame^] | 10 | #include <boost/asio/error.hpp> |
| 11 | #include <boost/asio/io_context.hpp> |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 12 | #include <boost/asio/steady_timer.hpp> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame^] | 13 | #include <boost/beast/core/error.hpp> |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 14 | #include <boost/beast/core/multi_buffer.hpp> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame^] | 15 | #include <boost/beast/http/field.hpp> |
| 16 | #include <boost/beast/http/serializer.hpp> |
| 17 | #include <boost/beast/http/write.hpp> |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 18 | |
| 19 | #include <array> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame^] | 20 | #include <chrono> |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 21 | #include <cstddef> |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 22 | #include <functional> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame^] | 23 | #include <memory> |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 24 | #include <optional> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame^] | 25 | #include <string> |
| 26 | #include <string_view> |
| 27 | #include <utility> |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 28 | |
| 29 | namespace crow |
| 30 | { |
| 31 | |
| 32 | namespace sse_socket |
| 33 | { |
Ed Tanous | 93cf0ac | 2024-03-28 00:35:13 -0700 | [diff] [blame] | 34 | struct Connection : public std::enable_shared_from_this<Connection> |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 35 | { |
| 36 | public: |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 37 | Connection() = default; |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 38 | |
| 39 | Connection(const Connection&) = delete; |
| 40 | Connection(Connection&&) = delete; |
| 41 | Connection& operator=(const Connection&) = delete; |
| 42 | Connection& operator=(const Connection&&) = delete; |
| 43 | virtual ~Connection() = default; |
| 44 | |
| 45 | virtual boost::asio::io_context& getIoContext() = 0; |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 46 | virtual void close(std::string_view msg = "quit") = 0; |
Ed Tanous | 6d799e1 | 2024-09-11 14:33:37 -0700 | [diff] [blame] | 47 | virtual void sendSseEvent(std::string_view id, std::string_view msg) = 0; |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | template <typename Adaptor> |
| 51 | class ConnectionImpl : public Connection |
| 52 | { |
| 53 | public: |
Ed Tanous | f80a87f | 2024-06-16 12:10:33 -0700 | [diff] [blame] | 54 | ConnectionImpl( |
| 55 | Adaptor&& adaptorIn, |
| 56 | std::function<void(Connection&, const Request&)> openHandlerIn, |
| 57 | std::function<void(Connection&)> closeHandlerIn) : |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 58 | adaptor(std::move(adaptorIn)), |
Ed Tanous | 93cf0ac | 2024-03-28 00:35:13 -0700 | [diff] [blame] | 59 | timer(static_cast<boost::asio::io_context&>( |
| 60 | adaptor.get_executor().context())), |
| 61 | openHandler(std::move(openHandlerIn)), |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 62 | closeHandler(std::move(closeHandlerIn)) |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 63 | |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 64 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 65 | BMCWEB_LOG_DEBUG("SseConnectionImpl: SSE constructor {}", logPtr(this)); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | ConnectionImpl(const ConnectionImpl&) = delete; |
| 69 | ConnectionImpl(const ConnectionImpl&&) = delete; |
| 70 | ConnectionImpl& operator=(const ConnectionImpl&) = delete; |
| 71 | ConnectionImpl& operator=(const ConnectionImpl&&) = delete; |
| 72 | |
| 73 | ~ConnectionImpl() override |
| 74 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 75 | BMCWEB_LOG_DEBUG("SSE ConnectionImpl: SSE destructor {}", logPtr(this)); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | boost::asio::io_context& getIoContext() override |
| 79 | { |
| 80 | return static_cast<boost::asio::io_context&>( |
| 81 | adaptor.get_executor().context()); |
| 82 | } |
| 83 | |
Ed Tanous | f80a87f | 2024-06-16 12:10:33 -0700 | [diff] [blame] | 84 | void start(const Request& req) |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 85 | { |
Ed Tanous | 464924c | 2024-12-20 14:49:45 -0800 | [diff] [blame] | 86 | BMCWEB_LOG_DEBUG("Starting SSE connection"); |
| 87 | |
| 88 | res.set(boost::beast::http::field::content_type, "text/event-stream"); |
| 89 | boost::beast::http::response_serializer<BodyType>& serial = |
| 90 | serializer.emplace(res); |
| 91 | |
| 92 | boost::beast::http::async_write_header( |
| 93 | adaptor, serial, |
| 94 | std::bind_front(&ConnectionImpl::sendSSEHeaderCallback, this, |
| 95 | shared_from_this(), req)); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | void close(const std::string_view msg) override |
| 99 | { |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 100 | BMCWEB_LOG_DEBUG("Closing connection with reason {}", msg); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 101 | // send notification to handler for cleanup |
| 102 | if (closeHandler) |
| 103 | { |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 104 | closeHandler(*this); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 105 | } |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 106 | BMCWEB_LOG_DEBUG("Closing SSE connection {} - {}", logPtr(this), msg); |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 107 | boost::beast::get_lowest_layer(adaptor).close(); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 108 | } |
| 109 | |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 110 | void sendSSEHeaderCallback(const std::shared_ptr<Connection>& /*self*/, |
Ed Tanous | 464924c | 2024-12-20 14:49:45 -0800 | [diff] [blame] | 111 | const Request& req, |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 112 | const boost::system::error_code& ec, |
| 113 | size_t /*bytesSent*/) |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 114 | { |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 115 | serializer.reset(); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 116 | if (ec) |
| 117 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 118 | BMCWEB_LOG_ERROR("Error sending header{}", ec); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 119 | close("async_write_header failed"); |
| 120 | return; |
| 121 | } |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 122 | BMCWEB_LOG_DEBUG("SSE header sent - Connection established"); |
Ed Tanous | 464924c | 2024-12-20 14:49:45 -0800 | [diff] [blame] | 123 | if (!openHandler) |
| 124 | { |
| 125 | BMCWEB_LOG_CRITICAL("No open handler???"); |
| 126 | return; |
| 127 | } |
| 128 | openHandler(*this, req); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 129 | |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 130 | // SSE stream header sent, So let us setup monitor. |
| 131 | // Any read data on this stream will be error in case of SSE. |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 132 | adaptor.async_read_some(boost::asio::buffer(buffer), |
| 133 | std::bind_front(&ConnectionImpl::afterReadError, |
| 134 | this, shared_from_this())); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 135 | } |
| 136 | |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 137 | void afterReadError(const std::shared_ptr<Connection>& /*self*/, |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 138 | const boost::system::error_code& ec, size_t bytesRead) |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 139 | { |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 140 | BMCWEB_LOG_DEBUG("Read {}", bytesRead); |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 141 | if (ec == boost::asio::error::operation_aborted) |
| 142 | { |
| 143 | return; |
| 144 | } |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 145 | if (ec) |
| 146 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 147 | BMCWEB_LOG_ERROR("Read error: {}", ec); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 148 | } |
| 149 | |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 150 | close("Close SSE connection"); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | void doWrite() |
| 154 | { |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 155 | if (doingWrite) |
| 156 | { |
| 157 | return; |
| 158 | } |
| 159 | if (inputBuffer.size() == 0) |
| 160 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 161 | BMCWEB_LOG_DEBUG("inputBuffer is empty... Bailing out"); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 162 | return; |
| 163 | } |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 164 | startTimeout(); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 165 | doingWrite = true; |
| 166 | |
| 167 | adaptor.async_write_some( |
| 168 | inputBuffer.data(), |
| 169 | std::bind_front(&ConnectionImpl::doWriteCallback, this, |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 170 | shared_from_this())); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 171 | } |
| 172 | |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 173 | void doWriteCallback(const std::shared_ptr<Connection>& /*self*/, |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 174 | const boost::beast::error_code& ec, |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 175 | size_t bytesTransferred) |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 176 | { |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 177 | timer.cancel(); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 178 | doingWrite = false; |
| 179 | inputBuffer.consume(bytesTransferred); |
| 180 | |
| 181 | if (ec == boost::asio::error::eof) |
| 182 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 183 | BMCWEB_LOG_ERROR("async_write_some() SSE stream closed"); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 184 | close("SSE stream closed"); |
| 185 | return; |
| 186 | } |
| 187 | |
| 188 | if (ec) |
| 189 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 190 | BMCWEB_LOG_ERROR("async_write_some() failed: {}", ec.message()); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 191 | close("async_write_some failed"); |
| 192 | return; |
| 193 | } |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 194 | BMCWEB_LOG_DEBUG("async_write_some() bytes transferred: {}", |
| 195 | bytesTransferred); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 196 | |
| 197 | doWrite(); |
| 198 | } |
| 199 | |
Ed Tanous | 6d799e1 | 2024-09-11 14:33:37 -0700 | [diff] [blame] | 200 | void sendSseEvent(std::string_view id, std::string_view msg) override |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 201 | { |
| 202 | if (msg.empty()) |
| 203 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 204 | BMCWEB_LOG_DEBUG("Empty data, bailing out."); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 205 | return; |
| 206 | } |
| 207 | |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 208 | dataFormat(id, msg); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 209 | |
| 210 | doWrite(); |
| 211 | } |
| 212 | |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 213 | void dataFormat(std::string_view id, std::string_view msg) |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 214 | { |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 215 | constexpr size_t bufferLimit = 10485760U; // 10MB |
| 216 | if (id.size() + msg.size() + inputBuffer.size() >= bufferLimit) |
| 217 | { |
| 218 | BMCWEB_LOG_ERROR("SSE Buffer overflow while waiting for client"); |
| 219 | close("Buffer overflow"); |
| 220 | return; |
| 221 | } |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 222 | std::string rawData; |
| 223 | if (!id.empty()) |
| 224 | { |
| 225 | rawData += "id: "; |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 226 | rawData.append(id); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 227 | rawData += "\n"; |
| 228 | } |
| 229 | |
| 230 | rawData += "data: "; |
| 231 | for (char character : msg) |
| 232 | { |
| 233 | rawData += character; |
| 234 | if (character == '\n') |
| 235 | { |
| 236 | rawData += "data: "; |
| 237 | } |
| 238 | } |
| 239 | rawData += "\n\n"; |
| 240 | |
Ed Tanous | 44106f3 | 2024-04-06 13:48:50 -0700 | [diff] [blame] | 241 | size_t copied = boost::asio::buffer_copy( |
| 242 | inputBuffer.prepare(rawData.size()), boost::asio::buffer(rawData)); |
| 243 | inputBuffer.commit(copied); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 244 | } |
| 245 | |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 246 | void startTimeout() |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 247 | { |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 248 | std::weak_ptr<Connection> weakSelf = weak_from_this(); |
| 249 | timer.expires_after(std::chrono::seconds(30)); |
| 250 | timer.async_wait(std::bind_front(&ConnectionImpl::onTimeoutCallback, |
| 251 | this, weak_from_this())); |
| 252 | } |
| 253 | |
| 254 | void onTimeoutCallback(const std::weak_ptr<Connection>& weakSelf, |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 255 | const boost::system::error_code& ec) |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 256 | { |
| 257 | std::shared_ptr<Connection> self = weakSelf.lock(); |
| 258 | if (!self) |
| 259 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 260 | BMCWEB_LOG_CRITICAL("{} Failed to capture connection", |
| 261 | logPtr(self.get())); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 262 | return; |
| 263 | } |
| 264 | |
| 265 | if (ec == boost::asio::error::operation_aborted) |
| 266 | { |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 267 | BMCWEB_LOG_DEBUG("Timer operation aborted"); |
Ed Tanous | 8ece0e4 | 2024-01-02 13:16:50 -0800 | [diff] [blame] | 268 | // Canceled wait means the path succeeded. |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 269 | return; |
| 270 | } |
| 271 | if (ec) |
| 272 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 273 | BMCWEB_LOG_CRITICAL("{} timer failed {}", logPtr(self.get()), ec); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 274 | } |
| 275 | |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 276 | BMCWEB_LOG_WARNING("{} Connection timed out, closing", |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 277 | logPtr(self.get())); |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 278 | |
| 279 | self->close("closing connection"); |
| 280 | } |
| 281 | |
| 282 | private: |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 283 | std::array<char, 1> buffer{}; |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 284 | boost::beast::multi_buffer inputBuffer; |
| 285 | |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 286 | Adaptor adaptor; |
| 287 | |
Ed Tanous | b289614 | 2024-01-31 15:25:47 -0800 | [diff] [blame] | 288 | using BodyType = bmcweb::HttpBody; |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 289 | boost::beast::http::response<BodyType> res; |
| 290 | std::optional<boost::beast::http::response_serializer<BodyType>> serializer; |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 291 | boost::asio::steady_timer timer; |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 292 | bool doingWrite = false; |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 293 | |
Ed Tanous | f80a87f | 2024-06-16 12:10:33 -0700 | [diff] [blame] | 294 | std::function<void(Connection&, const Request&)> openHandler; |
Ed Tanous | 6fde95f | 2023-06-01 07:33:34 -0700 | [diff] [blame] | 295 | std::function<void(Connection&)> closeHandler; |
V-Sanjana | 88ada3b | 2023-04-13 15:18:31 +0530 | [diff] [blame] | 296 | }; |
| 297 | } // namespace sse_socket |
| 298 | } // namespace crow |