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 DB5DE9EE98 for ; Wed, 7 Jun 2023 14:05:23 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 484921975A for ; Wed, 7 Jun 2023 14:04:53 +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 for ; Wed, 7 Jun 2023 14:04:52 +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 97DE441E71 for ; Wed, 7 Jun 2023 14:04:52 +0200 (CEST) Date: Wed, 7 Jun 2023 14:04:52 +0200 From: Christoph Heiss To: Wolfgang Bumiller Cc: pve-devel@lists.proxmox.com Message-ID: <6sk5nixtjvvavrnqo3yy3a26hrbpadnu2pa3qicqimn7xvqn23@sksljhzymrka> References: <20230330092519.93868-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-SPAM-LEVEL: Spam detection results: 0 AWL -0.082 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH manager] pvesh: decode streamed responses X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jun 2023 12:05:23 -0000 On Wed, Jun 07, 2023 at 08:54:44AM +0200, Wolfgang Bumiller wrote: > looks mostly fine, I'd like some minor changes: Thanks for the review! > > On Thu, Mar 30, 2023 at 11:25:20AM +0200, Christoph Heiss wrote: > > [..] > > > > +my $handle_streamed_response = sub { > > + my ($download) = @_; > > + my ($fh, $path, $encoding, $type) = > > + $download->@{'fh', 'path', 'content-encoding', 'content-type'}; > > + > > + die "{download} returned but neither fh nor path given\n" > > + if !defined($fh) and !defined($path); > > ^ style nit: use && here please Ack. > > > + > > + if (defined($path)) { > > + open($fh, '<', $path) > > + or die "open stream path '$path' for reading failed: $!\n"; > > + } > > + > > + local $/; > > + my $data = <$fh>; > > + > > + if (defined($encoding)) { > > + die "unknown 'content-encoding' $encoding\n" if $encoding ne 'gzip'; > > + my $out; > > + gunzip(\$data => \$out); > > + $data = $out; > > + } > > + > > + if (defined($type) && not $type =~ qw!^text/plain!) { > > style: `$type !~ …` instead of 'not $type =~ …' Did not know !~ existed as operator as well :^) > > > + die "unknown 'content-type' $type\n" if not $type =~ qw!^application/json!; > > Would be nice to move the $type check above the part doing the gunzip() > to avoid unnecessary work. I'll restructure that, thanks. > > > [..]