More SSL stuff (still doesn't work :/).
This commit is contained in:
@@ -36,7 +36,47 @@ void Stream::flush() {}
|
||||
|
||||
mijin::Task<StreamError> Stream::c_readRaw(std::span<std::uint8_t> buffer, const ReadOptions& options, std::size_t* outBytesRead)
|
||||
{
|
||||
co_return readRaw(buffer, options, outBytesRead);
|
||||
std::size_t bytesToRead = buffer.size();
|
||||
if (bytesToRead == 0)
|
||||
{
|
||||
co_return StreamError::SUCCESS;
|
||||
}
|
||||
|
||||
while(true)
|
||||
{
|
||||
bool done = false;
|
||||
std::size_t bytesRead = 0;
|
||||
const StreamError error = readRaw(buffer.data() + buffer.size() - bytesToRead, bytesToRead,
|
||||
{.partial = true, .noBlock = true}, &bytesToRead);
|
||||
switch (error)
|
||||
{
|
||||
case StreamError::SUCCESS:
|
||||
bytesToRead -= bytesRead;
|
||||
if (options.partial || bytesToRead == 0)
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
case StreamError::WOULD_BLOCK:
|
||||
if (options.noBlock)
|
||||
{
|
||||
co_return StreamError::WOULD_BLOCK;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
co_return error;
|
||||
}
|
||||
if (done)
|
||||
{
|
||||
break;
|
||||
}
|
||||
co_await mijin::c_suspend();
|
||||
}
|
||||
if (outBytesRead != nullptr)
|
||||
{
|
||||
*outBytesRead = buffer.size() - bytesToRead;
|
||||
}
|
||||
co_return StreamError::SUCCESS;
|
||||
}
|
||||
|
||||
mijin::Task<StreamError> Stream::c_writeRaw(std::span<const std::uint8_t> buffer)
|
||||
|
||||
Reference in New Issue
Block a user