From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id GAgDFLbhrWPtPAAAbAwnHQ (envelope-from ) for ; Thu, 29 Dec 2022 19:51:34 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id EFjoE7bhrWNOrQAAauVa8A (envelope-from ) for ; Thu, 29 Dec 2022 19:51:34 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 055DE1A630 for ; Thu, 29 Dec 2022 19:51:33 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAxQp-0000CB-9O; Thu, 29 Dec 2022 13:15:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pAxQl-0000AX-Jq for guix-patches@gnu.org; Thu, 29 Dec 2022 13:15:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAxQl-00049B-9F for guix-patches@gnu.org; Thu, 29 Dec 2022 13:15:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pAxQl-0007RX-4z for guix-patches@gnu.org; Thu, 29 Dec 2022 13:15:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52555] [PATCH v3 5/8] eris/http: Add HTTP block de-referencer. Resent-From: pukkamustard Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 29 Dec 2022 18:15:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52555 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52555@debbugs.gnu.org Cc: pukkamustard Received: via spool by 52555-submit@debbugs.gnu.org id=B52555.167233767728502 (code B ref 52555); Thu, 29 Dec 2022 18:15:03 +0000 Received: (at 52555) by debbugs.gnu.org; 29 Dec 2022 18:14:37 +0000 Received: from localhost ([127.0.0.1]:32808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAxQK-0007PY-RI for submit@debbugs.gnu.org; Thu, 29 Dec 2022 13:14:37 -0500 Received: from mout02.posteo.de ([185.67.36.66]:50291) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAxQD-0007OL-CV for 52555@debbugs.gnu.org; Thu, 29 Dec 2022 13:14:30 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id DB8E42401A9 for <52555@debbugs.gnu.org>; Thu, 29 Dec 2022 19:14:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1672337663; bh=HxZoZL8oLhJfoeETpauNq/MdOkf5vrtFLoMKrJn87GI=; h=From:To:Cc:Subject:Date:From; b=ewumwp+ApQe2kiWg1LfwTDiMJ6mIVkX7HK4Aw3MjSp8a80vzihaVkq439No4puVsY 1nCHRn1Do7kHXHI9NACaWpRU6VSyLQW65QXWaqg/HVGEZy2SbTP9fWtnQw5Mr1DBLO MEVh2SV8t2RwjR/NIar3ET+KRNiHbShR1aWeOyyknF2OKJPYpe+7j+Hjp6ObkR5cge RTcKzGkZxG+WTief9biX5EROmfIKCUdZkTt1kluPUVUSQxxOKj+SaL4PgfwNGjamVg 7LHfeRFjZlHdknpeXWrtqe4C3oeJbMZ11E4xyFwYGfLhg7YM00nmQ/7FfPNFlN6VyX SHOYzuqMQO2tQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Njc3g1lm5z6tn0; Thu, 29 Dec 2022 19:14:23 +0100 (CET) From: pukkamustard Date: Thu, 29 Dec 2022 18:13:24 +0000 Message-Id: <20221229181327.758-6-pukkamustard@posteo.net> In-Reply-To: <20221229181327.758-1-pukkamustard@posteo.net> References: <20221229181327.758-1-pukkamustard@posteo.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1672339894; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=/G+JBHBqU7LmjUQEUJ5JUh6Tq5ivhXq95Ho64BCkvqo=; b=jOYxm4bOZvYeDqYWUBLG9qk6AxgNAbWHvkYpHXwsJDKgdZMXAjlBXvB4eHzGZZktNLypdU ZlXHr1HBkJ8ro9DlBvlzc0ClO1ERCovcQGyDkonJlupHLEL5YSYtkNUnO+PtQD03ph0r/s oV8j0lw0LiMVP0fRxNqxyflj62PCK2vKNixBPnAU0eNhoyatZ+vSVfKPBSmJDUxZ7C69sL xpCFNJi7re12jyK4Yq2XZlTQkedRJWxPokY50nEr7esTm0hRYf4mwdaf4mgsWgLMip8Ouz KgrPCLeJVNdf5oVB/QAmqZDAoXU/n7ir12vNurKooTKRxcv9spT7QwCu/IirRw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=ewumwp+A; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1672339894; a=rsa-sha256; cv=none; b=nV/SuiTC4nh9xfQXyhsMw5ghV2ONJ9uV/f57rj22ThifCY9VzrErJoHd9n9mSd816FPW+w rNLI7sB82HHuqQHozNNf/4N2Iww8HZcagYXD8VbJq7eSLitbpd23IbA2tE23Fncz7wy0vd 6raMjGoUiEVn9NgqaSujF5r4rMNOSAsZVkzc8XWLZlP/8VEbCEbGcLvGFbuKPP21R79z9r 0tbIASws+EA6+Htn6qN6XpdjxMKctK4CVbuiHTm62ln3YmWvGplVpuwAHMb5mfns8OjFxV QhbSuxrvxmGznaZzjrbh35CFVKaZWkQ0sOnk5Fajv9h2vHVsKKbFyHHH3QVMPA== X-Spam: Yes X-Migadu-Queue-Id: 055DE1A630 X-Migadu-Spam: Yes X-Spam-Score: 8.77 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=ewumwp+A; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: 8.77 X-TUID: xy4o8ad1JMF7 * 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