diff options
Diffstat (limited to 'plugins/fcgi/socket.cpp')
-rw-r--r-- | plugins/fcgi/socket.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/plugins/fcgi/socket.cpp b/plugins/fcgi/socket.cpp index 228964c..5402cfb 100644 --- a/plugins/fcgi/socket.cpp +++ b/plugins/fcgi/socket.cpp @@ -106,7 +106,17 @@ size_t TCPSocket::write(const std::vector<char>& data) size_t TCPSocket::read(std::vector<char>& data) { try { - return m_socket.read_some(boost::asio::buffer(data)); + size_t result{0}; + + while (m_socket.available()) { + std::vector<char> inbuf_part(1024); + size_t got { m_socket.read_some(boost::asio::buffer(inbuf_part))}; + data.insert(data.end(), inbuf_part.begin(), inbuf_part.begin() + got); + result += got; + } + + return result; + } catch (const boost::system::system_error& ex) { if (ex.code() == boost::asio::error::eof) { throw fcgi_eof_error("EOF on read"); @@ -165,7 +175,16 @@ size_t FileSocket::write(const std::vector<char>& data) size_t FileSocket::read(std::vector<char>& data) { try { - return m_socket.read_some(boost::asio::buffer(data)); + size_t result{0}; + + while (m_socket.available()) { + std::vector<char> inbuf_part(1024); + size_t got { m_socket.read_some(boost::asio::buffer(inbuf_part))}; + data.insert(data.end(), inbuf_part.begin(), inbuf_part.begin() + got); + result += got; + } + + return result; } catch (const boost::system::system_error& ex) { if (ex.code() == boost::asio::error::eof) { throw fcgi_eof_error("EOF on read"); |