public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: Wolfgang Bumiller <w.bumiller@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH manager] pvesh: decode streamed responses
Date: Wed, 7 Jun 2023 14:04:52 +0200	[thread overview]
Message-ID: <6sk5nixtjvvavrnqo3yy3a26hrbpadnu2pa3qicqimn7xvqn23@sksljhzymrka> (raw)
In-Reply-To: <geyba3rng2pr2ehjo3pr4xs2pyhiucnb7bfh7r6lslc434pkn6@rck4vbnc5quo>

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.

>
> > [..]




      reply	other threads:[~2023-06-07 12:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30  9:25 Christoph Heiss
2023-06-07  6:54 ` Wolfgang Bumiller
2023-06-07 12:04   ` Christoph Heiss [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6sk5nixtjvvavrnqo3yy3a26hrbpadnu2pa3qicqimn7xvqn23@sksljhzymrka \
    --to=c.heiss@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=w.bumiller@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal