[pve-devel] [PATCH 2/2] rest : handle application/x-spice-configuration response format
Alexandre Derumier
aderumier at odiso.com
Wed Apr 10 13:10:55 CEST 2013
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/REST.pm | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/PVE/REST.pm b/PVE/REST.pm
index bc478d1..3fb5ea6 100644
--- a/PVE/REST.pm
+++ b/PVE/REST.pm
@@ -127,6 +127,17 @@ sub format_response_data {
# we use this for extjs file upload forms
$ct = 'text/html;charset=UTF-8';
$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 {
$ct = 'text/plain;charset=UTF-8';
$raw = to_json($data, {utf8 => 1, allow_nonref => 1, pretty => 1});
@@ -437,7 +448,7 @@ sub rest_handler {
sub split_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;
return wantarray ? ($rel_uri, $format) : $rel_uri;
--
1.7.10.4
More information about the pve-devel
mailing list