commit ba3876885b731531ccfb33f786e2e9957bb197d3 from: Aleksey Ryndin date: Mon Aug 14 10:32:29 2023 UTC Refactoring commit - bb3e281739184a20a50338238803256d986d6dfe commit + ba3876885b731531ccfb33f786e2e9957bb197d3 blob - e6d666b97f804f3ff012ebb92e6591199fca6a96 blob + 4cf61e35947eddbbc156541b9b6168a7f7027c61 --- shared/transport.cc +++ shared/transport.cc @@ -15,7 +15,7 @@ using config_t = std::unique_ptr read(not_null ctx, span buff) +bool read(not_null ctx, span &buff) { ssize_t ret{}; for (; ; ) @@ -36,9 +36,10 @@ span read(not_null ctx, span error::g_log << "Error: " << last_error << std::endl; } ); - return span{}; + return false; } - return buff.first(ret); + buff = buff.first(ret); + return true; } @@ -145,9 +146,9 @@ void accept( span read_request(not_null ctx, std::array &buffer) { - const auto request = read(ctx, buffer); - if (!request.size()) - return span{}; + span request{buffer}; + if (!read(ctx, request)) + return {}; for (auto current = request.begin(); current < request.end(); ++current) { @@ -162,7 +163,7 @@ span read_request(not_null ctx, st } } error::occurred("Parse request", error::none{}); - return span{}; + return {}; } blob - 4cbc7c5fbc7b64cfe00d9d3b4456b945ddb8ee8e blob + 0ad5894657e7261427d7baf9bded82d9f3501c19 --- vostokd/vostokd.cc +++ vostokd/vostokd.cc @@ -85,7 +85,7 @@ void client_thread(transport::accepted_context::value // > If is an empty string, the MIME type MUST default to "text/gemini; charset=utf-8". - transport::send_response(ctx.get_ctx(), transport::STATUS_20_SUCCESS, span{}); + transport::send_response(ctx.get_ctx(), transport::STATUS_20_SUCCESS, {}); static const char content[] = "# Vostok server\r\n\r\n...work-in-progress..."; transport::send(ctx.get_ctx(), cut_null(content)); }