We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all, I'm using RL-TCPNet HTTP embedded web server for developing a data publishing application. The "site" requires static (htm) and dynamic (cgi) pages, together with resources like images, javascripts and css.
I can successfully deploy the site by compiling-in pages with FCARM and the resulting web.c module.
Project contraints force me to explore a different approach now. I need to strip off the pages from the application code and store them on an external flash device.
I implemented a minimal access to pages stored on flash by redefining the interfaces for http_fopen(), http_fclose() and http_fread() in http_uif.c module and including it in the project (while removing web.c). It seems to work ok for static pages and images, but, as far as I can see, these functions are not called by the http server when client requires a cgi file and this kind of resources are still looked for as statically linked to the code, resulting in a HTTP 404 error to the client.
Is there any configuration I miss to make http server ALWAYS use my file interface functions? If not, does anybody there have an idea how I can keep storing web resources in flash and make the http server access them. At moment RL-FlashFS is preferrably not an option.
TIA Andrea
You do realize that dynamic pages are generated by execution some code? On a "real" web server, you have an OS that can start the cgi program and pipe the output back into the web server.
In an embedded environment, you haven't that. You have to figure out a way to either compile a script parser into your application, and create the cgi pages using a script language, or figure out how to distribute the cgi pages as some form of runnable object code that can be loaded into memory and run through a function pointer to their load address. Basically, you have to implement a "dll" interface. If the cgi code can't use relative addressing to support loading at any address, you must either load them to a fixed address (only one module loaded at a time to that address) or teach your application how to relocate the contents of the cgi.
The second alternative requires that you trust the writer of the cgi pages, since any error in them will bring down the web server application and require a watchdog reboot.
I would definitely recommend that you look again at the requirements for cgi pages. Do they have to be general, or can you use scripting and replace macros together with static template files? Going fully dynamic may be really expensive...
Hi Per, thanks for your reply. I probably did not clarified my problem well. I'm using Keil RL-TcpNet embedded http server which support a cgi scripting language: this is parsed and interpreted by the server itself. I implemented the dynamic code triggered by the cgi scripts in C routines (only the very-dynamic part of it). I don't want to cut off this part from the code, but the scripts files themself.
My question was: is it possible to store .cgi scripts, written for the Keil embedded http server, anywhere else outside the application code itself? This is not an upgradability requirement, but just a need to save some bytes for the code. I already store other pages and objects on the external flash, and just get confused to see that the http server is not accessing cgi scripts as it does for i.e. html files.
Regards
I don't use that web server myself, so I can't really answer that question. You have to check what source code you have available for the web server, and based on that check if you can override the information somewhere.
Hi Andrea, what you have already figured out is correct, HTTP server works this way. All of the web files except cgi scripts may be located in external Flash or SD/MMC memory card.
Web server checks first the external File System for the file (using the http_uif.c interface). If the file is not found there, the web server checks the internal virtual ROM file system for the file(compiled into the code). And finally if the file still not found, sends HTTP 404 error to the client.
Because the cgi scripts and the HTTP_CGI.c interface are tightly coupled (the cgi script command has a c-function behind in HTTP_CGI.c module), we have followed the idea that cgi files should not be located on other drives.
You can not locate cgi files anywhere else but the internal virtual ROM file system. However to reduce the size of the cgi files, you may want to extract the static header and footer into the separate (inc) file, which may be located on external drive. (see the HTTP_Demo example page TCP).
Hello Franc, thank you for confirming this. I'will keep .cgi in virtual ROM filesystem and try to optimize using inc files.
Regards.
Are there any plans in changing this. We have bought the Keil compiler and library and need to place a 'complete' website on an SD card. This includes the CGI scripts.
We are now not able to do this, despite the 7000 EURO we have spent.