summaryrefslogtreecommitdiffstats
path: root/server/src/http_server.cppm
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/http_server.cppm')
-rw-r--r--server/src/http_server.cppm13
1 files changed, 6 insertions, 7 deletions
diff --git a/server/src/http_server.cppm b/server/src/http_server.cppm
index 2bf3c63..e70110e 100644
--- a/server/src/http_server.cppm
+++ b/server/src/http_server.cppm
@@ -266,7 +266,7 @@ auto make_preflight_rsp(preflight_response res, keep_alive ka)
266// anyway, but all context types should derive from base_ctx). 266// anyway, but all context types should derive from base_ctx).
267template <bhttp::concepts::body_reader Body> 267template <bhttp::concepts::body_reader Body>
268auto read_request(base_ctx const& ctx, readable_request&& r) 268auto read_request(base_ctx const& ctx, readable_request&& r)
269 -> net::awaitable<std::expected<bhttp::request<Body>, presponse>> 269 -> net::awaitable<bhttp::request<Body>>
270{ 270{
271 std::ignore = ctx; 271 std::ignore = ctx;
272 auto p = bhttp::request_parser<Body>{std::move(*r.p)}; 272 auto p = bhttp::request_parser<Body>{std::move(*r.p)};
@@ -274,10 +274,8 @@ auto read_request(base_ctx const& ctx, readable_request&& r)
274 co_return std::move(p.release()); 274 co_return std::move(p.release());
275} 275}
276 276
277template <> 277auto read_empty_request(base_ctx const& ctx, readable_request&& r) -> net::
278auto read_request<bhttp::empty_body>(base_ctx const& ctx, readable_request&& r) 278 awaitable<std::expected<bhttp::request<bhttp::empty_body>, presponse>>
279 -> net::
280 awaitable<std::expected<bhttp::request<bhttp::empty_body>, presponse>>
281{ 279{
282 auto [ec, _] = 280 auto [ec, _] =
283 co_await bhttp::async_read(*r.strm, *r.buf, *r.p, net::as_tuple); 281 co_await bhttp::async_read(*r.strm, *r.buf, *r.p, net::as_tuple);
@@ -313,7 +311,7 @@ auto default_options_handler(
313 Ctx const& ctx, readable_request r, std::vector<std::string> const&) 311 Ctx const& ctx, readable_request r, std::vector<std::string> const&)
314 -> net::awaitable<presponse> 312 -> net::awaitable<presponse>
315{ 313{
316 auto mreq = co_await read_request<bhttp::empty_body>(ctx, std::move(r)); 314 auto mreq = co_await read_empty_request(ctx, std::move(r));
317 if (!mreq) 315 if (!mreq)
318 co_return std::move(mreq.error()); 316 co_return std::move(mreq.error());
319 317
@@ -324,7 +322,8 @@ auto default_options_handler(
324 preflight_response{ 322 preflight_response{
325 // TODO: should access-control-allow-methods contain OPTIONS? 323 // TODO: should access-control-allow-methods contain OPTIONS?
326 .allow_methods = ctx.route_methods, 324 .allow_methods = ctx.route_methods,
327 .allow_headers = {bhttp::field::content_type}, 325 .allow_headers =
326 {bhttp::field::content_type, bhttp::field::content_encoding},
328 }, 327 },
329 keep_alive{mreq->keep_alive()}); 328 keep_alive{mreq->keep_alive()});
330 } 329 }