Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::internal::service::http::HttpConnection Struct Referenceabstract

Base implementation of Http connection. More...

#include <HttpConnection.h>

Inheritance diagram for sese::internal::service::http::HttpConnection:
sese::internal::service::http::Handleable sese::internal::service::http::HttpConnectionImpl sese::internal::service::http::HttpsConnectionImpl

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::IOBufNodenode
 
io::ByteBuilder dynamic_buffer
 
std::weak_ptr< HttpServiceImplservice
 
- 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::Rangeranges
 
std::vector< sese::net::http::Range >::iterator range_iterator = ranges.begin()
 
sese::net::IPAddress::Ptr remote_address {}
 
bool keepalive = false
 
sese::StopWatch stopwatch
 

Detailed Description

Base implementation of Http connection.

Member Typedef Documentation

◆ Ptr

Constructor & Destructor Documentation

◆ HttpConnection()

sese::internal::service::http::HttpConnection::HttpConnection ( const std::shared_ptr< HttpServiceImpl > & service,
asio::io_context & io_context,
const sese::net::IPAddress::Ptr & addr )

◆ ~HttpConnection()

virtual sese::internal::service::http::HttpConnection::~HttpConnection ( )
virtualdefault

Member Function Documentation

◆ asyncReadSome()

virtual void sese::internal::service::http::HttpConnection::asyncReadSome ( const asio::mutable_buffers_1 & buffer,
const std::function< void(const asio::error_code &error, std::size_t bytes_transferred)> & callback )
pure virtual

Read function. This function will call the corresponding asio::async_read_some

Parameters
bufferasio::buffer
callbackCallback function

Implemented in sese::internal::service::http::HttpConnectionImpl, and sese::internal::service::http::HttpsConnectionImpl.

◆ checkKeepalive()

virtual void sese::internal::service::http::HttpConnection::checkKeepalive ( )
pure virtual

Called when a request is completed to determine whether to disconnect the current connection

Note
This function must be implemented

Implemented in sese::internal::service::http::HttpConnectionImpl, and sese::internal::service::http::HttpsConnectionImpl.

◆ disponse()

void sese::internal::service::http::HttpConnection::disponse ( )
virtual

Called before the connection is completely released to perform some cleanup of member variables

Note
This function is optional to implement

◆ getPtr()

Ptr sese::internal::service::http::HttpConnection::getPtr ( )
inline

◆ handleRequest()

void sese::internal::service::http::HttpConnection::handleRequest ( )

◆ readBody()

void sese::internal::service::http::HttpConnection::readBody ( )

◆ readHeader()

void sese::internal::service::http::HttpConnection::readHeader ( )

◆ reset()

void sese::internal::service::http::HttpConnection::reset ( )

◆ writeBlock()

virtual void sese::internal::service::http::HttpConnection::writeBlock ( const char * buffer,
size_t length,
const std::function< void(const asio::error_code &code)> & callback )
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

Note
This function must be implemented
Parameters
bufferPointer to the buffer
lengthSize of the buffer
callbackCompletion callback function

Implemented in sese::internal::service::http::HttpConnectionImpl, and sese::internal::service::http::HttpsConnectionImpl.

◆ writeBody()

void sese::internal::service::http::HttpConnection::writeBody ( )

References MTU_VALUE.

◆ writeHeader()

void sese::internal::service::http::HttpConnection::writeHeader ( )

References MTU_VALUE.

◆ writeRanges()

void sese::internal::service::http::HttpConnection::writeRanges ( )

◆ writeSingleRange()

void sese::internal::service::http::HttpConnection::writeSingleRange ( )

References MTU_VALUE.

Member Data Documentation

◆ dynamic_buffer

io::ByteBuilder sese::internal::service::http::HttpConnection::dynamic_buffer

◆ expect_length

size_t sese::internal::service::http::HttpConnection::expect_length

◆ io_buffer

iocp::IOBuf sese::internal::service::http::HttpConnection::io_buffer

◆ is0x0a

bool sese::internal::service::http::HttpConnection::is0x0a = false

◆ node

std::unique_ptr<iocp::IOBufNode> sese::internal::service::http::HttpConnection::node

◆ real_length

size_t sese::internal::service::http::HttpConnection::real_length

◆ send_buffer

char sese::internal::service::http::HttpConnection::send_buffer[MTU_VALUE] {}

◆ service

std::weak_ptr<HttpServiceImpl> sese::internal::service::http::HttpConnection::service

◆ timer

asio::system_timer sese::internal::service::http::HttpConnection::timer

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