pve-manager/PVE/CLI
Christoph Heiss 86f9a0acea pvesh: decode streamed responses
This allows to use `pvesh` on endpoints like /nodes/{node}/journal,
which return streamed (and possibly gzip'd) responses.

Currently, e.g. `pvesh get /nodes/localhost/journal --lastentries 10`
fails with:

  gzip: stdout: Broken pipe
  got hash object, but result schema specified array!

Using e.g. `--output-format yaml` resulted in:

  ---
  download:
    content-encoding: gzip
    content-type: application/json
    fh: &1 !!perl/ref
      =: *1
    stream: 1

  gzip: stdout: Broken pipe
  Failed to write

This is due the API call returning a "download" object (as seen above),
which contains (among some other things) a file handle to read the
response from.

With this patch, the response from such endpoints is now correctly read
and displayed. Only handles combinations of `Content-Encoding` == 'gzip'
and either 'text/plain' or 'application/json' for `Content-Type`.

This tries to mimic the behavior of the API server implementation when
encountering `download` objects.

Tested this with all four output formats 'text', 'json', 'json-pretty'
and 'yaml', as well as "cross-node" in a local test cluster.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-10-19 10:08:54 +02:00
..
Makefile drop outdated pve6to7 upgrade checker script for bookworm 2023-05-31 18:02:39 +02:00
pve7to8.pm pve7to8: Add check for dkms modules 2023-09-27 17:02:12 +02:00
pveam.pm fix #3961: pveam: error on 'list' if storage doesn't exist 2022-06-14 10:12:35 +02:00
pveceph.pm pveceph: support installing Ceph 18.2 Reef 2023-09-04 18:05:08 +02:00
pvenode.pm cli: tasks: don't treat warning status as an error status 2021-07-02 12:52:08 +02:00
pvesh.pm pvesh: decode streamed responses 2023-10-19 10:08:54 +02:00
pvesr.pm pvesr: prepare local job: remove stale replicated volumes immediately 2022-08-02 11:05:06 +02:00
pvesubscription.pm cli: subscription: simplify printing output in get command 2023-06-05 19:04:12 +02:00
vzdump.pm cli tools: correctly handle warnings status 2021-06-24 08:50:38 +02:00