Re: [Cppcms-users] Loop through files when responding
Brought to you by:
artyom-beilis
From: Artyom B. <art...@ya...> - 2011-12-03 20:36:26
|
>________________________________ > From: Marcel Hellwig <ke...@co...> >To: cpp...@li... >Sent: Saturday, December 3, 2011 5:32 PM >Subject: [Cppcms-users] Loop through files when responding > >Greetings, > >I am trying to loop through .css, .js, .png or everything else to the >browser. >At this time I dispatch all incoming transfers that are redirecting to >/media to a class that will read the content of the asked file and give >out the content via response(). > >But this is not very comfort, because i have to set the MIME type maually. > >I read and found the file_server config node, but there is an >exclamation, that you shouldn't use it in production enviroment. I >understand this, but then tell me how to redirect all the files that are >in a special folder to the browser with the right mime type. >Or should I really set the MIME type manually? I mean this won't be a >big problem, but there has to be a better solution ;) > >Regards, > >Marcel Hellwig >Hamburg, Germany > Two points: a) Why don't you use actual web server to serve the files? Just use Lighttpd, Apache or Nginx connected to CppCMS with FastCGI and let the web server to handle static files (they are very good in it) I assume you are familiar with these pages: http://art-blog.no-ip.info/wikipp/en/page/cppcms_1x_tut_web_server_config http://art-blog.no-ip.info/wikipp/en/page/run_application_web_server_root b) Starting from CppCMS 0.99.10 the internal web server you can use production use. Also it is mostly intended to be used in embedded environment and not for high traffic web sites. I'd strongly recommend give a web server a job of serving files rather then doing it manually. Especially when serving files involves many important security issues that should be handled properly. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.sf.net/ CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ |