pion-net
4.0.9
|
#include <HTTPWriter.hpp>
Inherits noncopyable.
Inherited by pion::net::HTTPRequestWriter, and pion::net::HTTPResponseWriter.
Classes | |
class | BinaryCache |
used to cache binary data included within the payload content | |
Public Member Functions | |
virtual | ~HTTPWriter () |
default destructor | |
void | clear (void) |
clears out all of the memory buffers used to cache payload content data | |
template<typename T > | |
void | write (const T &data) |
void | write (const void *data, size_t length) |
void | writeNoCopy (const std::string &data) |
void | writeNoCopy (void *data, size_t length) |
void | send (void) |
template<typename SendHandler > | |
void | send (SendHandler send_handler) |
template<typename SendHandler > | |
void | sendChunk (SendHandler send_handler) |
template<typename SendHandler > | |
void | sendFinalChunk (SendHandler send_handler) |
void | sendFinalChunk (void) |
TCPConnectionPtr & | getTCPConnection (void) |
returns a shared pointer to the TCP connection | |
size_t | getContentLength (void) const |
returns the length of the payload content (in bytes) | |
void | supportsChunkedMessages (bool b) |
sets whether or not the client supports chunked messages | |
bool | supportsChunkedMessages () const |
returns true if the client supports chunked messages | |
bool | sendingChunkedMessage () const |
returns true if we are sending a chunked message to the client | |
void | setLogger (PionLogger log_ptr) |
sets the logger to be used | |
PionLogger | getLogger (void) |
returns the logger currently in use | |
Protected Types | |
typedef boost::function1< void, const boost::system::error_code & > | FinishedHandler |
function called after the HTTP message has been sent | |
typedef boost::function2< void, const boost::system::error_code &, std::size_t > | WriteHandler |
data type for a function that handles write operations | |
Protected Member Functions | |
HTTPWriter (TCPConnectionPtr &tcp_conn, FinishedHandler handler) | |
virtual void | handleWrite (const boost::system::error_code &write_error, std::size_t bytes_written)=0 |
virtual void | prepareBuffersForSend (HTTPMessage::WriteBuffers &write_buffers)=0 |
virtual WriteHandler | bindToWriteHandler (void)=0 |
returns a function bound to HTTPWriter::handleWrite() | |
void | finishedWriting (const boost::system::error_code &ec) |
called after we have finished sending the HTTP message |
HTTPWriter: used to asynchronously send HTTP messages
Definition at line 33 of file HTTPWriter.hpp.
pion::net::HTTPWriter::HTTPWriter | ( | TCPConnectionPtr & | tcp_conn, |
FinishedHandler | handler | ||
) | [inline, protected] |
protected constructor: only derived classes may create objects
tcp_conn | TCP connection used to send the message |
handler | function called after the request has been sent |
Definition at line 51 of file HTTPWriter.hpp.
virtual void pion::net::HTTPWriter::handleWrite | ( | const boost::system::error_code & | write_error, |
std::size_t | bytes_written | ||
) | [protected, pure virtual] |
called after the message is sent
write_error | error status from the last write operation |
bytes_written | number of bytes sent by the last write operation |
Implemented in pion::net::HTTPResponseWriter, and pion::net::HTTPRequestWriter.
virtual void pion::net::HTTPWriter::prepareBuffersForSend | ( | HTTPMessage::WriteBuffers & | write_buffers | ) | [protected, pure virtual] |
initializes a vector of write buffers with the HTTP message information
write_buffers | vector of write buffers to initialize |
Implemented in pion::net::HTTPResponseWriter, and pion::net::HTTPRequestWriter.
void pion::net::HTTPWriter::send | ( | void | ) | [inline] |
Sends all data buffered as a single HTTP message (without chunking). Following a call to this function, it is not thread safe to use your reference to the HTTPWriter object.
Definition at line 160 of file HTTPWriter.hpp.
void pion::net::HTTPWriter::send | ( | SendHandler | send_handler | ) | [inline] |
Sends all data buffered as a single HTTP message (without chunking). Following a call to this function, it is not thread safe to use your reference to the HTTPWriter object until the send_handler has been called.
send_handler | function that is called after the message has been sent to the client. Your callback function must end the connection by calling TCPConnection::finish(). |
Definition at line 174 of file HTTPWriter.hpp.
void pion::net::HTTPWriter::sendChunk | ( | SendHandler | send_handler | ) | [inline] |
Sends all data buffered as a single HTTP chunk. Following a call to this function, it is not thread safe to use your reference to the HTTPWriter object until the send_handler has been called.
send_handler | function that is called after the chunk has been sent to the client. Your callback function must end by calling one of sendChunk() or sendFinalChunk(). Also, be sure to clear() the writer before writing data to it. |
Definition at line 189 of file HTTPWriter.hpp.
void pion::net::HTTPWriter::sendFinalChunk | ( | SendHandler | send_handler | ) | [inline] |
Sends all data buffered (if any) and also sends the final HTTP chunk. This function (either overloaded version) must be called following any calls to sendChunk(). Following a call to this function, it is not thread safe to use your reference to the HTTPWriter object until the send_handler has been called.
send_handler | function that is called after the message has been sent to the client. Your callback function must end the connection by calling TCPConnection::finish(). |
Definition at line 212 of file HTTPWriter.hpp.
void pion::net::HTTPWriter::sendFinalChunk | ( | void | ) | [inline] |
Sends all data buffered (if any) and also sends the final HTTP chunk. This function (either overloaded version) must be called following any calls to sendChunk(). Following a call to this function, it is not thread safe to use your reference to the HTTPWriter object.
Definition at line 224 of file HTTPWriter.hpp.
void pion::net::HTTPWriter::write | ( | const T & | data | ) | [inline] |
write text (non-binary) payload content
data | the data to append to the payload content |
Definition at line 105 of file HTTPWriter.hpp.
void pion::net::HTTPWriter::write | ( | const void * | data, |
size_t | length | ||
) | [inline] |
write binary payload content
data | points to the binary data to append to the payload content |
length | the length, in bytes, of the binary data |
Definition at line 116 of file HTTPWriter.hpp.
void pion::net::HTTPWriter::writeNoCopy | ( | const std::string & | data | ) | [inline] |
write text (non-binary) payload content; the data written is not copied, and therefore must persist until the message has finished sending
data | the data to append to the payload content |
Definition at line 131 of file HTTPWriter.hpp.
Referenced by pion::net::HTTPRequestWriter::HTTPRequestWriter().
void pion::net::HTTPWriter::writeNoCopy | ( | void * | data, |
size_t | length | ||
) | [inline] |
write binary payload content; the data written is not copied, and therefore must persist until the message has finished sending
data | points to the binary data to append to the payload content |
length | the length, in bytes, of the binary data |
Definition at line 146 of file HTTPWriter.hpp.