pion
5.0.6
|
#include <FileService.hpp>
Inherits pion::http::plugin_service.
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 | |
![]() | |
plugin_service (void) | |
default constructor | |
virtual | ~plugin_service () |
virtual destructor | |
void | set_resource (const std::string &str) |
sets the URI stem or resource that is bound to the web service | |
const std::string & | get_resource (void) const |
returns the URI stem or resource that is bound to the web service | |
std::string | get_relative_resource (const std::string &resource_requested) const |
returns the path to the resource requested, relative to the web service's location | |
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 | |
FileService: web service that serves regular files
Definition at line 235 of file FileService.hpp.
|
protected |
adds a single file to the cache
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 |
Definition at line 665 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().
|
staticprotected |
searches for a MIME type that matches a file
file_name | name of the file to search for |
Definition at line 716 of file FileService.cpp.
Referenced by addCacheEntry(), and operator()().
|
protected |
adds all files within a directory to the cache
dir_path | the directory to scan (sub-directories are included) |
Definition at line 625 of file FileService.cpp.
References addCacheEntry(), pion::http::plugin_service::get_resource(), and m_logger.
Referenced by start().
|
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().