mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-06 22:42:30 +00:00
rest : handle application/x-spice-configuration response format
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
7fe4ba9e43
commit
6e30b52dd4
@ -46,7 +46,7 @@ my $baseuri = "/api2";
|
|||||||
sub split_abs_uri {
|
sub split_abs_uri {
|
||||||
my ($abs_uri) = @_;
|
my ($abs_uri) = @_;
|
||||||
|
|
||||||
my ($format, $rel_uri) = $abs_uri =~ m/^\Q$baseuri\E\/+(html|text|json|extjs|png|htmljs)(\/.*)?$/;
|
my ($format, $rel_uri) = $abs_uri =~ m/^\Q$baseuri\E\/+(html|text|json|extjs|png|htmljs|spiceconfig)(\/.*)?$/;
|
||||||
$rel_uri = '/' if !$rel_uri;
|
$rel_uri = '/' if !$rel_uri;
|
||||||
|
|
||||||
return wantarray ? ($rel_uri, $format) : $rel_uri;
|
return wantarray ? ($rel_uri, $format) : $rel_uri;
|
||||||
|
11
PVE/REST.pm
11
PVE/REST.pm
@ -111,6 +111,17 @@ sub format_response_data {
|
|||||||
# we use this for extjs file upload forms
|
# we use this for extjs file upload forms
|
||||||
$ct = 'text/html;charset=UTF-8';
|
$ct = 'text/html;charset=UTF-8';
|
||||||
$raw = encode_entities(to_json($data, {allow_nonref => 1}));
|
$raw = encode_entities(to_json($data, {allow_nonref => 1}));
|
||||||
|
} elsif ($format eq 'spiceconfig') {
|
||||||
|
$ct = 'application/x-spice-configuration;charset=UTF-8';
|
||||||
|
if ($data && ref($data) && ref($data->{data})) {
|
||||||
|
$raw = "[virt-viewer]\n";
|
||||||
|
$raw .= "title=$data->{data}->{title}\n" if $data->{data}->{title};
|
||||||
|
$raw .= "type=$data->{data}->{type}\n" if $data->{data}->{type};
|
||||||
|
$raw .= "host=$data->{data}->{host}\n" if $data->{data}->{host};
|
||||||
|
$raw .= "port=$data->{data}->{port}\n" if $data->{data}->{port};
|
||||||
|
$raw .= "password=$data->{data}->{password}\n" if $data->{data}->{password};
|
||||||
|
$raw .= "proxy=$data->{data}->{proxy}\n" if $data->{data}->{proxy};
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$ct = 'text/plain;charset=UTF-8';
|
$ct = 'text/plain;charset=UTF-8';
|
||||||
$raw = to_json($data, {utf8 => 1, allow_nonref => 1, pretty => 1});
|
$raw = to_json($data, {utf8 => 1, allow_nonref => 1, pretty => 1});
|
||||||
|
Loading…
Reference in New Issue
Block a user