]> bicyclesonthemoon.info Git - ott/bsta/blobdiff - frame.1.pl
improve HTTP headers; can't post with GET request
[ott/bsta] / frame.1.pl
index 92485f34d9ef5367cd04c945b59a4f60bda0f3d4..9bea1c2a91c5ef12152886e14be93afbfcee84e0 100644 (file)
@@ -27,12 +27,14 @@ use Encode ('encode', 'decode');
 
 ###PERL_LIB: use lib /botm/lib/bsta
 use botm_common (
+       'HTTP_STATUS',
        'read_header_env',
        'url_query_decode',
        'read_data_file',
        'join_path',
        'merge_url',
-       'open_encoded', 'stat_encoded'
+       'open_encoded', 'stat_encoded',
+       'http_header_line', 'http_header_content_length', 'http_header_content_disposition'
 );
 use bsta_lib (
        'STATE', 'INTF_STATE',
@@ -92,7 +94,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);
@@ -183,7 +185,7 @@ if ($try_onged) {
                        {'path' => CGI_PATH()},
                        {'path' => $frame_file}
                );
-               exit redirect ($method, $frame_path, 303);
+               exit redirect ($method, $frame_path, HTTP_STATUS->{'see_other'});
        }
 }
 unless ($r) {
@@ -199,10 +201,13 @@ unless (binmode($fh)) {
 }
 
 if (my @file_info = stat_encoded($frame_path)){
-       print 'Content-length: '.$file_info[7]."\n";
+       print http_header_content_length($file_info[7]);
 }
 if ($frame_data{'content-type'} ne '') {
-       print 'Content-type: '.$frame_data{'content-type'}."\n";
+       print http_header_line('content-type', $frame_data{'content-type'});
+}
+if ($frame_file ne '') {
+       print http_header_content_disposition('inline', $frame_file);
 }
 unless (binmode STDOUT) {
        close($fh);