Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::internal::net::http::HttpClientImpl Class Reference

HTTP/1.1 client based on ASIO. More...

#include <HttpClientImpl.h>

Inheritance diagram for sese::internal::net::http::HttpClientImpl:
sese::net::http::Requestable sese::io::InputStream sese::io::OutputStream sese::internal::net::http::HttpSSLClientImpl

Public Member Functions

 HttpClientImpl (const sese::net::IPAddress::Ptr &addr, sese::net::http::Request::Ptr req)
 
 ~HttpClientImpl () override
 
bool request () override
 
int64_t read (void *buf, size_t len) override
 
int64_t write (const void *buf, size_t len) override
 
int getLastError () override
 
std::string getLastErrorString () override
 
- Public Member Functions inherited from sese::net::http::Requestable
 ~Requestable () override=default
 
Request::PtrgetRequest ()
 
Response::PtrgetResponse ()
 
void setReadData (io::PeekableStream *read_data, size_t expect_total)
 
void setWriteData (io::OutputStream *write_data)
 
void setReadCallback (const ReadCallback &read_callback, size_t expect_total)
 
void setWriteCallback (const WriteCallback &write_callback)
 
void reset ()
 Reset body-related settings.
 
- Public Member Functions inherited from sese::io::InputStream
virtual ~InputStream () noexcept=default
 
- Public Member Functions inherited from sese::io::OutputStream
virtual ~OutputStream () noexcept=default
 
int64_t write (const std::string_view &buffer)
 
int64_t write (const text::StringView &buffer)
 
template<typename T >
int64_t write (std::vector< T > &buffer)
 
template<typename T , size_t N>
int64_t write (std::array< T, N > &buffer)
 

Protected Member Functions

virtual bool handshake ()
 
virtual bool shutdown ()
 
bool writeHeader (io::ByteBuilder &builder)
 
bool writeBodyByCallback ()
 
bool writeBodyByData ()
 
bool writeBodyByAuto ()
 
bool readBodyByCallback (size_t expect)
 
bool readBodyByData (size_t expect)
 

Protected Attributes

sese::net::IPAddress::Ptr address
 
sese::net::http::CookieMap::Ptr cookies
 
asio::error_code code {}
 
asio::io_context ioContext
 
asio::ip::tcp::socket socket
 
bool first = true
 
- Protected Attributes inherited from sese::net::http::Requestable
Request::Ptr req = nullptr
 
Response::Ptr resp = nullptr
 
size_t expect_total = 0
 
io::PeekableStreamread_data = nullptr
 
io::OutputStreamwrite_data = nullptr
 
WriteCallback write_callback
 
ReadCallback read_callback
 

Additional Inherited Members

- Public Types inherited from sese::net::http::Requestable
using WriteCallback = std::function<int64_t(const void *, size_t)>
 
using ReadCallback = std::function<int64_t(void *, size_t)>
 
- Public Types inherited from sese::io::InputStream
typedef std::shared_ptr< InputStreamPtr
 
- Public Types inherited from sese::io::OutputStream
typedef std::shared_ptr< OutputStreamPtr
 

Detailed Description

HTTP/1.1 client based on ASIO.

Constructor & Destructor Documentation

◆ HttpClientImpl()

◆ ~HttpClientImpl()

HttpClientImpl::~HttpClientImpl ( )
override

References socket.

Member Function Documentation

◆ getLastError()

int HttpClientImpl::getLastError ( )
overridevirtual

Get the last error

Returns
Last error

Implements sese::net::http::Requestable.

References code.

◆ getLastErrorString()

std::string HttpClientImpl::getLastErrorString ( )
overridevirtual

Get the last error string

Returns
Last error string

Implements sese::net::http::Requestable.

References code.

◆ handshake()

bool HttpClientImpl::handshake ( )
protectedvirtual

◆ read()

int64_t HttpClientImpl::read ( void * buf,
size_t len )
overridevirtual

◆ readBodyByCallback()

bool HttpClientImpl::readBodyByCallback ( size_t expect)
protected

◆ readBodyByData()

bool HttpClientImpl::readBodyByData ( size_t expect)
protected

◆ request()

◆ shutdown()

bool HttpClientImpl::shutdown ( )
protectedvirtual

Reimplemented in sese::internal::net::http::HttpSSLClientImpl.

Referenced by request().

◆ write()

int64_t HttpClientImpl::write ( const void * buf,
size_t len )
overridevirtual

◆ writeBodyByAuto()

◆ writeBodyByCallback()

bool HttpClientImpl::writeBodyByCallback ( )
protected

◆ writeBodyByData()

◆ writeHeader()

Member Data Documentation

◆ address

sese::net::IPAddress::Ptr sese::internal::net::http::HttpClientImpl::address
protected

Referenced by HttpClientImpl(), and request().

◆ code

◆ cookies

sese::net::http::CookieMap::Ptr sese::internal::net::http::HttpClientImpl::cookies
protected

Referenced by HttpClientImpl().

◆ first

bool sese::internal::net::http::HttpClientImpl::first = true
protected

Referenced by request().

◆ ioContext

asio::io_context sese::internal::net::http::HttpClientImpl::ioContext
protected

◆ socket

asio::ip::tcp::socket sese::internal::net::http::HttpClientImpl::socket
protected

Referenced by read(), request(), write(), and ~HttpClientImpl().


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