aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-05-03 11:58:39 +0200
committerChristopher Baines <mail@cbaines.net>2023-05-03 11:58:39 +0200
commitafd757537d36ef0bd21ba4744879687c0d6a49c8 (patch)
treed1ded92aef4dc8e97cfedf1d31df539ea56ff3b5
parent935ef75d590c030fbec9d3f56091b07f3bf4880b (diff)
downloadnar-herder-afd757537d36ef0bd21ba4744879687c0d6a49c8.tar
nar-herder-afd757537d36ef0bd21ba4744879687c0d6a49c8.tar.gz
Add HEAD request support for /file/
-rw-r--r--nar-herder/server.scm26
1 files changed, 17 insertions, 9 deletions
diff --git a/nar-herder/server.scm b/nar-herder/server.scm
index 50bc70f..5634fbe 100644
--- a/nar-herder/server.scm
+++ b/nar-herder/server.scm
@@ -355,10 +355,12 @@
#f)
(values (build-response #:code 404)
"404"))))))
- (('GET "file" name algo hash)
+ (((or 'HEAD 'GET) "file" name algo hash)
(guard (c ((invalid-base32-character? c)
(values (build-response #:code 404)
- "404")))
+ (if (eq? (request-method request) 'HEAD)
+ #f
+ "404"))))
(let ((hash-bytevector (nix-base32-string->bytevector hash)))
(if (and (string=? algo "sha256") (= 32 (bytevector-length
hash-bytevector)))
@@ -396,20 +398,26 @@
(values `((content-type . (application/octet-stream
(charset . "ISO-8859-1")))
(content-length . ,bytes))
- (lambda (output-port)
- (dump-port nar-port
- output-port
- bytes)
+ (if (eq? (request-method request) 'HEAD)
+ #f
+ (lambda (output-port)
+ (dump-port nar-port
+ output-port
+ bytes)
- (close-port output-port))))))
+ (close-port output-port)))))))
(values (build-response #:code 404)
- "404")))
+ (if (eq? (request-method request) 'HEAD)
+ #f
+ "404"))))
(begin
(increment-request-metric "file" "404")
(values (build-response #:code 404)
- "404"))))))
+ (if (eq? (request-method request) 'HEAD)
+ #f
+ "404")))))))
(('GET "recent-changes")
(let ((query-parameters