aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/mod-submit.cxx28
-rw-r--r--mod/options.cli17
2 files changed, 34 insertions, 11 deletions
diff --git a/mod/mod-submit.cxx b/mod/mod-submit.cxx
index 6dbb4ec..5bc00a1 100644
--- a/mod/mod-submit.cxx
+++ b/mod/mod-submit.cxx
@@ -139,7 +139,7 @@ handle (request& rq, response& rs)
serializer s (rs.content (status, "text/manifest;charset=utf-8"),
"response");
- s.next ("", "1"); // Start of manifest.
+ s.next ("", "1"); // Start of manifest.
s.next ("status", to_string (status));
s.next ("message", message);
@@ -152,8 +152,9 @@ handle (request& rq, response& rs)
auto respond_error = [&rs] (status_code status = 500) -> bool
{
- rs.content (status, "text/plain;charset=utf-8") << "unable to handle "
- << "submission" << endl;
+ rs.content (status, "text/plain;charset=utf-8")
+ << "submission handling failed" << endl;
+
return true;
};
@@ -226,6 +227,23 @@ handle (request& rq, response& rs)
return respond_manifest (400, "invalid parameter");
}
+ const string& simulate (params.simulate ());
+
+ if (simulate == "internal-error-text")
+ return respond_error ();
+ else if (simulate == "internal-error-html")
+ {
+ const string title ("Internal Error");
+ xml::serializer s (rs.content (500), title);
+
+ s << HTML
+ << HEAD << TITLE << title << ~TITLE << ~HEAD
+ << BODY << "submission handling failed" << ~BODY
+ << ~HTML;
+
+ return true;
+ }
+
const string& archive (params.archive ());
const string& sha256sum (params.sha256sum ());
@@ -266,7 +284,7 @@ handle (request& rq, response& rs)
string ac (sha256sum, 0, 12);
dir_path dd (options_->submit_data () / dir_path (ac));
- if (dir_exists (dd))
+ if (dir_exists (dd) || simulate == "duplicate-archive")
return respond_manifest (409, "duplicate submission");
// Create the temporary submission directory.
@@ -662,7 +680,7 @@ handle (request& rq, response& rs)
// web server error log is monitored and the email sending failure will be
// noticed.
//
- if (options_->submit_email_specified () && !params.simulate ())
+ if (options_->submit_email_specified () && simulate.empty ())
try
{
// Redirect the diagnostics to the web server error log.
diff --git a/mod/options.cli b/mod/options.cli
index 66f19b1..f939b52 100644
--- a/mod/options.cli
+++ b/mod/options.cli
@@ -643,14 +643,19 @@ namespace brep
//
string sha256sum;
- // Simulate submission. Tells the submission handler not to publish the
- // package but to respond as if it does.
+ // Submission simulation. The presence of this parameter instructs the
+ // submission service to simulate various outcomes of the submission
+ // process without actually performing any externally visible actions
+ // (e.g., publishing the package, notifying the submitter, etc).
//
- // Note that the package submission email (see submit-email
- // configuration option for details) is not sent for the simulated
- // submission.
+ // Pre-defined simulation outcome values are 'internal-error-text',
+ // 'internal-error-html', 'duplicate-archive', and 'success'. The
+ // handler program may recognize additional outcomes.
//
- bool simulate;
+ // Note that the package submission email (see submit-email for details)
+ // is not sent for the simulated submissions.
+ //
+ string simulate;
};
}
}