pion::plugins::FileService Class Reference

#include <FileService.hpp>

Inherits pion::http::plugin_service.

List of all members.

Public Member Functions

virtual void set_option (const std::string &name, const std::string &value)
virtual void operator() (pion::http::request_ptr &http_request_ptr, pion::tcp::connection_ptr &tcp_conn)
 handles requests for FileService
virtual void start (void)
 called when the web service's server is starting
virtual void stop (void)
 called when the web service's server is stopping
void set_logger (logger log_ptr)
 sets the logger to be used
logger get_logger (void)
 returns the logger currently in use

Protected Types

typedef PION_HASH_MAP
< std::string, DiskFile,
PION_HASH_STRING > 
CacheMap
 data type for map of file names to cache entries
typedef PION_HASH_MAP
< std::string, std::string,
PION_HASH_STRING > 
MIMETypeMap
 data type for map of file extensions to MIME types

Protected Member Functions

void scanDirectory (const boost::filesystem::path &dir_path)
std::pair< CacheMap::iterator,
bool > 
addCacheEntry (const std::string &relative_path, const boost::filesystem::path &file_path, const bool placeholder)
void sendNotFoundResponse (pion::http::request_ptr &http_request_ptr, pion::tcp::connection_ptr &tcp_conn)

Static Protected Member Functions

static std::string findMIMEType (const std::string &file_name)

Protected Attributes

logger m_logger
 primary logging interface used by this class

Detailed Description

FileService: web service that serves regular files

Definition at line 235 of file FileService.hpp.


Member Function Documentation

std::pair< FileService::CacheMap::iterator, bool > pion::plugins::FileService::addCacheEntry ( const std::string &  relative_path,
const boost::filesystem::path &  file_path,
const bool  placeholder 
) [protected]

adds a single file to the cache

Parameters:
relative_path path for the file relative to the root directory
file_path actual path to the file on disk
placeholder if true, the file's contents are not cached
Returns:
std::pair<CacheMap::iterator, bool> if an entry is added to the cache, second will be true and first will point to the new entry

Definition at line 660 of file FileService.cpp.

References findMIMEType(), pion::plugins::DiskFile::getFileSize(), m_logger, pion::plugins::DiskFile::read(), and pion::plugins::DiskFile::update().

Referenced by scanDirectory(), and start().

std::string pion::plugins::FileService::findMIMEType ( const std::string &  file_name  )  [static, protected]

searches for a MIME type that matches a file

Parameters:
file_name name of the file to search for
Returns:
MIME type corresponding with the file, or DEFAULT_MIME_TYPE if none found

Definition at line 711 of file FileService.cpp.

Referenced by addCacheEntry(), and operator()().

void pion::plugins::FileService::scanDirectory ( const boost::filesystem::path &  dir_path  )  [protected]

adds all files within a directory to the cache

Parameters:
dir_path the directory to scan (sub-directories are included)

Definition at line 620 of file FileService.cpp.

References addCacheEntry(), pion::http::plugin_service::get_resource(), and m_logger.

Referenced by start().

void pion::plugins::FileService::set_option ( const std::string &  name,
const std::string &  value 
) [virtual]

configuration options supported by FileService:

directory: all files within the directory will be made available file: cache: scan: max_chunk_size: writable:

Reimplemented from pion::http::plugin_service.

Definition at line 53 of file FileService.cpp.

References pion::plugin::check_cygwin_path().


The documentation for this class was generated from the following files:

Generated on 16 Sep 2013 for pion by  doxygen 1.6.1