Merge pull request #331 from shenshouer/patch-3

Update web-server.md
pull/334/head
Sunface 3 years ago committed by GitHub
commit 27bb2f412d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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()));
}
```
```

Loading…
Cancel
Save