Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
f7b7f85c
Commit
f7b7f85c
authored
May 02, 2014
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix typo
parent
27d5f5ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
28 deletions
+28
-28
API2.pm
PVE/API2.pm
+7
-7
HTTPServer.pm
PVE/HTTPServer.pm
+21
-21
No files found.
PVE/API2.pm
View file @
f7b7f85c
...
...
@@ -114,7 +114,7 @@ __PACKAGE__->register_method ({
return
$res
;
}});
# register result formaters
# register result format
t
ers
my
$prepare_response_data
=
sub
{
my
(
$format
,
$res
)
=
@_
;
...
...
@@ -151,7 +151,7 @@ my $prepare_response_data = sub {
$res
->
{
data
}
=
$new
;
};
PVE::HTTPServer::
register_formater
('
json
',
sub
{
PVE::HTTPServer::
register_format
t
er
('
json
',
sub
{
my
(
$res
,
$data
,
$param
,
$path
,
$auth
)
=
@_
;
my
$nocomp
=
0
;
...
...
@@ -166,7 +166,7 @@ PVE::HTTPServer::register_formater('json', sub {
});
PVE::HTTPServer::
register_formater
('
extjs
',
sub
{
PVE::HTTPServer::
register_format
t
er
('
extjs
',
sub
{
my
(
$res
,
$data
,
$param
,
$path
,
$auth
)
=
@_
;
my
$nocomp
=
0
;
...
...
@@ -180,7 +180,7 @@ PVE::HTTPServer::register_formater('extjs', sub {
return
(
$raw
,
$ct
,
$nocomp
);
});
PVE::HTTPServer::
register_formater
('
htmljs
',
sub
{
PVE::HTTPServer::
register_format
t
er
('
htmljs
',
sub
{
my
(
$res
,
$data
,
$param
,
$path
,
$auth
)
=
@_
;
my
$nocomp
=
0
;
...
...
@@ -197,7 +197,7 @@ PVE::HTTPServer::register_formater('htmljs', sub {
});
PVE::HTTPServer::
register_formater
('
spiceconfig
',
sub
{
PVE::HTTPServer::
register_format
t
er
('
spiceconfig
',
sub
{
my
(
$res
,
$data
,
$param
,
$path
,
$auth
)
=
@_
;
my
$nocomp
=
0
;
...
...
@@ -220,7 +220,7 @@ PVE::HTTPServer::register_formater('spiceconfig', sub {
return
(
$raw
,
$ct
,
$nocomp
);
});
PVE::HTTPServer::
register_formater
('
png
',
sub
{
PVE::HTTPServer::
register_format
t
er
('
png
',
sub
{
my
(
$res
,
$data
,
$param
,
$path
,
$auth
)
=
@_
;
my
$nocomp
=
1
;
...
...
@@ -245,7 +245,7 @@ PVE::HTTPServer::register_formater('png', sub {
return
(
$raw
,
$ct
,
$nocomp
);
});
PVE::HTTPServer::
register_formater
('
html
',
sub
{
PVE::HTTPServer::
register_format
t
er
('
html
',
sub
{
my
(
$res
,
$data
,
$param
,
$path
,
$auth
)
=
@_
;
my
$nocomp
=
0
;
...
...
PVE/HTTPServer.pm
View file @
f7b7f85c
...
...
@@ -55,49 +55,49 @@ sub split_abs_uri {
return
wantarray
?
(
$rel_uri
,
$format
)
:
$rel_uri
;
}
# generic formater support
# generic format
t
er support
my
$formater_hash
=
{};
my
$format
t
er_hash
=
{};
sub
register_formater
{
sub
register_format
t
er
{
my
(
$format
,
$func
)
=
@_
;
die
"
format
er '
$format
' already defined
"
if
$forma
ter_hash
->
{
$format
};
die
"
format
ter '
$format
' already defined
"
if
$format
ter_hash
->
{
$format
};
$formater_hash
->
{
$format
}
=
{
$format
t
er_hash
->
{
$format
}
=
{
func
=>
$func
,
};
}
sub
get_formater
{
sub
get_format
t
er
{
my
(
$format
)
=
@_
;
return
undef
if
!
$format
;
my
$info
=
$formater_hash
->
{
$format
};
my
$info
=
$format
t
er_hash
->
{
$format
};
return
undef
if
!
$info
;
return
$info
->
{
func
};
}
my
$login_formater_hash
=
{};
my
$login_format
t
er_hash
=
{};
sub
register_login_formater
{
sub
register_login_format
t
er
{
my
(
$format
,
$func
)
=
@_
;
die
"
login format
er '
$format
' already defined
"
if
$login_forma
ter_hash
->
{
$format
};
die
"
login format
ter '
$format
' already defined
"
if
$login_format
ter_hash
->
{
$format
};
$login_formater_hash
->
{
$format
}
=
{
$login_format
t
er_hash
->
{
$format
}
=
{
func
=>
$func
,
};
}
sub
get_login_formater
{
sub
get_login_format
t
er
{
my
(
$format
)
=
@_
;
return
undef
if
!
$format
;
my
$info
=
$login_formater_hash
->
{
$format
};
my
$info
=
$login_format
t
er_hash
->
{
$format
};
return
undef
if
!
$info
;
return
$info
->
{
func
};
...
...
@@ -496,9 +496,9 @@ sub handle_api2_request {
my
(
$rel_uri
,
$format
)
=
split_abs_uri
(
$path
);
my
$format
er
=
get_forma
ter
(
$format
);
my
$format
ter
=
get_format
ter
(
$format
);
if
(
!
defined
(
$formater
))
{
if
(
!
defined
(
$format
t
er
))
{
$self
->
error
(
$reqstate
,
HTTP_NOT_IMPLEMENTED
,
"
no such uri
$rel_uri
,
$format
");
return
;
}
...
...
@@ -554,13 +554,13 @@ sub handle_api2_request {
$delay
=
0
if
$delay
<
0
;
}
if
(
$res
->
{
info
}
&&
$res
->
{
info
}
->
{
formater
})
{
if
(
defined
(
my
$func
=
$res
->
{
info
}
->
{
formater
}
->
{
$format
}))
{
$formater
=
$func
;
if
(
$res
->
{
info
}
&&
$res
->
{
info
}
->
{
format
t
er
})
{
if
(
defined
(
my
$func
=
$res
->
{
info
}
->
{
format
t
er
}
->
{
$format
}))
{
$format
t
er
=
$func
;
}
}
my
(
$raw
,
$ct
,
$nocomp
)
=
&
$formater
(
$res
,
$res
->
{
data
},
$path
,
$auth
);
my
(
$raw
,
$ct
,
$nocomp
)
=
&
$format
t
er
(
$res
,
$res
->
{
data
},
$path
,
$auth
);
my
$resp
;
if
(
ref
(
$raw
)
&&
(
ref
(
$raw
)
eq
'
HTTP::Response
'))
{
...
...
@@ -1014,8 +1014,8 @@ sub unshift_read_header {
if
(
my
$err
=
$@
)
{
# always delay unauthorized calls by 3 seconds
my
$delay
=
3
;
if
(
my
$format
er
=
get_login_forma
ter
(
$format
))
{
my
(
$raw
,
$ct
,
$nocomp
)
=
&
$formater
(
$path
,
$auth
);
if
(
my
$format
ter
=
get_login_format
ter
(
$format
))
{
my
(
$raw
,
$ct
,
$nocomp
)
=
&
$format
t
er
(
$path
,
$auth
);
my
$resp
;
if
(
ref
(
$raw
)
&&
(
ref
(
$raw
)
eq
'
HTTP::Response
'))
{
$resp
=
$raw
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment