From 390af63a73b7d91c3c0b37089e88027b4f46a39f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 15 May 2023 22:38:18 +0300 Subject: Add support for interactive parameter for task request --- mod/mod-build-task.cxx | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'mod/mod-build-task.cxx') diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx index 4b0165f..19907ea 100644 --- a/mod/mod-build-task.cxx +++ b/mod/mod-build-task.cxx @@ -214,6 +214,40 @@ handle (request& rq, response& rs) task_response_manifest tsm; + auto serialize_task_response_manifest = [&tsm, &rs] () + { + // @@ Probably it would be a good idea to also send some cache control + // headers to avoid caching by HTTP proxies. That would require + // extension of the web::response interface. + // + + manifest_serializer s (rs.content (200, "text/manifest;charset=utf-8"), + "task_response_manifest"); + tsm.serialize (s); + }; + + interactive_mode imode (tqm.effective_interactive_mode ()); + + // Restict the interactive mode (specified by the task request manifest) if + // the interactive parameter is specified and is other than "both". If + // values specified by the parameter and manifest are incompatible (false vs + // true), then just bail out responding with the manifest with an empty + // session. + // + if (params.interactive () != interactive_mode::both) + { + if (imode != interactive_mode::both) + { + if (params.interactive () != imode) + { + serialize_task_response_manifest (); + return true; + } + } + else + imode = params.interactive (); // Can only change both to true or false. + } + // Map build target configurations to machines that are capable of building // them. The first matching machine is selected for each configuration. // @@ -604,7 +638,6 @@ handle (request& rq, response& rs) using pkg_query = query; using prep_pkg_query = prepared_query; - interactive_mode imode (tqm.effective_interactive_mode ()); pkg_query pq (package_query (params, imode)); // Transform (in-place) the interactive login information into the actual @@ -1495,14 +1528,6 @@ handle (request& rq, response& rs) } } - // @@ Probably it would be a good idea to also send some cache control - // headers to avoid caching by HTTP proxies. That would require extension - // of the web::response interface. - // - - manifest_serializer s (rs.content (200, "text/manifest;charset=utf-8"), - "task_response_manifest"); - tsm.serialize (s); - + serialize_task_response_manifest (); return true; } -- cgit v1.1