pion  5.0.6
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
pion::plugins::DiskFileSender Class Reference

#include <FileService.hpp>

Inherits enable_shared_from_this< DiskFileSender >, and noncopyable.

Public Member Functions

virtual ~DiskFileSender ()
 default virtual destructor
 
void send (void)
 
void set_logger (logger log_ptr)
 sets the logger to be used
 
logger get_logger (void)
 returns the logger currently in use
 

Static Public Member Functions

static boost::shared_ptr< DiskFileSendercreate (DiskFile &file, const pion::http::request_ptr &http_request_ptr, const pion::tcp::connection_ptr &tcp_conn, unsigned long max_chunk_size=0)
 

Protected Member Functions

 DiskFileSender (DiskFile &file, const pion::http::request_ptr &http_request_ptr, const pion::tcp::connection_ptr &tcp_conn, unsigned long max_chunk_size)
 
void handle_write (const boost::system::error_code &write_error, std::size_t bytes_written)
 

Protected Attributes

logger m_logger
 primary logging interface used by this class
 

Detailed Description

DiskFileSender: class used to send files to clients using HTTP responses

Definition at line 133 of file FileService.hpp.

Constructor & Destructor Documentation

§ DiskFileSender()

pion::plugins::DiskFileSender::DiskFileSender ( DiskFile file,
const pion::http::request_ptr &  http_request_ptr,
const pion::tcp::connection_ptr &  tcp_conn,
unsigned long  max_chunk_size 
)
protected

protected constructor restricts creation of objects (use create())

Parameters
filedisk file object that should be sent
http_request_ptrHTTP request that we are responding to
tcp_connTCP connection used to send the file
max_chunk_sizesets the maximum chunk size

Definition at line 813 of file FileService.cpp.

References pion::plugins::DiskFile::getFilePath(), pion::plugins::DiskFile::getLastModifiedString(), pion::plugins::DiskFile::getMimeType(), pion::plugins::DiskFile::hasFileContent(), and m_logger.

Member Function Documentation

§ create()

static boost::shared_ptr<DiskFileSender> pion::plugins::DiskFileSender::create ( DiskFile file,
const pion::http::request_ptr &  http_request_ptr,
const pion::tcp::connection_ptr &  tcp_conn,
unsigned long  max_chunk_size = 0 
)
inlinestatic

creates new DiskFileSender objects

Parameters
filedisk file object that should be sent
http_request_ptrHTTP request that we are responding to
tcp_connTCP connection used to send the file
max_chunk_sizesets the maximum chunk size (default=0, unlimited)

Definition at line 147 of file FileService.hpp.

Referenced by pion::plugins::FileService::operator()().

§ handle_write()

void pion::plugins::DiskFileSender::handle_write ( const boost::system::error_code &  write_error,
std::size_t  bytes_written 
)
protected

handler called after a send operation has completed

Parameters
write_errorerror status from the last write operation
bytes_writtennumber of bytes sent by the last write operation

Definition at line 939 of file FileService.cpp.

References pion::plugins::DiskFile::getFileSize(), m_logger, and send().

Referenced by send().

§ send()

void pion::plugins::DiskFileSender::send ( void  )

Begins sending the file to the client. Following a call to this function, it is not thread safe to use your reference to the DiskFileSender object.

Definition at line 842 of file FileService.cpp.

References pion::plugins::DiskFile::getFileContent(), pion::plugins::DiskFile::getFilePath(), pion::plugins::DiskFile::getFileSize(), handle_write(), pion::plugins::DiskFile::hasFileContent(), and m_logger.

Referenced by handle_write().


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