Sese Framework
2.3.0
A cross-platform framework
|
Base implementation of Http connection. More...
#include <HttpConnection.h>
Public Types | |
using | Ptr = std::shared_ptr<HttpConnection> |
Public Types inherited from sese::internal::service::http::Handleable | |
using | Ptr = std::shared_ptr<Handleable> |
Public Member Functions | |
Ptr | getPtr () |
HttpConnection (const std::shared_ptr< HttpServiceImpl > &service, asio::io_context &io_context, const sese::net::IPAddress::Ptr &addr) | |
virtual | ~HttpConnection ()=default |
void | reset () |
void | readHeader () |
void | readBody () |
void | handleRequest () |
void | writeHeader () |
void | writeBody () |
virtual void | writeBlock (const char *buffer, size_t length, const std::function< void(const asio::error_code &code)> &callback)=0 |
virtual void | asyncReadSome (const asio::mutable_buffers_1 &buffer, const std::function< void(const asio::error_code &error, std::size_t bytes_transferred)> &callback)=0 |
virtual void | checkKeepalive ()=0 |
virtual void | disponse () |
void | writeSingleRange () |
void | writeRanges () |
Public Attributes | |
asio::system_timer | timer |
size_t | expect_length |
size_t | real_length |
char | send_buffer [MTU_VALUE] {} |
bool | is0x0a = false |
iocp::IOBuf | io_buffer |
std::unique_ptr< iocp::IOBufNode > | node |
io::ByteBuilder | dynamic_buffer |
std::weak_ptr< HttpServiceImpl > | service |
Public Attributes inherited from sese::internal::service::http::Handleable | |
ConnType | conn_type = ConnType::NONE |
sese::net::http::Request | request |
sese::net::http::Response | response |
std::string | content_type = "application/x-" |
io::File::Ptr | file |
size_t | filesize = 0 |
std::vector< sese::net::http::Range > | ranges |
std::vector< sese::net::http::Range >::iterator | range_iterator = ranges.begin() |
sese::net::IPAddress::Ptr | remote_address {} |
bool | keepalive = false |
sese::StopWatch | stopwatch |
Base implementation of Http connection.
using sese::internal::service::http::HttpConnection::Ptr = std::shared_ptr<HttpConnection> |
sese::internal::service::http::HttpConnection::HttpConnection | ( | const std::shared_ptr< HttpServiceImpl > & | service, |
asio::io_context & | io_context, | ||
const sese::net::IPAddress::Ptr & | addr ) |
|
virtualdefault |
|
pure virtual |
Read function. This function will call the corresponding asio::async_read_some
buffer | asio::buffer |
callback | Callback function |
Implemented in sese::internal::service::http::HttpConnectionImpl, and sese::internal::service::http::HttpsConnectionImpl.
|
pure virtual |
Called when a request is completed to determine whether to disconnect the current connection
Implemented in sese::internal::service::http::HttpConnectionImpl, and sese::internal::service::http::HttpsConnectionImpl.
|
virtual |
Called before the connection is completely released to perform some cleanup of member variables
|
inline |
void sese::internal::service::http::HttpConnection::handleRequest | ( | ) |
References sese::net::http::HttpUtil::sendResponse().
void sese::internal::service::http::HttpConnection::readBody | ( | ) |
References sese::internal::service::http::FILTER, MTU_VALUE, and sese::streamMove().
void sese::internal::service::http::HttpConnection::readHeader | ( | ) |
References sese::internal::service::http::FILTER, MTU_VALUE, sese::streamMove(), and sese::toInteger().
void sese::internal::service::http::HttpConnection::reset | ( | ) |
References sese::internal::service::http::NONE.
|
pure virtual |
Write block function. This function ensures that all buffers are completely written, and the connection will be disconnected if an unexpected error occurs
buffer | Pointer to the buffer |
length | Size of the buffer |
callback | Completion callback function |
Implemented in sese::internal::service::http::HttpConnectionImpl, and sese::internal::service::http::HttpsConnectionImpl.
void sese::internal::service::http::HttpConnection::writeBody | ( | ) |
References MTU_VALUE.
void sese::internal::service::http::HttpConnection::writeHeader | ( | ) |
References MTU_VALUE.
void sese::internal::service::http::HttpConnection::writeRanges | ( | ) |
References sese::io::BEGIN, HTTPD_BOUNDARY, and MTU_VALUE.
void sese::internal::service::http::HttpConnection::writeSingleRange | ( | ) |
References MTU_VALUE.
io::ByteBuilder sese::internal::service::http::HttpConnection::dynamic_buffer |
size_t sese::internal::service::http::HttpConnection::expect_length |
iocp::IOBuf sese::internal::service::http::HttpConnection::io_buffer |
bool sese::internal::service::http::HttpConnection::is0x0a = false |
std::unique_ptr<iocp::IOBufNode> sese::internal::service::http::HttpConnection::node |
size_t sese::internal::service::http::HttpConnection::real_length |
char sese::internal::service::http::HttpConnection::send_buffer[MTU_VALUE] {} |
std::weak_ptr<HttpServiceImpl> sese::internal::service::http::HttpConnection::service |
asio::system_timer sese::internal::service::http::HttpConnection::timer |