From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id zdd0NCNvp2DCMgEAgWs5BA (envelope-from ) for ; Fri, 21 May 2021 10:28:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id iIedLyNvp2DlegAAB5/wlQ (envelope-from ) for ; Fri, 21 May 2021 08:28:19 +0000 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 5D5ABEC01 for ; Fri, 21 May 2021 10:28:19 +0200 (CEST) Received: from localhost ([::1]:58300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lk0W0-0006Ln-FP for larch@yhetil.org; Fri, 21 May 2021 04:28:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lk0Vo-0005xW-4S for guix-patches@gnu.org; Fri, 21 May 2021 04:28:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lk0Vn-0005PD-T5 for guix-patches@gnu.org; Fri, 21 May 2021 04:28:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lk0Vn-00062j-QQ for guix-patches@gnu.org; Fri, 21 May 2021 04:28:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48559] [PATCH 2/4] scripts: publish: Forward the request connection header. Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 21 May 2021 08:28:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48559 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48559@debbugs.gnu.org Cc: Mathieu Othacehe X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162158565223157 (code B ref -1); Fri, 21 May 2021 08:28:03 +0000 Received: (at submit) by debbugs.gnu.org; 21 May 2021 08:27:32 +0000 Received: from localhost ([127.0.0.1]:35742 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lk0VI-00061L-9v for submit@debbugs.gnu.org; Fri, 21 May 2021 04:27:32 -0400 Received: from lists.gnu.org ([209.51.188.17]:44360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lk0VF-00060y-Uo for submit@debbugs.gnu.org; Fri, 21 May 2021 04:27:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lk0VF-0005J9-KJ for guix-patches@gnu.org; Fri, 21 May 2021 04:27:29 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36136) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lk0VB-00053S-V9 for guix-patches@gnu.org; Fri, 21 May 2021 04:27:27 -0400 Received: from [2a01:e0a:19b:d9a0:f2f7:a404:c3d3:f8b4] (port=37126 helo=localhost.localdomain) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lk0V7-0003nM-Vj; Fri, 21 May 2021 04:27:25 -0400 From: Mathieu Othacehe Date: Fri, 21 May 2021 10:27:11 +0200 Message-Id: <20210521082713.20169-2-othacehe@gnu.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210521082713.20169-1-othacehe@gnu.org> References: <20210521082713.20169-1-othacehe@gnu.org> 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621585699; 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; bh=g0vQbs8h9FOb0jJenYEz8gOYuG1Wv/C5kDmTZHQ//Aw=; b=YNE5qzrRkZbFAPPbA87Tko5wTIAec8YxpWIEn88CZyMXk6EnTJ/O/GJ8Kfbz5etjyIglZD sUmThDUEAilEyrR5viok0PSD08FSwHwad4SOkk8eKXzkrZF29BSyrgGCFHpGvIUJfmhnHh xsjLTcp0Vpq65hDkpNKcMqigMEyYMyKP2iryyJrWiecaIOBeqNuUNBB8KAizFgGGXjRxxJ MHyDkS4MnLEQgw4vZfsSX1smbqRU/8bItyT2nMVK2HSmsYMnxVd9+YT7l7OwaXxUZFMfpR Vd3xpz6aB0zSIET0c7b+fbYotOzkqw83vFw3AR3nnVaj2fnUxpLu1bT65DHEaQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621585699; a=rsa-sha256; cv=none; b=lnlB8/56EM2Yomem1xYFPz6MX9zlHkLbynjk9EsJ9EzG6IgEu2Z2B7lK2gh1an1b1/IgJv /5uEY8XMVJP3C94UXAq/d1sg+cWVbjP0Mh75DPiIaRZZvVXtHaOKlt9cCxUtL3IKiJKh5C MUZLcxrUeF8IZRG5dsjc9MTsIn992Dytj2CfwQhVD/PzlR2lf+/TznwDy59XQWNVbkHn4z zeKxJJkg6nXG4qO8fUtfP0MOBjLtSeFoTrLp/lrw0UxpMzgudhwAoXYd8/xIcTlVbrUl6p WpX1InlrEeCV8fvYT1VEILILWIy3fIV/2c6hZxCs0EvdJHdwcQKmDtPHnG/DQA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 2.06 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 5D5ABEC01 X-Spam-Score: 2.06 X-Migadu-Scanner: scn0.migadu.com X-TUID: m0HLdcsJwyOP The Guile web server is reading the response connection header to decide whether to close the connection. However, as the request connection header is not forwarded to the response, this mechanism cannot work. * guix/scripts/publish.scm (add-extra-headers): New procedure. (make-request-handler): Use it to forward the request connection header to the response. --- guix/scripts/publish.scm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm index 19fed574c2..260f98edf0 100644 --- a/guix/scripts/publish.scm +++ b/guix/scripts/publish.scm @@ -34,6 +34,7 @@ #:use-module (srfi srfi-2) #:use-module (srfi srfi-9) #:use-module (srfi srfi-9 gnu) + #:use-module (srfi srfi-11) #:use-module (srfi srfi-19) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) @@ -1034,6 +1035,14 @@ methods, return the applicable compression." compressions) (default-compression requested-type))) +(define (add-extra-headers request response) + "Append the REQUEST connection header to the given RESPONSE headers and +return them." + (if (pair? response) + `(,@response + ,(assq 'connection (request-headers request))) + response)) + (define* (make-request-handler store #:key cache pool @@ -1047,7 +1056,7 @@ methods, return the applicable compression." (let ((expected (split-and-decode-uri-path nar-path))) (cut equal? expected <>))) - (lambda (request body) + (define (handle request body) (format #t "~a ~a~%" (request-method request) (uri-path (request-uri request))) @@ -1119,7 +1128,15 @@ methods, return the applicable compression." (not-found request))) (x (not-found request))) - (not-found request)))) + (not-found request))) + + ;; Forward the request connection header to the response, so that the server + ;; can close the connection if this is requested by the client. + (lambda (request body) + (let-values (((response response-body) + (handle request body))) + (values (add-extra-headers request response) + response-body)))) (define (service-name) "Return the Avahi service name of the server." -- 2.31.1