Added HTTPClient type.
This commit is contained in:
@@ -265,16 +265,25 @@ mijin::Task<StreamError> TCPStream::c_readRaw(std::span<std::uint8_t> buffer, co
|
||||
MIJIN_ASSERT(isOpen(), "Socket is not open.");
|
||||
setAsync(true);
|
||||
|
||||
if (buffer.empty())
|
||||
{
|
||||
co_return StreamError::SUCCESS;
|
||||
}
|
||||
|
||||
while(true)
|
||||
{
|
||||
const long bytesRead = osRecv(handle_, buffer, readFlags(options));
|
||||
if (bytesRead >= 0)
|
||||
if (bytesRead > 0)
|
||||
{
|
||||
if (outBytesRead != nullptr) {
|
||||
*outBytesRead = static_cast<std::size_t>(bytesRead);
|
||||
}
|
||||
co_return StreamError::SUCCESS;
|
||||
}
|
||||
else if (bytesRead == 0)
|
||||
{
|
||||
co_return StreamError::CONNECTION_CLOSED;
|
||||
}
|
||||
else if (errno != EAGAIN)
|
||||
{
|
||||
co_return translateErrno();
|
||||
@@ -286,14 +295,25 @@ mijin::Task<StreamError> TCPStream::c_readRaw(std::span<std::uint8_t> buffer, co
|
||||
mijin::Task<StreamError> TCPStream::c_writeRaw(std::span<const std::uint8_t> buffer)
|
||||
{
|
||||
MIJIN_ASSERT(isOpen(), "Socket is not open.");
|
||||
|
||||
if (buffer.empty())
|
||||
{
|
||||
co_return StreamError::SUCCESS;
|
||||
}
|
||||
|
||||
setAsync(true);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (osSend(handle_, buffer, 0) >= 0)
|
||||
const long bytesSent = osSend(handle_, buffer, 0);
|
||||
if (bytesSent == static_cast<long>(buffer.size()))
|
||||
{
|
||||
co_return StreamError::SUCCESS;
|
||||
}
|
||||
else if (bytesSent == 0)
|
||||
{
|
||||
co_return StreamError::CONNECTION_CLOSED;
|
||||
}
|
||||
else if (errno != EAGAIN)
|
||||
{
|
||||
co_return translateErrno();
|
||||
|
||||
Reference in New Issue
Block a user