Mike Dickey's picture

Following another busy week of coding, a new version of libpion is now available.

This release introduces support for module configuration files, which are simple text files supporting the following commands:

path <DIRECTORY> - adds DIRECTORY to the search path for HTTP modules
module <RESOURCE> <MODULE> - loads a dynamic HTTP MODULE bound to RESOURCE
option <RESOURCE> <NAME=VALUE> - sets option NAME to VALUE for the module bound to RESOURCE

As usual, blank lines and lines that begin with a hash character ('#') are ignored. I added this feature after some deliberation since I would really like to keep libpion away from any configuration-related tasks. IMHO, these should either be handled by the application or by another library that specializes in configuration. However, I needed a way to easily load multiple modules for testing, and decided to include this code in the library (versus PionModuleTest) in case it might be useful elsewhere (see HTTPServer::loadModuleConfig()).

Now included in the "tests" directory is a "testmodules.conf" and "testmodules.html" file. The "testmodules.conf" file includes all of the modules currently distributed with libpion. The "testmodules.html" file is bound to the "/" and "/index.html" resources, serving as a simple index for all of the modules loaded. The PionModuleTest application supports module configuration files using a "-c" option. To start up a fully-functional test server just run:

./PionModuleTest -c testmodules

Similar to how it automatically adds extensions to module files, libpion automatically adds a ".conf" extension to configuration files if the name cannot be found as-is.

This release adds support for parsing and setting cookies (version 1), and introduces a CookieModule that displays the client's cookies and allows you to delete or add new ones. When libpion is built with one of the supported logging libraries (log4cpp, log4cxx or log4cplus), a new LogModule will hook itself into the Root logger to cache the most recent log events and deliver these to a client when requested. The FileModule has also been updated to include a "file" option. This allows you to bind its resource to a particular file that is sent when requested. You can specify both a "directory" and a "file" option to create a directory resource that returns an index when just the directory is requested.

SSL & TLS encryption is now supported as well when libpion is built with the OpenSSL library. To include support for OpenSSL, you must pass a "--with-openssl" parameter to the "configure" script. To enable SSL support, simply call "TCPServer::setSSLFlag()". You will also need to configure the server (such as adding the private key) using the asio library. Configuration for SSL is managed via a boost::asio::ssl::context object (which is also typedef'd as TCPConnection::SSLContext). Each server has it's own SSLContext object to manage configuration, which can be accessed using the TCPServer::getSSLContext() method.

I'm planning to tag the first beta release soon, after adding a few more caching-related features to the FileModule and performing some general cleanup work. There are also some strange platform-specific bugs I know of, such as certain third-party libraries only working with certain platforms. I'll hope to fix or at least document these issues better in the next release.