浏览代码

LibCore: Allow reads smaller than the buffered data size in IODevice

This restriction doesn't make much sense, a user should be free to
consume the buffered data with as small a max_size as they desire.
This fixes a possible RequestServer spin when talking to HTTP servers.
Ali Mohammad Pur 3 年之前
父节点
当前提交
e112e6620f
共有 1 个文件被更改,包括 0 次插入9 次删除
  1. 0 9
      Userland/Libraries/LibCore/IODevice.cpp

+ 0 - 9
Userland/Libraries/LibCore/IODevice.cpp

@@ -47,15 +47,6 @@ ByteBuffer IODevice::read(size_t max_size)
     if (m_buffered_data.size() < max_size)
         populate_read_buffer(max(max_size - m_buffered_data.size(), 1024));
 
-    if (m_buffered_data.size() > max_size) {
-        if (m_error)
-            return {};
-        if (m_eof) {
-            dbgln("IODevice::read: At EOF but there's more than max_size({}) buffered", max_size);
-            return {};
-        }
-    }
-
     auto size = min(max_size, m_buffered_data.size());
     auto buffer_result = ByteBuffer::create_uninitialized(size);
     if (!buffer_result.has_value()) {