From d275821738b99ed63b1b241a222bf5e1ee5badfa Mon Sep 17 00:00:00 2001 From: sope Date: Wed, 26 Jan 2022 15:39:25 +0800 Subject: [PATCH] Update web-server.md --- book/contents/async/web-server.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/contents/async/web-server.md b/book/contents/async/web-server.md index 8baf6133..dfc24faa 100644 --- a/book/contents/async/web-server.md +++ b/book/contents/async/web-server.md @@ -257,7 +257,7 @@ impl Read for MockTcpStream { } ``` -`Write`的实现也类似,需要实现三个方法 : `poll_write`, `poll_flush`, and `poll_close`。 `poll_write` 会拷贝输入数据到mock的 `TcpStream` 中,当完成后返回 `Poll::Ready`。由于 `TcpStream` 无需 `flush` 和 `close`,因此另两个方法直接返回 `Poll::Ready` 即可. +`Write`的实现也类似,需要实现三个方法 : `poll_write`, `poll_flush`, 与 `poll_close`。 `poll_write` 会拷贝输入数据到mock的 `TcpStream` 中,当完成后返回 `Poll::Ready`。由于 `TcpStream` 无需 `flush` 和 `close`,因此另两个方法直接返回 `Poll::Ready` 即可. ```rust impl Write for MockTcpStream { @@ -311,4 +311,4 @@ async fn test_handle_connection() { let expected_response = format!("HTTP/1.1 200 OK\r\n\r\n{}", expected_contents); assert!(stream.write_data.starts_with(expected_response.as_bytes())); } -``` \ No newline at end of file +```