This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HTTP Web server dynamic file generation without CGI extension

Firstly, can I say thanks for the excellent HHTP Server example at  This (and Appendix E of the NCK guide) got me started with TI-RTOS and gave a great explanation of how to serve a file from memory, SD card or via CGI.

I come from a web development background and would like a little more freedom to create a web server using REST style APIs. I'd like a URL something like /mytiva/workshop/light/on to call a CGI method. Hwever, I've found that using something like

efs_createfile("/mytiva/workshop/light/on", 0, (UINT8 *) &myMethod);

just returns a zero byte file and doesn't actually call myMethod unless the path ends in ".cgi".

Is there any way to have a little more flexibility over how URLs are handled? I noticed in the NDK guide that the HTTP server uses the function efs_filecheck to check whether the file represents a function call. Could I perhaps override the built-in function?

Thanks.

  • Hi Fred,

    You're correct that the efs_filecheck function determines whether or not the input should run your method. Based on the NDK efs.c file within the int 

    efs_filecheck(char *name, char *user, char *pass, int *prealm)

    function:

    So at the moment you must specify the file extension as .cgi in order to have it call your function.

    Best,

    Alexander

  • Thanks. Not sure why I didn't find that. Maybe because the header file is osif.h I had assumed a source file with the name osif.c rather than efs.c.

    I think I'll try changing that and building a custom version that better suits my needs. This seems to be documented well in the TI-RTOS user guide (section 8.1). I hope it'll be as easy as it looks.
  • I thought I 'd give an update in case anyone stumbles over this post. Customizing TI-RTOS was pretty easy and worked well. The only gotcha was that tirtos.mak is set to compile with ARM compiler version ti-cgt-arm_5.2.5. Is this even available any more? It  didn't like the current STS compiler and seemed to need an LTS version. I used ti-cgt-arm_15.12.1.LTS.

    Other than this it was as described in the TI-RTOS User Guide.

  • Hi Fred,

    Just wanted to give you a heads up, ti-cgt-arm_5.2.5 is still available and is currently bundled with an ARM installation of CCS.

    Best,
    Alexander
  • You can very easily change the "dot-CGI"-only behavior (and others) of the http server by implementing your own versions of the efs* functions, including efs_filecheck (the function that restricts application server behavior to "Dot-CGI" files.  Copy the sources in /ndk-blah-directories/efs.c into your own source file in your local project, and alter them as you like.  You might need to add a compiler include path to get the right headers, and add a few explicit casts from void*, but it will work.  The sources are commented and clear about the ability of the application programmer to change the behavior.  The linker will link your local implementations in preference to the ones in the NDK libs.  Perhaps you can put the same into your own static library and if it is higher in the linker list, they will also be linked before the ones in the NDK libs - I haven't tried that yet, but will.

    If you're writing C++ code, make sure you specify "C" linkage.

    This approach is laid out in Todd Mullanix's very useful HTTP server example: processors.wiki.ti.com/.../File:TIRTOS_httpServer.zip

    It may be covered somewhere else in the documentation, but that's where I found it.

    It may