From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 707669205D; Mon, 10 Oct 2022 15:10:49 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 44BA94023; Mon, 10 Oct 2022 15:10:19 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS; Mon, 10 Oct 2022 15:10:17 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C17EE44902; Mon, 10 Oct 2022 15:10:16 +0200 (CEST) Message-ID: <018a731f-d9c3-b038-613d-f0d02df6355c@proxmox.com> Date: Mon, 10 Oct 2022 15:10:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:106.0) Gecko/20100101 Thunderbird/106.0 Content-Language: en-GB To: Daniel Tschlatscher , Proxmox VE development discussion , pbs-devel@lists.proxmox.com, pmg-devel@lists.proxmox.com References: <20220907085633.89113-1-d.tschlatscher@proxmox.com> <20220907085633.89113-5-d.tschlatscher@proxmox.com> <09162367-74c0-a233-b913-a1b0e9477ef7@proxmox.com> From: Thomas Lamprecht In-Reply-To: <09162367-74c0-a233-b913-a1b0e9477ef7@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 1.934 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -3.934 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pmg-devel] [pve-devel] [PATCH manager v2 4/7] revised task log API call for PVE X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2022 13:10:49 -0000 Am 10/10/2022 um 13:40 schrieb Daniel Tschlatscher: > It does save about 20 lines of very redundant code in both pmg and pve > each and should make it easy to implement potential other download > calls. Though, that hinges on the question on how likely it is that > there will be such a need. 20 lines is: 1) really not _that_ much 2) especially not dramatic as its just plain boilerplate info that won't change 3) only your version needs that much ;-P Can be easily cut down of 16 lines my $fh; if ($compress) { open($fh, '-|', "/usr/bin/gzip", "-c", "$file") or die "could not open file $file - $!"; } else { open($fh, '<', $file) or die "could not open file $file- $!"; } return { download => { fh => $fh, stream => 1, 'content-encoding' => $compress ? 'gzip' : undef, 'content-type' => $content_type // 'text/plain', 'content-disposition' => 'attachment; filename="'. ($suggested_name // $file) .'"', }, }; And independent of that, pve-common would be the wrong place for that helper, as it has no control over how the http server takes the streaming hint, i.e., this is not a general stream middleware but only prepare it in the specific format that our perl http server expects it. So _iff_ it should go into pve-http-server, as otherwise any changes would need and extra level of coordination on upgrade and possibly even make pve-common depend on pve-http-server, introducing a circular dependency.