mirror of
https://github.com/oatpp/oatpp.git
synced 2025-02-11 17:20:52 +08:00
Merge pull request #57 from oatpp/virtual_async_io_fix
Virtual async io fix
This commit is contained in:
commit
398ff27b4a
@ -310,6 +310,11 @@ oatpp::async::Action FIFOBuffer::flushToStreamAsync(oatpp::async::AbstractCorout
|
||||
{}
|
||||
|
||||
Action act() override {
|
||||
|
||||
if(!m_fifo->m_canRead) {
|
||||
return finish();
|
||||
}
|
||||
|
||||
if(m_fifo->m_readPosition < m_fifo->m_writePosition) {
|
||||
|
||||
m_data1 = &m_fifo->m_buffer[m_fifo->m_readPosition];
|
||||
|
@ -164,6 +164,7 @@ oatpp::async::Action HttpRequestExecutor::executeAsync(oatpp::async::AbstractCor
|
||||
std::shared_ptr<Body> m_body;
|
||||
std::shared_ptr<const oatpp::web::protocol::http::incoming::BodyDecoder> m_bodyDecoder;
|
||||
std::shared_ptr<ConnectionHandle> m_connectionHandle;
|
||||
std::shared_ptr<oatpp::data::stream::OutputStreamBufferedProxy> m_upstream;
|
||||
private:
|
||||
std::shared_ptr<oatpp::data::stream::IOStream> m_connection;
|
||||
std::shared_ptr<oatpp::data::buffer::IOBuffer> m_ioBuffer;
|
||||
@ -207,10 +208,10 @@ oatpp::async::Action HttpRequestExecutor::executeAsync(oatpp::async::AbstractCor
|
||||
request->putHeaderIfNotExists(Header::HOST, m_connectionProvider->getProperty("host"));
|
||||
request->putHeaderIfNotExists(Header::CONNECTION, Header::Value::CONNECTION_KEEP_ALIVE);
|
||||
m_ioBuffer = oatpp::data::buffer::IOBuffer::createShared();
|
||||
auto upStream = oatpp::data::stream::OutputStreamBufferedProxy::createShared(connection, m_ioBuffer);
|
||||
m_upstream = oatpp::data::stream::OutputStreamBufferedProxy::createShared(connection, m_ioBuffer);
|
||||
m_bufferPointer = m_ioBuffer->getData();
|
||||
m_bufferBytesLeftToRead = m_ioBuffer->getSize();
|
||||
return request->sendAsync(this, upStream->flushAsync(this, yieldTo(&ExecutorCoroutine::readResponse)), upStream);
|
||||
return request->sendAsync(this, m_upstream->flushAsync(this, yieldTo(&ExecutorCoroutine::readResponse)), m_upstream);
|
||||
}
|
||||
|
||||
Action readResponse() {
|
||||
|
@ -135,6 +135,7 @@ RequestHeadersReader::Action RequestHeadersReader::readHeadersAsync(oatpp::async
|
||||
auto res = m_connection->read(m_buffer, desiredToRead);
|
||||
if(res > 0) {
|
||||
m_bufferStream.write(m_buffer, res);
|
||||
m_progress += res;
|
||||
|
||||
for(v_int32 i = 0; i < res; i ++) {
|
||||
m_accumulator <<= 8;
|
||||
|
@ -135,6 +135,7 @@ ResponseHeadersReader::Action ResponseHeadersReader::readHeadersAsync(oatpp::asy
|
||||
auto res = m_connection->read(m_buffer, desiredToRead);
|
||||
if(res > 0) {
|
||||
m_bufferStream.write(m_buffer, res);
|
||||
m_progress += res;
|
||||
|
||||
for(v_int32 i = 0; i < res; i ++) {
|
||||
m_accumulator <<= 8;
|
||||
|
@ -116,7 +116,7 @@ oatpp::async::Action Response::sendAsync(oatpp::async::AbstractCoroutine* parent
|
||||
, m_buffer(oatpp::data::stream::ChunkedBuffer::createShared())
|
||||
{}
|
||||
|
||||
Action act() {
|
||||
Action act() override {
|
||||
|
||||
if(m_response->m_body){
|
||||
m_response->m_body->declareHeaders(m_response->m_headers);
|
||||
|
Loading…
Reference in New Issue
Block a user