diff options
author | Christopher Baines <mail@cbaines.net> | 2021-02-28 14:38:03 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-02-28 18:40:20 +0000 |
commit | caf63dce0ea29a07c5205a69ff6f60b7c6b60084 (patch) | |
tree | 430f9accd8cf00d307b298a5a58b1ba3cb3d62f3 /guix-build-coordinator | |
parent | f9a257ed61531eafc9727faebe50be1a1cb1648a (diff) | |
download | build-coordinator-caf63dce0ea29a07c5205a69ff6f60b7c6b60084.tar build-coordinator-caf63dce0ea29a07c5205a69ff6f60b7c6b60084.tar.gz |
Move request-query-parameters to utils
Diffstat (limited to 'guix-build-coordinator')
-rw-r--r-- | guix-build-coordinator/client-communication.scm | 20 | ||||
-rw-r--r-- | guix-build-coordinator/utils.scm | 23 |
2 files changed, 23 insertions, 20 deletions
diff --git a/guix-build-coordinator/client-communication.scm b/guix-build-coordinator/client-communication.scm index 6ad98f2..550b054 100644 --- a/guix-build-coordinator/client-communication.scm +++ b/guix-build-coordinator/client-communication.scm @@ -81,26 +81,6 @@ #:port port)) #:on-error 'backtrace)) -(define (request-query-parameters request) - (define (parse-query-string query) - "Parse and decode the URI query string QUERY and return an alist." - (let lp ((lst (map uri-decode (string-split query (char-set #\& #\=))))) - (match lst - ((key value . rest) - (cons (cons key value) (lp rest))) - (("") '()) - (() '())))) - - (let ((query (uri-query (request-uri request)))) - (if (and query - (not (string-null? query))) - (map (match-lambda - ((name . value) - (cons (string->symbol name) - value))) - (parse-query-string query)) - '()))) - (define (controller request method-and-path-components raw-body diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index 0a5af15..fea9c1c 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -33,6 +33,9 @@ #:export (random-v4-uuid make-base64-output-port + + request-query-parameters + call-with-streaming-http-request make-chunked-input-port* @@ -226,6 +229,26 @@ upcoming chunk." (make-custom-binary-input-port "chunked input port" read! #f #f close)) +(define (request-query-parameters request) + (define (parse-query-string query) + "Parse and decode the URI query string QUERY and return an alist." + (let lp ((lst (map uri-decode (string-split query (char-set #\& #\=))))) + (match lst + ((key value . rest) + (cons (cons key value) (lp rest))) + (("") '()) + (() '())))) + + (let ((query (uri-query (request-uri request)))) + (if (and query + (not (string-null? query))) + (map (match-lambda + ((name . value) + (cons (string->symbol name) + value))) + (parse-query-string query)) + '()))) + (define* (call-with-streaming-http-request uri callback #:key (headers '())) (let* ((port (open-socket-for-uri uri)) |