aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-01-26 22:27:55 +0100
committerLudovic Courtès <ludo@gnu.org>2018-01-26 22:41:22 +0100
commit4558d1c86914e2427fc99afbe00c28cb716dbd3d (patch)
treefa2763f849955a2abf133f99d1de231ad5b117ed /src
parent8b26874cac35dabb0d4e203e0de8e9c3485738a1 (diff)
downloadcuirass-4558d1c86914e2427fc99afbe00c28cb716dbd3d.tar
cuirass-4558d1c86914e2427fc99afbe00c28cb716dbd3d.tar.gz
http: Reject methods other than GET.
* src/cuirass/http.scm (url-handler): Check whether REQUEST's method is 'GET, and return 405 if not.
Diffstat (limited to 'src')
-rw-r--r--src/cuirass/http.scm8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index 1939c34..6b67379 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -130,7 +130,10 @@
(log-message "~a ~a" (request-method request)
(uri-path (request-uri request)))
- (match (request-path-components request)
+ ;; Reject OPTIONS, POST, etc.
+ (match (if (eq? 'GET (request-method request))
+ (request-path-components request)
+ 'method-not-allowed)
(((or "jobsets" "specifications") . rest)
(respond-json (object->json-string (car (db-get-specifications db)))))
(("build" build-id)
@@ -182,6 +185,9 @@
,@params
(order submission-time)))))
(respond-json-with-error 500 "Parameter not defined!"))))
+ ('method-not-allowed
+ ;; 405 "Method Not Allowed"
+ (values (build-response #:code 405) #f db))
(_
(respond (build-response #:code 404)
#:body (string-append "Resource not found: "