Sese Framework
2.3.0
A cross-platform framework
|
HTTP/1.1 client based on ASIO. More...
#include <HttpClientImpl.h>
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::Ptr & | getRequest () |
Response::Ptr & | getResponse () |
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::PeekableStream * | read_data = nullptr |
io::OutputStream * | write_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< InputStream > | Ptr |
Public Types inherited from sese::io::OutputStream | |
typedef std::shared_ptr< OutputStream > | Ptr |
HTTP/1.1 client based on ASIO.
HttpClientImpl::HttpClientImpl | ( | const sese::net::IPAddress::Ptr & | addr, |
sese::net::http::Request::Ptr | req ) |
|
override |
References socket.
|
overridevirtual |
|
overridevirtual |
Get the last error string
Implements sese::net::http::Requestable.
References code.
|
protectedvirtual |
Reimplemented in sese::internal::net::http::HttpSSLClientImpl.
Referenced by sese::internal::net::http::HttpSSLClientImpl::handshake(), and request().
|
overridevirtual |
Implements sese::net::http::Requestable.
Reimplemented in sese::internal::net::http::HttpSSLClientImpl.
References code, read(), and socket.
Referenced by read(), readBodyByCallback(), and readBodyByData().
|
protected |
References MTU_VALUE, read(), and sese::net::http::Requestable::write_callback.
Referenced by request().
|
protected |
References MTU_VALUE, read(), sese::io::OutputStream::write(), and sese::net::http::Requestable::write_data.
Referenced by request().
|
overridevirtual |
Execute request
Implements sese::net::http::Requestable.
References sese::net::http::CookieMap::add(), address, code, sese::internal::net::convert(), sese::net::http::Requestable::expect_total, first, sese::net::http::Header::get(), sese::net::http::Request::getBody(), sese::net::http::Header::getCookies(), sese::io::AbstractByteBuffer::getLength(), sese::net::http::RequestHeader::getType(), handshake(), sese::net::http::Requestable::read_callback, readBodyByCallback(), readBodyByData(), sese::net::http::HttpUtil::recvResponse(), sese::net::http::Requestable::req, sese::net::http::Requestable::reset(), sese::net::http::Requestable::resp, sese::net::http::HttpUtil::sendRequest(), sese::net::http::Header::set(), shutdown(), socket, sese::strcmpDoNotCase(), sese::net::http::Requestable::write_callback, writeBodyByAuto(), writeBodyByCallback(), writeBodyByData(), and writeHeader().
|
protectedvirtual |
Reimplemented in sese::internal::net::http::HttpSSLClientImpl.
Referenced by request().
|
overridevirtual |
Implements sese::net::http::Requestable.
Reimplemented in sese::internal::net::http::HttpSSLClientImpl.
Referenced by writeBodyByAuto(), writeBodyByCallback(), writeBodyByData(), and writeHeader().
|
protected |
References sese::net::http::Request::getBody(), MTU_VALUE, sese::io::AbstractByteBuffer::peek(), sese::net::http::Requestable::req, sese::io::AbstractByteBuffer::trunc(), and write().
Referenced by request().
|
protected |
References sese::net::http::Requestable::expect_total, MTU_VALUE, sese::net::http::Requestable::read_callback, and write().
Referenced by request().
|
protected |
|
protected |
References MTU_VALUE, sese::io::AbstractByteBuffer::peek(), sese::io::AbstractByteBuffer::resetPos(), sese::io::AbstractByteBuffer::trunc(), and write().
Referenced by request().
|
protected |
Referenced by HttpClientImpl(), and request().
|
protected |
Referenced by getLastError(), getLastErrorString(), sese::internal::net::http::HttpSSLClientImpl::handshake(), read(), sese::internal::net::http::HttpSSLClientImpl::read(), request(), sese::internal::net::http::HttpSSLClientImpl::shutdown(), write(), and sese::internal::net::http::HttpSSLClientImpl::write().
|
protected |
Referenced by HttpClientImpl().
|
protected |
Referenced by request().
|
protected |
|
protected |
Referenced by read(), request(), write(), and ~HttpClientImpl().