mirror of
https://github.com/oatpp/oatpp.git
synced 2025-03-13 18:06:47 +08:00
fix to Input and Output stream interface
This commit is contained in:
parent
204ab1367b
commit
4d2487b4ff
@ -38,6 +38,11 @@ namespace oatpp { namespace data{ namespace stream {
|
||||
class OutputStream {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default virtual destructor.
|
||||
*/
|
||||
virtual ~OutputStream() = default;
|
||||
|
||||
/**
|
||||
* Write data to stream up to count bytes, and return number of bytes actually written
|
||||
* It is a legal case if return result < count. Caller should handle this!
|
||||
@ -122,6 +127,11 @@ public:
|
||||
class InputStream {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default virtual destructor.
|
||||
*/
|
||||
virtual ~InputStream() = default;
|
||||
|
||||
/**
|
||||
* Read data from stream up to count bytes, and return number of bytes actually read
|
||||
* It is a legal case if return result < count. Caller should handle this!
|
||||
|
@ -79,10 +79,14 @@ oatpp::async::Action ConnectionProvider::getConnectionAsync(oatpp::async::Abstra
|
||||
|
||||
Action obtainSocket() {
|
||||
auto socket = m_submission->getSocketNonBlocking();
|
||||
if(socket && !m_submission->isPending()) {
|
||||
socket->setNonBlocking(true);
|
||||
socket->setMaxAvailableToReadWrtie(m_maxAvailableToRead, m_maxAvailableToWrite);
|
||||
return _return(socket);
|
||||
if(!m_submission->isPending()) {
|
||||
if(socket) {
|
||||
socket->setNonBlocking(true);
|
||||
socket->setMaxAvailableToReadWrtie(m_maxAvailableToRead, m_maxAvailableToWrite);
|
||||
return _return(socket);
|
||||
} else {
|
||||
return error<Error>("[oatpp::network::virtual_::client::ConnectionProvider::getConnectionAsync()]: Error. Can't connect.");
|
||||
}
|
||||
}
|
||||
return waitRetry();
|
||||
}
|
||||
|
@ -133,8 +133,11 @@ public:
|
||||
}
|
||||
|
||||
Action handleError(const std::shared_ptr<const Error>& error) override {
|
||||
if(error) {
|
||||
OATPP_LOGD("[FullAsyncClientTest::ClientCoroutine_getRootAsync::handleError()]", "Error. %s", error->what());
|
||||
if(error->is<oatpp::data::AsyncIOError>()) {
|
||||
auto e = static_cast<const oatpp::data::AsyncIOError*>(error.get());
|
||||
OATPP_LOGD("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "AsyncIOError. %s, %d", e->what(), e->getCode());
|
||||
} else {
|
||||
OATPP_LOGD("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "Error. %s", error->what());
|
||||
}
|
||||
return Action::TYPE_ERROR;
|
||||
}
|
||||
@ -177,7 +180,12 @@ public:
|
||||
|
||||
Action handleError(const std::shared_ptr<const Error>& error) override {
|
||||
if(error) {
|
||||
OATPP_LOGD("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "Error. %s", error->what());
|
||||
if(error->is<oatpp::data::AsyncIOError>()) {
|
||||
auto e = static_cast<const oatpp::data::AsyncIOError*>(error.get());
|
||||
OATPP_LOGD("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "AsyncIOError. %s, %d", e->what(), e->getCode());
|
||||
} else {
|
||||
OATPP_LOGD("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "Error. %s", error->what());
|
||||
}
|
||||
}
|
||||
return Action::TYPE_ERROR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user