GNU bug report logs -
#52555
[RFC PATCH 0/3] Decentralized substitute distribution with ERIS
Previous Next
Full log
View this message in rfc822 format
* guix/eris/http.scm (eris-http-block-ref): New procedure.
---
guix/eris/http.scm | 46 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/guix/eris/http.scm b/guix/eris/http.scm
index a8a9520197..354d3be3be 100644
--- a/guix/eris/http.scm
+++ b/guix/eris/http.scm
@@ -18,11 +18,17 @@
(define-module (guix eris http)
#:use-module (eris utils base32)
+
#:use-module (web uri)
+ #:use-module (web client)
+ #:use-module (web response)
- #:use-module (srfi srfi-2)
+ #:use-module (rnrs base)
+ #:use-module (srfi srfi-2) ; and-let*
+ #:use-module (srfi srfi-71) ; extended let-syntax for multiple values
- #:export (make-blake2b-urn-query-ref))
+ #:export (make-blake2b-urn-query-ref
+ eris-http-block-ref))
(define blake2b-uri-path-regexp
(make-regexp "^blake2b:" regexp/icase))
@@ -38,3 +44,39 @@ (define (make-blake2b-urn-query-ref block-ref)
(blake2b-ref (base32-decode
(string-drop (uri-path urn) 8))))
(block-ref blake2b-ref))))
+
+(define (make-blake2b-urn ref)
+ (string-append "urn:blake2b:" (base32-encode ref)))
+
+(define (make-request-uri host ref)
+ (build-uri (uri-scheme host)
+ #:userinfo (uri-userinfo host)
+ #:host (uri-host host)
+ #:port (uri-port host)
+ #:path "/uri-res/N2R"
+ #:query (make-blake2b-urn ref)))
+
+(define* (eris-http-block-ref
+ ref
+ #:key host
+ (open-connection (lambda (host) (open-socket-for-uri host))))
+
+ (let* ((uri (make-request-uri host ref))
+ (_ (format #t "URI: ~a\n" uri))
+ (response body
+ (http-get uri
+ #:decode-body? #f
+ #:port (open-connection host)
+ #:keep-alive? #t)))
+ (if (eqv? (response-code response) 200)
+ body
+ #f)))
+
+;; (use-modules (eris)
+;; (rnrs bytevectors))
+
+;; (bytevector?
+;; (eris-http-block-ref
+;; (base32-decode
+;; "4ACQM2Q5IB3DBHGKHM2WRTAXDBPMVZ7F6MG2TUXZ5QOJHW7P4N7Q")
+;; #:host (string->uri "http://localhost:8081")))
--
2.38.1
This bug report was last modified 1 year and 233 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.