Menu

#81 custom adp extensions returning 200 text/plain

Bug
closed-fixed
nobody
None
3
2018-09-19
2018-09-16
David Fox
No

Could I get clarifcation if this is correct?
Using the default config if I use the parameter

ns_param map /*.ix
Which should enable use of the .ix extension.

Example is here: http://teddywarriors.tf/start.ix

the page displays as "text/plain", this happens if I use .html as an extension too
any advice? thanks

Discussion

  • gustafn

    gustafn - 2018-09-16

    in which section of the config file have you added this parameter?
    what is it that you want to achieve?

     
  • David Fox

    David Fox - 2018-09-16

    Under the normal /default/server/rdp section where the default entry is listed.

    To mimic the ability to do what ADP does but with a different file exentsion.
    Just looking to render the .ix exentsion as text/html, I even attempted to use the custom content type commands and those get overruled.

    ns_section "ns/server/default/adp" {
        ns_param    map                 /*.adp
        ns_param    map                 "/*.ix"
        ns_param    enableexpire        false    ;# default: false;
        ns_param   enabledebug         true    ;# default: false
        ns_param   enabletclpages      true     ;# default: false
    

    edit
    Nevermind, this can be closed. I just discovered the ns/mimetype section of the config. Regardless searching for it.
    Thanks again.

     

    Last edit: David Fox 2018-09-16
  • gustafn

    gustafn - 2018-09-17

    i asked, since there are several map configuration options for NaviServer. The map at the "adp" section of the config file is finally interpreted as a ns_register_adp command (registered for the HTTP methods GET, HEAD, and POST). I tried to reconstruct, what the problem might be when adding a mapping for /*.ix to the sample nsd-config file . When the following snipped is saved under t.adpor t.ix, the behavior is the same for both requests.

    <% ns_log notice "this is [ns_url2file [ns_conn url]]"; set x 1 %>
    <p>x = <%= [set x] %>
    

    If you want .adp like interpretation of these file, you should use the adp mapping

     
  • David Fox

    David Fox - 2018-09-17

    I even attempted with ns_register_adp and had the same results.
    <% %> tags were working correctly. however any HTML was pharsed as text/plain in the .ix file

    I fixed the issue by locating in the config and changing the following from text/plain.

    ns_section "ns/mimetypes" { 
    ns_param default text/html
    ns_param noextension text/plain
    }
    

    Since that change, everythings been working fine. I think.

    Edit:
    This is why I was never developer. Not sure if this is my fault, which i expect it is.
    As I am using ns_register_proc - I create a TCL file with these defined in the root directory TCL library which should in theory be loaded on server startup. But doesn't.

    However, after registering the ns_register_proc.
    It works. But after several hits/multiple refreshes, I get "Invalid command name "xyz" and the page fails.

    The context I'm using this is with iframes to display the "GET" of the ns_register_proc

    ns_register_proc GET /ix/:: askFile
    displays html form for upload from askFile.tcl

    If I hit F5 a few times, it then kind of crashes, page is active but the proc fails with the error "Invalid command "askFile"

    edit: sorry for the head-ache.
    Feel free to close this as whatever problems I was having have cleared up.

    I've uploaded what I am trying to do onto bitbucket.
    https://bitbucket.org/mookiefox/pixc/src/master/tunnel/

     

    Last edit: David Fox 2018-09-18
  • gustafn

    gustafn - 2018-09-19

    The problem you are experiencing is probably due to the fact that you are using source to load Tcl functions into the current connection thread, but not into the other connection threads waiting for something to do. By hitting a few times reload, you get a different connection thread without these procs, and Tcl complains.

    You should get familiar with pre-loaded procs (see https://naviserver.sourceforge.io/n/manual/files/tcl-libraries.html). At startup time, NaviServer collects the procs from the mentioned library files into a so-called blueprint, which is provided to all connection threads (and scheduled threads, etc.). With this, there is no need to use source during a request. The blueprints can be dynamically updated via ns_eval.

     
  • David Fox

    David Fox - 2018-09-19

    Thank you. Got it all working and now no issues.

    Regards,
    David

     
  • gustafn

    gustafn - 2018-09-19

    Great!

     
  • gustafn

    gustafn - 2018-09-19
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB