Hello,
Is there a way to set a default mime-type for nscgi similar to how other 
naviserver modules use the default mime-types associated by file suffix, or in 
any other way, or have I goofed the config?
With 4.99.18 and these settings, no mime-type is provided. Browsers aren't 
recognizing such content and nscgi isn't sending the content in these cases as 
far as I can tell.

Varying value of ns_param allowstaticresources doesn't seem to change anything 
(after restarting nsd). 

ns_section "ns/server/${server}/module/nscgi" 
       ns_param map     "GET  /cgi-bin /usr/local/cgi-bin"
       ns_param map     "POST /cgi-bin /usr/local/cgi-bin" 
       ns_param Interps CGIinterps
       ns_param        allowstaticresources true    ;# default: false
#
# CGI
#
ns_section "ns/Interps/CGIinterps"
       ns_param .cgi "/usr/local/ns/bin/tclsh"
       ns_param .pl "/usr/bin/perl"

FYI, for testing, I made these url/files:/cgi-bin/test.pl   - dynamically 
generated with mime-type  
/cgi-bin/test-wo-mimetype.pl - dynamically generated without mime-type
/cgi-bin/test2.cgi  -dynamically generated with mime-type (same as case 
provided here: Forum OpenACS Q&A: Naviserver + nscgi )

| 
| 
|  | 
Forum OpenACS Q&A: Naviserver + nscgi


 |

 |

 |

/cgi-bin/test3.cgi  -dynamically generated without mime-type (similar to 
test2.cgi less the mime-type declaration)
/cgi-bin/test4.txt  -static "hello world" text file
/cgi-bin/test5.html -static "hello world" html file
/test4.txt  -static "hello world" text file
/test5.html  -static "hello world" html file

and tested cases using this "t" tcl/adp pair in an OpenACS test site:
t.adp:<pre>
@content_html;noquote@
</pre>
t.tcl:
set test_names_list [list cgi-bin/test.pl \
             cgi-bin/test-wo-mimetype.pl \
             cgi-bin/test2.cgi \
             cgi-bin/test3.cgi \
             cgi-bin/test4.txt \
             cgi-bin/test5.html \
             test4.txt \
             test5.html ]
    
set content_html ""
foreach n $test_names_list {
    set u "http://localhost:8000/";
    append u $n
    set result_dict [util::http::get -url $u ]
    append content_html $u " : \n"
    dict for {k v} $result_dict {
    append content_html "  " $k " : " $v "\n"
    }
append content_html "\n"
}


Here's an example of test page results using OpenACS' util::http::get:


http://localhost:8000/cgi-bin/test.pl : 
  headers : server NaviServer/4.99.18 date {Thu, 28 Feb 2019 03:16:50 GMT} 
x-frame-options SAMEORIGIN x-content-type-options nosniff x-xss-protection {1; 
mode=block} referrer-policy strict-origin set-cookie 
{ad_session_id="210001%2c0%2c0%2c1551323810%20{744%201551325010%201605F86CC89B6BA5C0830FD3E4C413A955563B44}";
 Expires=Fri, 01-Jan-2035 01:00:00 GMT; Path=/; Discard; HttpOnly} content-type 
text/plain connection close
  page : hello world
  file : 
  status : 200
  modified : 

http://localhost:8000/cgi-bin/test-wo-mimetype.pl : 
  headers : server NaviServer/4.99.18 date {Thu, 28 Feb 2019 03:16:50 GMT} 
x-frame-options SAMEORIGIN x-content-type-options nosniff x-xss-protection {1; 
mode=block} referrer-policy strict-origin set-cookie 
{ad_session_id="210002%2c0%2c0%2c1551323810%20{128%201551325010%2000B49E88A7DD72C3E8840DB3BBD40C043E870469}";
 Expires=Fri, 01-Jan-2035 01:00:00 GMT; Path=/; Discard; HttpOnly} connection 
close
  page : 
  file : 
  status : 200
  modified : 

http://localhost:8000/cgi-bin/test2.cgi : 
  headers : server NaviServer/4.99.18 date {Thu, 28 Feb 2019 03:16:50 GMT} 
