[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: http: Handle request parameters with no value.
From: |
Mathieu Othacehe |
Subject: |
branch master updated: http: Handle request parameters with no value. |
Date: |
Mon, 03 Aug 2020 09:31:18 -0400 |
This is an automated email from the git hooks/post-receive script.
mothacehe pushed a commit to branch master
in repository guix-cuirass.
The following commit(s) were added to refs/heads/master by this push:
new 2094d68 http: Handle request parameters with no value.
2094d68 is described below
commit 2094d68053f606996b2f30a62a2ae4af06851ab6
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Mon Aug 3 15:27:00 2020 +0200
http: Handle request parameters with no value.
Handle requests such as "/build/?nr" by ignoring parameters without any
associated value.
* src/cuirass/http.scm (request-parameters): Ignore silently parameters
without an associated value.
* tests/http.scm: Add a corresponding test case.
---
src/cuirass/http.scm | 17 ++++++++++-------
tests/http.scm | 7 +++++++
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index 39d8711..de27ea5 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -146,16 +146,19 @@ Hydra format."
(let* ((uri (request-uri request))
(query (uri-query uri)))
(if query
- (map (lambda (param)
+ (fold (lambda (param params)
(match (string-split param #\=)
((key param)
(let ((key-symbol (string->symbol key)))
- (cons key-symbol
- (match key-symbol
- ('id (string->number param))
- ('nr (string->number param))
- (_ param)))))))
- (string-split query #\&))
+ (cons (cons key-symbol
+ (match key-symbol
+ ('id (string->number param))
+ ('nr (string->number param))
+ (_ param)))
+ params)))
+ (_ #f)))
+ '()
+ (string-split query #\&))
'())))
diff --git a/tests/http.scm b/tests/http.scm
index 1bcd056..f1d6e46 100644
--- a/tests/http.scm
+++ b/tests/http.scm
@@ -255,6 +255,13 @@
(test-cuirass-uri
"/api/latestbuilds?nr=1&jobset=gnu")))))
+ (test-equal "/api/latestbuilds?nr&jobset=gnu"
+ 500
+ (response-code
+ (http-get
+ (test-cuirass-uri
+ "/api/latestbuilds?nr&jobset=gnu"))))
+
(test-equal "/api/queue?nr=100"
`("fake-2.0" ,(build-status scheduled))
(match (json-string->scm
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: http: Handle request parameters with no value.,
Mathieu Othacehe <=