[pve-devel] [PATCH 7/9] PVE/API2/Formatter/HTML.pm: avoid use of PVE::REST

Fabian Gr├╝nbichler f.gruenbichler at proxmox.com
Tue Jan 10 15:48:26 CET 2017


On Tue, Jan 10, 2017 at 11:55:24AM +0100, Dietmar Maurer wrote:
> Instead, pass the HTTP server as last argument to the page formater,
> so that we can call $server->create_auth_cookie().
> 
> Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
> ---
>  PVE/API2/Formatter/HTML.pm | 5 ++---
>  PVE/HTTPServer.pm          | 2 +-
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/API2/Formatter/HTML.pm b/PVE/API2/Formatter/HTML.pm
> index 3165088..59fceea 100644
> --- a/PVE/API2/Formatter/HTML.pm
> +++ b/PVE/API2/Formatter/HTML.pm
> @@ -3,7 +3,6 @@ package PVE::API2::Formatter::HTML;
>  use strict;
>  use warnings;
>  
> -use PVE::REST;
>  use PVE::HTTPServer;
>  use HTTP::Status;
>  use JSON;
> @@ -264,10 +263,10 @@ PVE::API2->register_page_formatter(
>      method => 'POST',
>      path => "/access/ticket",
>      code => sub {
> -	my ($res, $data, $param, $path, $auth) = @_;
> +	my ($res, $data, $param, $path, $auth, $server) = @_;

this one would really be nicer if it would say $cookie_name ;)
see patch #1

>  
>  	if (HTTP::Status::is_success($res->{status})) {
> -	    my $cookie = PVE::REST::create_auth_cookie($data->{ticket});
> +	    my $cookie = $server->create_auth_cookie($data->{ticket});
>  	    my $headers = HTTP::Headers->new(Location => $baseurl,
>  					     'Set-Cookie' => $cookie);
>  	    return HTTP::Response->new(301, "Moved", $headers);
> diff --git a/PVE/HTTPServer.pm b/PVE/HTTPServer.pm
> index 95dff1f..a8269bf 100755
> --- a/PVE/HTTPServer.pm
> +++ b/PVE/HTTPServer.pm
> @@ -825,7 +825,7 @@ sub handle_api2_request {
>  	    }
>  	}
>  
> -	my ($raw, $ct, $nocomp) = &$formatter($res, $res->{data}, $params, $path, $auth);
> +	my ($raw, $ct, $nocomp) = &$formatter($res, $res->{data}, $params, $path, $auth, $self);
>  
>  	my $resp;
>  	if (ref($raw) && (ref($raw) eq 'HTTP::Response')) {
> -- 
> 2.1.4
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



More information about the pve-devel mailing list