x-frame-options SAMEORIGIN x-content-type-options nosniff x-xss-protection {1; 
mode=block} referrer-policy strict-origin set-cookie 
{ad_session_id="210003%2c0%2c0%2c1551323810%20{133%201551325010%2017B9AE6B9466893882B47FEF24895721ADFFCA9E}";
 Expires=Fri, 01-Jan-2035 01:00:00 GMT; Path=/; Discard; HttpOnly} {http/1.0 
200 okdate} {Monday, 06-Nov-95 17:50:15 GMT} content-type text/html connection 
close
  page : 

Hello World



  file : 
  status : 200
  modified : 

http://localhost:8000/cgi-bin/test3.cgi : 
  headers : server NaviServer/4.99.18 date {Thu, 28 Feb 2019 03:16:51 GMT} 
x-frame-options SAMEORIGIN x-content-type-options nosniff x-xss-protection {1; 
mode=block} referrer-policy strict-origin set-cookie 
{ad_session_id="210004%2c0%2c0%2c1551323810%20{126%201551325010%208E8037ACE4FC0A043ACCF888D561EEA18CDCDF87}";
 Expires=Fri, 01-Jan-2035 01:00:00 GMT; Path=/; Discard; HttpOnly} {http/1.0 
200 okdate} {Monday, 06-Nov-95 17:50:15 GMT} connection close
  page : 

Hello World



  file : 
  status : 200
  modified : 

http://localhost:8000/cgi-bin/test4.txt : 
  headers : server NaviServer/4.99.18 date {Thu, 28 Feb 2019 03:16:51 GMT} 
x-frame-options SAMEORIGIN x-content-type-options nosniff x-xss-protection {1; 
mode=block} referrer-policy strict-origin set-cookie 
{ad_session_id="210005%2c0%2c0%2c1551323811%20{133%201551325011%205D826D56888E7909B34A73FA2299141C5E681A0E}";
 Expires=Fri, 01-Jan-2035 01:00:00 GMT; Path=/; Discard; HttpOnly} connection 
close
  page : 
  file : 
  status : 200
  modified : 

http://localhost:8000/cgi-bin/test5.html : 
  headers : server NaviServer/4.99.18 date {Thu, 28 Feb 2019 03:16:51 GMT} 
x-frame-options SAMEORIGIN x-content-type-options nosniff x-xss-protection {1; 
mode=block} referrer-policy strict-origin set-cookie 
{ad_session_id="210006%2c0%2c0%2c1551323811%20{134%201551325011%2038F08ED3FADFC1410681FE5A34B8101B0FD194BE}";
 Expires=Fri, 01-Jan-2035 01:00:00 GMT; Path=/; Discard; HttpOnly} connection 
close
  page : 
  file : 
  status : 200
  modified : 

http://localhost:8000/test4.txt : 
  headers : server NaviServer/4.99.18 date {Thu, 28 Feb 2019 03:16:51 GMT} 
x-frame-options SAMEORIGIN x-content-type-options nosniff x-xss-protection {1; 
mode=block} referrer-policy strict-origin set-cookie 
{ad_session_id="210007%2c0%2c0%2c1551323811%20{129%201551325011%20921A7B089760E84FCCDE96D4057070B2705B87CC}";
 Expires=Fri, 01-Jan-2035 01:00:00 GMT; Path=/; Discard; HttpOnly} 
last-modified {Thu, 28 Feb 2019 03:04:56 GMT} content-type text/plain 
accept-ranges bytes content-length 22 connection close
  page : Hello World. Really!


  file : 
  status : 200
  modified : Thu, 28 Feb 2019 03:04:56 GMT

http://localhost:8000/test5.html : 
  headers : server NaviServer/4.99.18 date {Thu, 28 Feb 2019 03:16:51 GMT} 
x-frame-options SAMEORIGIN x-content-type-options nosniff x-xss-protection {1; 
mode=block} referrer-policy strict-origin set-cookie 
{ad_session_id="210008%2c0%2c0%2c1551323811%20{128%201551325011%208B6E0EE2521A4AC57006FCF7A3F6C437E26FAB54}";
 Expires=Fri, 01-Jan-2035 01:00:00 GMT; Path=/; Discard; HttpOnly} 
last-modified {Thu, 28 Feb 2019 03:05:48 GMT} content-type text/html 
accept-ranges bytes content-length 101 connection close
  page : 
  
    
  
  
    
Hello World
 file : status : 200 modified : Thu, 28 Feb 2019 03:05:48 GMT
 
kind regards,Ben
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to