diff options
Diffstat (limited to 'rh-bin/musicgrid.cgi')
-rwxr-xr-x | rh-bin/musicgrid.cgi | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/rh-bin/musicgrid.cgi b/rh-bin/musicgrid.cgi index f2bf9db..5e2888d 100755 --- a/rh-bin/musicgrid.cgi +++ b/rh-bin/musicgrid.cgi @@ -35,7 +35,7 @@ my @clocks = (); my $q = CGI->new; my $username = $q->param('LOGIN_NAME'); my $token = $q->param('PASSWORD'); -my $cmd = $q->param('COMMAND'); +my $cmd = $q->request_method(); sub get_clocks { @@ -83,24 +83,21 @@ if(!defined $username) { } elsif(!defined $token) { $responsecode = 400; $errorstring = "mandatory field PASSWORD is missing"; -} elsif(!defined $cmd) { - $responsecode = 400; - $errorstring = "mandatory field COMMAND is missing"; } else { (my $ctx, $status, $errorstring) = RHRD::rddb::init(); if(defined $ctx) { (my $authenticated, $status, $errorstring) = RHRD::rddb::check_token($ctx, $username, $token); my $authorized = RHRD::rddb::is_musicpools_user($ctx, $username); if($authenticated == 1 && $authorized == 1) { - if($cmd eq "get") { + if($cmd eq "GET") { ($responsecode, $errorstring) = get_clocks($ctx); } - elsif($cmd eq "set") { + elsif($cmd eq "POST") { ($responsecode, $errorstring) = set_clock($ctx); } else { - $responsecode = 400; - $errorstring = "command '$cmd' is unknown"; + $responsecode = 405; + $errorstring = "request method '$cmd' is unknown"; } } elsif($authenticated == 0) { $responsecode = 401; @@ -117,7 +114,7 @@ if(!defined $username) { print "Content-type: application/xml; charset=UTF-8\n"; print "Status: $responsecode\n\n"; -if($cmd eq "set" || $responsecode != 200) { +if($cmd eq "POST" || $responsecode != 200) { print "<RDWebResult>\n"; print " <ResponseCode>" . xml_quote($responsecode) . "</ResponseCode>\n"; print " <ErrorString>" . xml_quote($errorstring) . "</ErrorString>\n"; |