Oncaphillis::Ligh++pd

Mod::Hello my first completely useless ligh++pd module

Mod::Hello (or mod_hello) resides in the "test" directory of the ligh++pd project. It represents a complete useless module which is only there to illustrate the current abilities of ligh++pd. If you have successfully installed ligh++pd, it should have been placed as a loadable module in the standard module path for lighttpd.

To activate simply place the "mod_hello" line into the server.modules section of your lighttpd.conf file.

But be warned: Up until now Mod::hello simply takes over the server completely. It does not check the current URL/Path and will respond to every request in the same boring way.

So this is something you definitely do not want to try on your 24/7 shopping server where your customers are just rushing in to order their VIAGRA genera you've brought back from China.

mod_hello.cc might also server as a blueprint for your own module.


12.05.2008

Mod::Hello catches the handle_uri_clean event, pipes out a page including a form which allows the user to submit a string and a file. Data is read in as multipart/from-data and bounced back in raw format to the user. This serves as a demonstration of how the niftyLib:IO::device_streambuf encapsulates the request and response chunkqueue as well as the logging facility of lighttpd.

The read and write merely becomes:

    ...

    c.out() << lighttpd::TESTS::HELLO::header << std::endl 
            << "<h2>Hello 世界...</h2>"      << std::endl 
            << "<p><b>You gave me</b></p>"    << std::endl;

    std::string st;
    c.in() >> st;

    if(c.in()) {
      c.out() << "<p><b>-SOME-</b></p>" << st << std::endl;
      c.out() << c.in().rdbuf()  << std::endl; 
    } else {
      c.out() << "<p><b>-NONE-</b></p>" << std::endl;
    }
    
    c.out() << lighttpd::TESTS::HELLO::footer 
            << std::endl  
            << std::endl;
    
    s.log() << __DBG_INTRO
            << "mod_hello::handle_uri_clean::DONE " << c.in().eof() 
            << std::endl;

Thoughts...

  • Rudimentary usage of lighttpd::String and lighttpd::Hash in a class called lighttpd::Config. Which is really really ugly and in no way OO...

  • mod_hello::patch and mod_hello::set_defaults are butt ugly....

  • It would be preferable to change from server:out() reteuning a ref to lighttpd::istream(lighttpd::IO::Connection &).The resources per module slot are only allocated when actually needed and not initialized whenever a lighttpd::Connectuion class is instantaited.


screenshot1.png

The 'user-inteface' of Mod::Hello waiting for you use to type something and select a file to be transfered

screenshot2.png

Mod::Hello after data submission.


Generated by  doxygen
© 2008; Dr. Sebastian Kloska ( Oncaphillis )
Powered by: [?]