]> bicyclesonthemoon.info Git - ott/bsta/blobdiff - viewer.1.pl
improve HTTP headers; can't post with GET request
[ott/bsta] / viewer.1.pl
index c62a0f77672d0949e0ac08e5fde7ce36e3bd14d1..33c90edcb079ba8a18b60a3830160fbc3515ffbe 100644 (file)
@@ -27,11 +27,13 @@ use Encode ('encode', 'decode');
 
 ###PERL_LIB: use lib /botm/lib/bsta
 use botm_common (
+       'HTTP_STATUS',
        'read_header_env',
        'read_data_file', 'write_data_file',
        'url_query_decode',
        'join_path',
-       'open_encoded'
+       'open_encoded',
+       'http_header_status',
 );
 use bsta_lib (
        'STATE', 'TEXT_MODE', 'INTF_STATE',
@@ -97,7 +99,7 @@ if ($ENV{'REQUEST_METHOD'} =~ /^(HEAD|GET|POST)$/) {
        $method = $1;
 }
 else{
-       exit fail_method($ENV{'REQUEST_METHOD'}, 'GET, POST, HEAD');
+       exit fail_method($ENV{'REQUEST_METHOD'}, ['GET', 'POST', 'HEAD']);
 }
 
 %http = read_header_env(\%ENV);
@@ -297,11 +299,10 @@ $words_data_path = join_path(PATH_SEPARATOR(), DATA_WORDS_PATH(), $frame);
        1,  # as list
 );
 
-print "Content-type: text/html; charset=UTF-8\n";
-if(!$access) {
-       print "Status: 403 Forbidden\n";
+if (!$access) {
+       print http_header_status(HTTP_STATUS->{'forbidden'});
 }
-print "\n";
+print "Content-type: text/html; charset=UTF-8\n\n";
 if($method eq 'HEAD') {
        exit;
 }