Преглед изворни кода

rpc/common: use read_exact to read request/response http body

skoupidi пре 3 месеци
родитељ
комит
ebc168c5a6
1 измењених фајлова са 2 додато и 4 уклоњено
  1. 2 4
      src/rpc/common.rs

+ 2 - 4
src/rpc/common.rs

@@ -96,9 +96,8 @@ pub(super) async fn http_read_from_stream_request(
     // Now we know the request body size. Read it into the buffer.
     buf.clear();
     buf.resize(content_length, 0_u8);
-    reader.read(buf).await?;
+    reader.read_exact(buf).await?;
 
-    assert!(buf.len() == content_length);
     Ok(content_length)
 }
 
@@ -170,9 +169,8 @@ pub(super) async fn http_read_from_stream_response(
     // Now we know the response body size. Read it into the buffer.
     buf.clear();
     buf.resize(content_length, 0_u8);
-    reader.read(buf).await?;
+    reader.read_exact(buf).await?;
 
-    assert!(buf.len() == content_length);
     Ok(content_length)
 }