aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-build-task.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-05-15 22:38:18 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2023-05-17 19:02:14 +0300
commit390af63a73b7d91c3c0b37089e88027b4f46a39f (patch)
tree4c373646625b6c54007a942c6e022dcb14fea4df /mod/mod-build-task.cxx
parent9f5b820aec37ac0a929e074ae2c859229da33b0f (diff)
Add support for interactive parameter for task request
Diffstat (limited to 'mod/mod-build-task.cxx')
-rw-r--r--mod/mod-build-task.cxx45
1 files changed, 35 insertions, 10 deletions
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<buildable_package>;
using prep_pkg_query = prepared_query<buildable_package>;
- interactive_mode imode (tqm.effective_interactive_mode ());
pkg_query pq (package_query<buildable_package> (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;
}