aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-07-30 14:27:19 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-07-30 15:02:30 +0300
commitbab55b944718705fa7696607831fe3b1646cd971 (patch)
treef922b803e549cfc69370a30a69503365c7542605 /mod
parentee3331cbb8bd7e436521545e4c21b65bf1e07484 (diff)
Use unprocessable entity HTTP status code (422) for submission semantic errors
Diffstat (limited to 'mod')
-rw-r--r--mod/mod-submit.cxx14
1 files changed, 9 insertions, 5 deletions
diff --git a/mod/mod-submit.cxx b/mod/mod-submit.cxx
index 49ffe23..accd56d 100644
--- a/mod/mod-submit.cxx
+++ b/mod/mod-submit.cxx
@@ -279,13 +279,13 @@ handle (request& rq, response& rs)
// Check for a duplicate submission.
//
- // Respond with the conflict (409) code if a duplicate is found.
+ // Respond with the unprocessable entity (422) code if a duplicate is found.
//
string ac (sha256sum, 0, 12);
dir_path dd (options_->submit_data () / dir_path (ac));
if (dir_exists (dd) || simulate == "duplicate-archive")
- return respond_manifest (409, "duplicate submission");
+ return respond_manifest (422, "duplicate submission");
// Create the temporary submission directory.
//
@@ -371,8 +371,11 @@ handle (request& rq, response& rs)
os.close ();
+ // Respond with the unprocessable entity (422) code for the archive
+ // checksum mismatch.
+ //
if (sha.string () != sha256sum)
- return respond_manifest (400, "package archive checksum mismatch");
+ return respond_manifest (422, "package archive checksum mismatch");
}
// Note that invalid_argument (thrown by open_upload() function call) can
// mean both no archive upload or multiple archive uploads.
@@ -478,7 +481,8 @@ handle (request& rq, response& rs)
// Make the temporary submission directory permanent.
//
- // Respond with the conflict (409) code if a submission race is detected.
+ // Respond with the unprocessable entity (422) code if a submission race is
+ // detected.
//
try
{
@@ -488,7 +492,7 @@ handle (request& rq, response& rs)
{
int ec (e.code ().value ());
if (ec == ENOTEMPTY || ec == EEXIST)
- return respond_manifest (409, "duplicate submission");
+ return respond_manifest (422, "duplicate submission");
error << "unable to rename directory '" << td << "' to '" << dd << "': "
<< e;