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 |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 3 | #pragma once |
| 4 | #include "bmcweb_config.h" |
| 5 | |
| 6 | #include "async_resp.hpp" |
| 7 | #include "authentication.hpp" |
| 8 | #include "complete_response_fields.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 9 | #include "forward_unauthorized.hpp" |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 10 | #include "http_body.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 11 | #include "http_request.hpp" |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 12 | #include "http_response.hpp" |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 13 | #include "logging.hpp" |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 14 | |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 15 | // NOLINTNEXTLINE(misc-include-cleaner) |
| 16 | #include "nghttp2_adapters.hpp" |
| 17 | |
| 18 | #include <nghttp2/nghttp2.h> |
| 19 | #include <unistd.h> |
| 20 | |
| 21 | #include <boost/asio/buffer.hpp> |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 22 | #include <boost/asio/ssl/stream.hpp> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 23 | #include <boost/beast/core/error.hpp> |
| 24 | #include <boost/beast/http/field.hpp> |
| 25 | #include <boost/beast/http/fields.hpp> |
| 26 | #include <boost/beast/http/message.hpp> |
| 27 | #include <boost/beast/http/verb.hpp> |
| 28 | #include <boost/optional/optional.hpp> |
Ed Tanous | d088218 | 2024-01-26 23:45:25 -0800 | [diff] [blame] | 29 | #include <boost/system/error_code.hpp> |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 30 | |
Ed Tanous | d088218 | 2024-01-26 23:45:25 -0800 | [diff] [blame] | 31 | #include <array> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 32 | #include <bit> |
| 33 | #include <cstddef> |
| 34 | #include <cstdint> |
Ed Tanous | d088218 | 2024-01-26 23:45:25 -0800 | [diff] [blame] | 35 | #include <functional> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 36 | #include <map> |
Ed Tanous | d088218 | 2024-01-26 23:45:25 -0800 | [diff] [blame] | 37 | #include <memory> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 38 | #include <optional> |
| 39 | #include <span> |
Ed Tanous | 89cda63 | 2024-04-16 08:45:54 -0700 | [diff] [blame] | 40 | #include <string> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 41 | #include <string_view> |
Ed Tanous | 796ba93 | 2020-08-02 04:29:21 +0000 | [diff] [blame] | 42 | #include <type_traits> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 43 | #include <utility> |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 44 | #include <vector> |
| 45 | |
| 46 | namespace crow |
| 47 | { |
| 48 | |
Ed Tanous | 796ba93 | 2020-08-02 04:29:21 +0000 | [diff] [blame] | 49 | template <typename> |
| 50 | struct IsTls : std::false_type |
| 51 | {}; |
| 52 | |
| 53 | template <typename T> |
| 54 | struct IsTls<boost::asio::ssl::stream<T>> : std::true_type |
| 55 | {}; |
| 56 | |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 57 | struct Http2StreamData |
| 58 | { |
Jonathan Doman | 102a4cd | 2024-04-15 16:56:23 -0700 | [diff] [blame] | 59 | std::shared_ptr<Request> req = std::make_shared<Request>(); |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 60 | std::optional<bmcweb::HttpBody::reader> reqReader; |
Ed Tanous | 89cda63 | 2024-04-16 08:45:54 -0700 | [diff] [blame] | 61 | std::string accept; |
Ed Tanous | 47f2934 | 2024-03-19 12:18:06 -0700 | [diff] [blame] | 62 | Response res; |
Ed Tanous | b289614 | 2024-01-31 15:25:47 -0800 | [diff] [blame] | 63 | std::optional<bmcweb::HttpBody::writer> writer; |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | template <typename Adaptor, typename Handler> |
| 67 | class HTTP2Connection : |
| 68 | public std::enable_shared_from_this<HTTP2Connection<Adaptor, Handler>> |
| 69 | { |
| 70 | using self_type = HTTP2Connection<Adaptor, Handler>; |
| 71 | |
| 72 | public: |
| 73 | HTTP2Connection(Adaptor&& adaptorIn, Handler* handlerIn, |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 74 | std::function<std::string()>& getCachedDateStrF) : |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 75 | adaptor(std::move(adaptorIn)), ngSession(initializeNghttp2Session()), |
| 76 | handler(handlerIn), getCachedDateStr(getCachedDateStrF) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 77 | {} |
| 78 | |
| 79 | void start() |
| 80 | { |
| 81 | // Create the control stream |
Ed Tanous | f42e859 | 2023-08-25 10:47:44 -0700 | [diff] [blame] | 82 | streams[0]; |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 83 | |
| 84 | if (sendServerConnectionHeader() != 0) |
| 85 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 86 | BMCWEB_LOG_ERROR("send_server_connection_header failed"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 87 | return; |
| 88 | } |
| 89 | doRead(); |
| 90 | } |
| 91 | |
Ed Tanous | cd7dbb3 | 2025-02-01 12:37:56 -0800 | [diff] [blame] | 92 | void startFromSettings(std::string_view http2UpgradeSettings) |
| 93 | { |
| 94 | int ret = ngSession.sessionUpgrade2(http2UpgradeSettings, |
| 95 | false /*head_request*/); |
| 96 | if (ret != 0) |
| 97 | { |
| 98 | BMCWEB_LOG_ERROR("Failed to load upgrade header"); |
| 99 | return; |
| 100 | } |
| 101 | // Create the control stream |
| 102 | streams[0]; |
| 103 | |
| 104 | if (sendServerConnectionHeader() != 0) |
| 105 | { |
| 106 | BMCWEB_LOG_ERROR("send_server_connection_header failed"); |
| 107 | return; |
| 108 | } |
| 109 | doRead(); |
| 110 | } |
| 111 | |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 112 | int sendServerConnectionHeader() |
| 113 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 114 | BMCWEB_LOG_DEBUG("send_server_connection_header()"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 115 | |
| 116 | uint32_t maxStreams = 4; |
| 117 | std::array<nghttp2_settings_entry, 2> iv = { |
| 118 | {{NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, maxStreams}, |
| 119 | {NGHTTP2_SETTINGS_ENABLE_PUSH, 0}}}; |
| 120 | int rv = ngSession.submitSettings(iv); |
| 121 | if (rv != 0) |
| 122 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 123 | BMCWEB_LOG_ERROR("Fatal error: {}", nghttp2_strerror(rv)); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 124 | return -1; |
| 125 | } |
Ed Tanous | d088218 | 2024-01-26 23:45:25 -0800 | [diff] [blame] | 126 | writeBuffer(); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 127 | return 0; |
| 128 | } |
| 129 | |
Patrick Williams | 504af5a | 2025-02-03 14:29:03 -0500 | [diff] [blame] | 130 | static ssize_t fileReadCallback( |
| 131 | nghttp2_session* /* session */, int32_t streamId, uint8_t* buf, |
| 132 | size_t length, uint32_t* dataFlags, nghttp2_data_source* /*source*/, |
| 133 | void* userPtr) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 134 | { |
Ed Tanous | f42e859 | 2023-08-25 10:47:44 -0700 | [diff] [blame] | 135 | self_type& self = userPtrToSelf(userPtr); |
| 136 | |
| 137 | auto streamIt = self.streams.find(streamId); |
| 138 | if (streamIt == self.streams.end()) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 139 | { |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 140 | return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; |
| 141 | } |
Ed Tanous | f42e859 | 2023-08-25 10:47:44 -0700 | [diff] [blame] | 142 | Http2StreamData& stream = streamIt->second; |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 143 | BMCWEB_LOG_DEBUG("File read callback length: {}", length); |
Ed Tanous | d547d8d | 2024-03-16 18:04:41 -0700 | [diff] [blame] | 144 | if (!stream.writer) |
| 145 | { |
| 146 | return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; |
| 147 | } |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 148 | boost::beast::error_code ec; |
| 149 | boost::optional<std::pair<boost::asio::const_buffer, bool>> out = |
| 150 | stream.writer->getWithMaxSize(ec, length); |
| 151 | if (ec) |
Ed Tanous | 27b0cf9 | 2023-08-07 12:02:40 -0700 | [diff] [blame] | 152 | { |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 153 | BMCWEB_LOG_CRITICAL("Failed to get buffer"); |
Ed Tanous | 27b0cf9 | 2023-08-07 12:02:40 -0700 | [diff] [blame] | 154 | return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; |
| 155 | } |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 156 | if (!out) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 157 | { |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 158 | BMCWEB_LOG_ERROR("Empty file, setting EOF"); |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 159 | *dataFlags |= NGHTTP2_DATA_FLAG_EOF; |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | BMCWEB_LOG_DEBUG("Send chunk of size: {}", out->first.size()); |
| 164 | if (length < out->first.size()) |
| 165 | { |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 166 | BMCWEB_LOG_CRITICAL( |
| 167 | "Buffer overflow that should never happen happened"); |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 168 | // Should never happen because of length limit on get() above |
| 169 | return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; |
| 170 | } |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 171 | boost::asio::mutable_buffer writeableBuf(buf, length); |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 172 | BMCWEB_LOG_DEBUG("Copying {} bytes to buf", out->first.size()); |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 173 | size_t copied = boost::asio::buffer_copy(writeableBuf, out->first); |
| 174 | if (copied != out->first.size()) |
| 175 | { |
| 176 | BMCWEB_LOG_ERROR( |
| 177 | "Couldn't copy all {} bytes into buffer, only copied {}", |
| 178 | out->first.size(), copied); |
| 179 | return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; |
| 180 | } |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 181 | |
| 182 | if (!out->second) |
| 183 | { |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 184 | BMCWEB_LOG_DEBUG("Setting EOF flag"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 185 | *dataFlags |= NGHTTP2_DATA_FLAG_EOF; |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 186 | } |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 187 | return static_cast<ssize_t>(copied); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | nghttp2_nv headerFromStringViews(std::string_view name, |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 191 | std::string_view value, uint8_t flags) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 192 | { |
| 193 | uint8_t* nameData = std::bit_cast<uint8_t*>(name.data()); |
| 194 | uint8_t* valueData = std::bit_cast<uint8_t*>(value.data()); |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 195 | return {nameData, valueData, name.size(), value.size(), flags}; |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | int sendResponse(Response& completedRes, int32_t streamId) |
| 199 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 200 | BMCWEB_LOG_DEBUG("send_response stream_id:{}", streamId); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 201 | |
| 202 | auto it = streams.find(streamId); |
| 203 | if (it == streams.end()) |
| 204 | { |
| 205 | close(); |
| 206 | return -1; |
| 207 | } |
Ed Tanous | 499b5b4 | 2024-04-06 08:39:18 -0700 | [diff] [blame] | 208 | Http2StreamData& stream = it->second; |
| 209 | Response& res = stream.res; |
| 210 | res = std::move(completedRes); |
Ed Tanous | 499b5b4 | 2024-04-06 08:39:18 -0700 | [diff] [blame] | 211 | |
Ed Tanous | 89cda63 | 2024-04-16 08:45:54 -0700 | [diff] [blame] | 212 | completeResponseFields(stream.accept, res); |
Ed Tanous | 499b5b4 | 2024-04-06 08:39:18 -0700 | [diff] [blame] | 213 | res.addHeader(boost::beast::http::field::date, getCachedDateStr()); |
| 214 | res.preparePayload(); |
| 215 | |
| 216 | boost::beast::http::fields& fields = res.fields(); |
| 217 | std::string code = std::to_string(res.resultInt()); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 218 | std::vector<nghttp2_nv> hdr; |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 219 | hdr.emplace_back( |
| 220 | headerFromStringViews(":status", code, NGHTTP2_NV_FLAG_NONE)); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 221 | for (const boost::beast::http::fields::value_type& header : fields) |
| 222 | { |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 223 | hdr.emplace_back(headerFromStringViews( |
Ed Tanous | d088218 | 2024-01-26 23:45:25 -0800 | [diff] [blame] | 224 | header.name_string(), header.value(), NGHTTP2_NV_FLAG_NONE)); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 225 | } |
Ed Tanous | b289614 | 2024-01-31 15:25:47 -0800 | [diff] [blame] | 226 | http::response<bmcweb::HttpBody>& fbody = res.response; |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 227 | stream.writer.emplace(fbody.base(), fbody.body()); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 228 | |
| 229 | nghttp2_data_provider dataPrd{ |
Ed Tanous | f42e859 | 2023-08-25 10:47:44 -0700 | [diff] [blame] | 230 | .source = {.fd = 0}, |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 231 | .read_callback = fileReadCallback, |
| 232 | }; |
| 233 | |
| 234 | int rv = ngSession.submitResponse(streamId, hdr, &dataPrd); |
| 235 | if (rv != 0) |
| 236 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 237 | BMCWEB_LOG_ERROR("Fatal error: {}", nghttp2_strerror(rv)); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 238 | close(); |
| 239 | return -1; |
| 240 | } |
Ed Tanous | d088218 | 2024-01-26 23:45:25 -0800 | [diff] [blame] | 241 | writeBuffer(); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 242 | |
| 243 | return 0; |
| 244 | } |
| 245 | |
| 246 | nghttp2_session initializeNghttp2Session() |
| 247 | { |
| 248 | nghttp2_session_callbacks callbacks; |
| 249 | callbacks.setOnFrameRecvCallback(onFrameRecvCallbackStatic); |
| 250 | callbacks.setOnStreamCloseCallback(onStreamCloseCallbackStatic); |
| 251 | callbacks.setOnHeaderCallback(onHeaderCallbackStatic); |
| 252 | callbacks.setOnBeginHeadersCallback(onBeginHeadersCallbackStatic); |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 253 | callbacks.setOnDataChunkRecvCallback(onDataChunkRecvStatic); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 254 | |
| 255 | nghttp2_session session(callbacks); |
| 256 | session.setUserData(this); |
| 257 | |
| 258 | return session; |
| 259 | } |
| 260 | |
| 261 | int onRequestRecv(int32_t streamId) |
| 262 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 263 | BMCWEB_LOG_DEBUG("on_request_recv"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 264 | |
| 265 | auto it = streams.find(streamId); |
| 266 | if (it == streams.end()) |
| 267 | { |
| 268 | close(); |
| 269 | return -1; |
| 270 | } |
Ed Tanous | d547d8d | 2024-03-16 18:04:41 -0700 | [diff] [blame] | 271 | auto& reqReader = it->second.reqReader; |
| 272 | if (reqReader) |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 273 | { |
| 274 | boost::beast::error_code ec; |
Ed Tanous | daadfb2 | 2024-12-20 09:25:54 -0800 | [diff] [blame] | 275 | bmcweb::HttpBody::reader::finish(ec); |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 276 | if (ec) |
| 277 | { |
| 278 | BMCWEB_LOG_CRITICAL("Failed to finalize payload"); |
| 279 | close(); |
| 280 | return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; |
| 281 | } |
| 282 | } |
Jonathan Doman | 102a4cd | 2024-04-15 16:56:23 -0700 | [diff] [blame] | 283 | crow::Request& thisReq = *it->second.req; |
Ed Tanous | 8e8245d | 2024-04-11 22:21:38 -0700 | [diff] [blame] | 284 | thisReq.ioService = static_cast<decltype(thisReq.ioService)>( |
| 285 | &adaptor.get_executor().context()); |
Ed Tanous | 89cda63 | 2024-04-16 08:45:54 -0700 | [diff] [blame] | 286 | |
| 287 | it->second.accept = thisReq.getHeaderValue("Accept"); |
| 288 | |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 289 | BMCWEB_LOG_DEBUG("Handling {} \"{}\"", logPtr(&thisReq), |
| 290 | thisReq.url().encoded_path()); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 291 | |
Ed Tanous | f42e859 | 2023-08-25 10:47:44 -0700 | [diff] [blame] | 292 | crow::Response& thisRes = it->second.res; |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 293 | |
| 294 | thisRes.setCompleteRequestHandler( |
| 295 | [this, streamId](Response& completeRes) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 296 | BMCWEB_LOG_DEBUG("res.completeRequestHandler called"); |
| 297 | if (sendResponse(completeRes, streamId) != 0) |
| 298 | { |
| 299 | close(); |
| 300 | return; |
| 301 | } |
| 302 | }); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 303 | auto asyncResp = |
Ed Tanous | f42e859 | 2023-08-25 10:47:44 -0700 | [diff] [blame] | 304 | std::make_shared<bmcweb::AsyncResp>(std::move(it->second.res)); |
Ed Tanous | 8332831 | 2024-05-09 15:48:09 -0700 | [diff] [blame] | 305 | if constexpr (!BMCWEB_INSECURE_DISABLE_AUTH) |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 306 | { |
Ed Tanous | 8332831 | 2024-05-09 15:48:09 -0700 | [diff] [blame] | 307 | thisReq.session = crow::authentication::authenticate( |
| 308 | {}, asyncResp->res, thisReq.method(), thisReq.req, nullptr); |
| 309 | if (!crow::authentication::isOnAllowlist(thisReq.url().path(), |
| 310 | thisReq.method()) && |
| 311 | thisReq.session == nullptr) |
Ed Tanous | 499b5b4 | 2024-04-06 08:39:18 -0700 | [diff] [blame] | 312 | { |
Ed Tanous | 8332831 | 2024-05-09 15:48:09 -0700 | [diff] [blame] | 313 | BMCWEB_LOG_WARNING("Authentication failed"); |
| 314 | forward_unauthorized::sendUnauthorized( |
| 315 | thisReq.url().encoded_path(), |
| 316 | thisReq.getHeaderValue("X-Requested-With"), |
| 317 | thisReq.getHeaderValue("Accept"), asyncResp->res); |
| 318 | return 0; |
Ed Tanous | 499b5b4 | 2024-04-06 08:39:18 -0700 | [diff] [blame] | 319 | } |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 320 | } |
Ed Tanous | 8332831 | 2024-05-09 15:48:09 -0700 | [diff] [blame] | 321 | std::string_view expected = |
| 322 | thisReq.getHeaderValue(boost::beast::http::field::if_none_match); |
| 323 | BMCWEB_LOG_DEBUG("Setting expected hash {}", expected); |
| 324 | if (!expected.empty()) |
| 325 | { |
| 326 | asyncResp->res.setExpectedHash(expected); |
| 327 | } |
| 328 | handler->handle(it->second.req, asyncResp); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 329 | return 0; |
| 330 | } |
| 331 | |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 332 | int onDataChunkRecvCallback(uint8_t /*flags*/, int32_t streamId, |
| 333 | const uint8_t* data, size_t len) |
| 334 | { |
| 335 | auto thisStream = streams.find(streamId); |
| 336 | if (thisStream == streams.end()) |
| 337 | { |
| 338 | BMCWEB_LOG_ERROR("Unknown stream{}", streamId); |
| 339 | close(); |
| 340 | return -1; |
| 341 | } |
Ed Tanous | d547d8d | 2024-03-16 18:04:41 -0700 | [diff] [blame] | 342 | |
| 343 | std::optional<bmcweb::HttpBody::reader>& reqReader = |
| 344 | thisStream->second.reqReader; |
| 345 | if (!reqReader) |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 346 | { |
Ed Tanous | 8e5cc7b | 2024-04-02 11:00:54 -0700 | [diff] [blame] | 347 | reqReader.emplace( |
Jonathan Doman | 102a4cd | 2024-04-15 16:56:23 -0700 | [diff] [blame] | 348 | bmcweb::HttpBody::reader(thisStream->second.req->req.base(), |
| 349 | thisStream->second.req->req.body())); |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 350 | } |
| 351 | boost::beast::error_code ec; |
Ed Tanous | d547d8d | 2024-03-16 18:04:41 -0700 | [diff] [blame] | 352 | reqReader->put(boost::asio::const_buffer(data, len), ec); |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 353 | if (ec) |
| 354 | { |
| 355 | BMCWEB_LOG_CRITICAL("Failed to write payload"); |
| 356 | return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; |
| 357 | } |
| 358 | return 0; |
| 359 | } |
| 360 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 361 | static int onDataChunkRecvStatic( |
| 362 | nghttp2_session* /* session */, uint8_t flags, int32_t streamId, |
| 363 | const uint8_t* data, size_t len, void* userData) |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 364 | { |
| 365 | BMCWEB_LOG_DEBUG("on_frame_recv_callback"); |
| 366 | if (userData == nullptr) |
| 367 | { |
| 368 | BMCWEB_LOG_CRITICAL("user data was null?"); |
| 369 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 370 | } |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 371 | return userPtrToSelf(userData).onDataChunkRecvCallback( |
| 372 | flags, streamId, data, len); |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 373 | } |
| 374 | |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 375 | int onFrameRecvCallback(const nghttp2_frame& frame) |
| 376 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 377 | BMCWEB_LOG_DEBUG("frame type {}", static_cast<int>(frame.hd.type)); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 378 | switch (frame.hd.type) |
| 379 | { |
| 380 | case NGHTTP2_DATA: |
| 381 | case NGHTTP2_HEADERS: |
| 382 | // Check that the client request has finished |
| 383 | if ((frame.hd.flags & NGHTTP2_FLAG_END_STREAM) != 0) |
| 384 | { |
| 385 | return onRequestRecv(frame.hd.stream_id); |
| 386 | } |
| 387 | break; |
| 388 | default: |
| 389 | break; |
| 390 | } |
| 391 | return 0; |
| 392 | } |
| 393 | |
| 394 | static int onFrameRecvCallbackStatic(nghttp2_session* /* session */, |
| 395 | const nghttp2_frame* frame, |
| 396 | void* userData) |
| 397 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 398 | BMCWEB_LOG_DEBUG("on_frame_recv_callback"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 399 | if (userData == nullptr) |
| 400 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 401 | BMCWEB_LOG_CRITICAL("user data was null?"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 402 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 403 | } |
| 404 | if (frame == nullptr) |
| 405 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 406 | BMCWEB_LOG_CRITICAL("frame was null?"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 407 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 408 | } |
| 409 | return userPtrToSelf(userData).onFrameRecvCallback(*frame); |
| 410 | } |
| 411 | |
| 412 | static self_type& userPtrToSelf(void* userData) |
| 413 | { |
| 414 | // This method exists to keep the unsafe reinterpret cast in one |
| 415 | // place. |
| 416 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) |
| 417 | return *reinterpret_cast<self_type*>(userData); |
| 418 | } |
| 419 | |
| 420 | static int onStreamCloseCallbackStatic(nghttp2_session* /* session */, |
| 421 | int32_t streamId, |
| 422 | uint32_t /*unused*/, void* userData) |
| 423 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 424 | BMCWEB_LOG_DEBUG("on_stream_close_callback stream {}", streamId); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 425 | if (userData == nullptr) |
| 426 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 427 | BMCWEB_LOG_CRITICAL("user data was null?"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 428 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 429 | } |
Ed Tanous | f42e859 | 2023-08-25 10:47:44 -0700 | [diff] [blame] | 430 | if (userPtrToSelf(userData).streams.erase(streamId) <= 0) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 431 | { |
| 432 | return -1; |
| 433 | } |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 434 | return 0; |
| 435 | } |
| 436 | |
| 437 | int onHeaderCallback(const nghttp2_frame& frame, |
| 438 | std::span<const uint8_t> name, |
| 439 | std::span<const uint8_t> value) |
| 440 | { |
| 441 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) |
| 442 | std::string_view nameSv(reinterpret_cast<const char*>(name.data()), |
| 443 | name.size()); |
| 444 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) |
| 445 | std::string_view valueSv(reinterpret_cast<const char*>(value.data()), |
| 446 | value.size()); |
| 447 | |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 448 | BMCWEB_LOG_DEBUG("on_header_callback name: {} value {}", nameSv, |
| 449 | valueSv); |
Ed Tanous | a07e981 | 2024-03-19 10:31:13 -0700 | [diff] [blame] | 450 | if (frame.hd.type != NGHTTP2_HEADERS) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 451 | { |
Ed Tanous | a07e981 | 2024-03-19 10:31:13 -0700 | [diff] [blame] | 452 | return 0; |
| 453 | } |
| 454 | if (frame.headers.cat != NGHTTP2_HCAT_REQUEST) |
| 455 | { |
| 456 | return 0; |
| 457 | } |
| 458 | auto thisStream = streams.find(frame.hd.stream_id); |
| 459 | if (thisStream == streams.end()) |
| 460 | { |
| 461 | BMCWEB_LOG_ERROR("Unknown stream{}", frame.hd.stream_id); |
| 462 | close(); |
| 463 | return -1; |
| 464 | } |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 465 | |
Jonathan Doman | 102a4cd | 2024-04-15 16:56:23 -0700 | [diff] [blame] | 466 | crow::Request& thisReq = *thisStream->second.req; |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 467 | |
Ed Tanous | a07e981 | 2024-03-19 10:31:13 -0700 | [diff] [blame] | 468 | if (nameSv == ":path") |
| 469 | { |
| 470 | thisReq.target(valueSv); |
| 471 | } |
| 472 | else if (nameSv == ":method") |
| 473 | { |
| 474 | boost::beast::http::verb verb = |
| 475 | boost::beast::http::string_to_verb(valueSv); |
| 476 | if (verb == boost::beast::http::verb::unknown) |
| 477 | { |
| 478 | BMCWEB_LOG_ERROR("Unknown http verb {}", valueSv); |
Ed Tanous | 50bfc91 | 2024-07-29 14:20:50 -0700 | [diff] [blame] | 479 | verb = boost::beast::http::verb::trace; |
Ed Tanous | a07e981 | 2024-03-19 10:31:13 -0700 | [diff] [blame] | 480 | } |
Myung Bae | 1873a04 | 2024-04-01 09:27:39 -0500 | [diff] [blame] | 481 | thisReq.method(verb); |
Ed Tanous | a07e981 | 2024-03-19 10:31:13 -0700 | [diff] [blame] | 482 | } |
| 483 | else if (nameSv == ":scheme") |
| 484 | { |
| 485 | // Nothing to check on scheme |
| 486 | } |
| 487 | else |
| 488 | { |
Myung Bae | 1873a04 | 2024-04-01 09:27:39 -0500 | [diff] [blame] | 489 | thisReq.addHeader(nameSv, valueSv); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 490 | } |
| 491 | return 0; |
| 492 | } |
| 493 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 494 | static int onHeaderCallbackStatic( |
| 495 | nghttp2_session* /* session */, const nghttp2_frame* frame, |
| 496 | const uint8_t* name, size_t namelen, const uint8_t* value, |
| 497 | size_t vallen, uint8_t /* flags */, void* userData) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 498 | { |
| 499 | if (userData == nullptr) |
| 500 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 501 | BMCWEB_LOG_CRITICAL("user data was null?"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 502 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 503 | } |
| 504 | if (frame == nullptr) |
| 505 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 506 | BMCWEB_LOG_CRITICAL("frame was null?"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 507 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 508 | } |
| 509 | if (name == nullptr) |
| 510 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 511 | BMCWEB_LOG_CRITICAL("name was null?"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 512 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 513 | } |
| 514 | if (value == nullptr) |
| 515 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 516 | BMCWEB_LOG_CRITICAL("value was null?"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 517 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 518 | } |
| 519 | return userPtrToSelf(userData).onHeaderCallback(*frame, {name, namelen}, |
| 520 | {value, vallen}); |
| 521 | } |
| 522 | |
| 523 | int onBeginHeadersCallback(const nghttp2_frame& frame) |
| 524 | { |
| 525 | if (frame.hd.type == NGHTTP2_HEADERS && |
| 526 | frame.headers.cat == NGHTTP2_HCAT_REQUEST) |
| 527 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 528 | BMCWEB_LOG_DEBUG("create stream for id {}", frame.hd.stream_id); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 529 | |
Ed Tanous | 3a49941 | 2024-06-05 16:05:35 -0700 | [diff] [blame] | 530 | streams.emplace(frame.hd.stream_id, Http2StreamData()); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 531 | } |
| 532 | return 0; |
| 533 | } |
| 534 | |
| 535 | static int onBeginHeadersCallbackStatic(nghttp2_session* /* session */, |
| 536 | const nghttp2_frame* frame, |
| 537 | void* userData) |
| 538 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 539 | BMCWEB_LOG_DEBUG("on_begin_headers_callback"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 540 | if (userData == nullptr) |
| 541 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 542 | BMCWEB_LOG_CRITICAL("user data was null?"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 543 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 544 | } |
| 545 | if (frame == nullptr) |
| 546 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 547 | BMCWEB_LOG_CRITICAL("frame was null?"); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 548 | return NGHTTP2_ERR_CALLBACK_FAILURE; |
| 549 | } |
| 550 | return userPtrToSelf(userData).onBeginHeadersCallback(*frame); |
| 551 | } |
| 552 | |
| 553 | static void afterWriteBuffer(const std::shared_ptr<self_type>& self, |
| 554 | const boost::system::error_code& ec, |
| 555 | size_t sendLength) |
| 556 | { |
| 557 | self->isWriting = false; |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 558 | BMCWEB_LOG_DEBUG("Sent {}", sendLength); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 559 | if (ec) |
| 560 | { |
| 561 | self->close(); |
| 562 | return; |
| 563 | } |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 564 | self->writeBuffer(); |
| 565 | } |
| 566 | |
| 567 | void writeBuffer() |
| 568 | { |
| 569 | if (isWriting) |
| 570 | { |
| 571 | return; |
| 572 | } |
Ed Tanous | d088218 | 2024-01-26 23:45:25 -0800 | [diff] [blame] | 573 | std::span<const uint8_t> data = ngSession.memSend(); |
| 574 | if (data.empty()) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 575 | { |
| 576 | return; |
| 577 | } |
| 578 | isWriting = true; |
Ed Tanous | 325310d | 2024-03-15 09:05:04 -0700 | [diff] [blame] | 579 | boost::asio::async_write( |
| 580 | adaptor, boost::asio::const_buffer(data.data(), data.size()), |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 581 | std::bind_front(afterWriteBuffer, shared_from_this())); |
| 582 | } |
| 583 | |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 584 | void close() |
| 585 | { |
Ed Tanous | 796ba93 | 2020-08-02 04:29:21 +0000 | [diff] [blame] | 586 | if constexpr (IsTls<Adaptor>::value) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 587 | { |
| 588 | adaptor.next_layer().close(); |
| 589 | } |
| 590 | else |
| 591 | { |
| 592 | adaptor.close(); |
| 593 | } |
| 594 | } |
| 595 | |
Ed Tanous | d088218 | 2024-01-26 23:45:25 -0800 | [diff] [blame] | 596 | void afterDoRead(const std::shared_ptr<self_type>& /*self*/, |
| 597 | const boost::system::error_code& ec, |
| 598 | size_t bytesTransferred) |
| 599 | { |
| 600 | BMCWEB_LOG_DEBUG("{} async_read_some {} Bytes", logPtr(this), |
| 601 | bytesTransferred); |
| 602 | |
| 603 | if (ec) |
| 604 | { |
| 605 | BMCWEB_LOG_ERROR("{} Error while reading: {}", logPtr(this), |
| 606 | ec.message()); |
| 607 | close(); |
| 608 | BMCWEB_LOG_DEBUG("{} from read(1)", logPtr(this)); |
| 609 | return; |
| 610 | } |
| 611 | std::span<uint8_t> bufferSpan{inBuffer.data(), bytesTransferred}; |
| 612 | |
| 613 | ssize_t readLen = ngSession.memRecv(bufferSpan); |
| 614 | if (readLen < 0) |
| 615 | { |
| 616 | BMCWEB_LOG_ERROR("nghttp2_session_mem_recv returned {}", readLen); |
| 617 | close(); |
| 618 | return; |
| 619 | } |
| 620 | writeBuffer(); |
| 621 | |
| 622 | doRead(); |
| 623 | } |
| 624 | |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 625 | void doRead() |
| 626 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 627 | BMCWEB_LOG_DEBUG("{} doRead", logPtr(this)); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 628 | adaptor.async_read_some( |
Ed Tanous | d088218 | 2024-01-26 23:45:25 -0800 | [diff] [blame] | 629 | boost::asio::buffer(inBuffer), |
| 630 | std::bind_front(&self_type::afterDoRead, this, shared_from_this())); |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | // A mapping from http2 stream ID to Stream Data |
Ed Tanous | 52e3162 | 2024-01-23 16:31:11 -0800 | [diff] [blame] | 634 | std::map<int32_t, Http2StreamData> streams; |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 635 | |
Ed Tanous | d088218 | 2024-01-26 23:45:25 -0800 | [diff] [blame] | 636 | std::array<uint8_t, 8192> inBuffer{}; |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 637 | |
| 638 | Adaptor adaptor; |
| 639 | bool isWriting = false; |
| 640 | |
| 641 | nghttp2_session ngSession; |
| 642 | |
| 643 | Handler* handler; |
| 644 | std::function<std::string()>& getCachedDateStr; |
| 645 | |
| 646 | using std::enable_shared_from_this< |
| 647 | HTTP2Connection<Adaptor, Handler>>::shared_from_this; |
| 648 | |
| 649 | using std::enable_shared_from_this< |
| 650 | HTTP2Connection<Adaptor, Handler>>::weak_from_this; |
| 651 | }; |
| 652 | } // namespace crow |