Просмотр исходного кода

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

skoupidi 2 месяцев назад
Родитель
Сommit
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)
 }