Skip to content

Commit 4c3fbcb

Browse files
authored
Merge pull request #25 from yoshuawuyts/refactor-stuff
Chunked Encoding
2 parents c687267 + 6a49d81 commit 4c3fbcb

File tree

2 files changed

+259
-81
lines changed

2 files changed

+259
-81
lines changed

examples/server.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ async fn accept(addr: String, stream: TcpStream) -> Result<(), async_h1::Excepti
1414
// TODO: Delete this line when we implement `Clone` for `TcpStream`.
1515
let stream = Stream(Arc::new(stream));
1616

17-
server::connect(&addr, stream.clone(), stream, |_| {
17+
server::accept(&addr, stream.clone(), stream, |_| {
1818
async {
1919
let resp = Response::new(StatusCode::Ok)
2020
.set_header("Content-Type", "text/plain")?
21-
.set_body_string("Hello, World!".to_string())?;
21+
.set_body_string("Hello".into())?;
22+
// To try chunked encoding, replace `set_body_string` with the following method call
23+
// .set_body(io::Cursor::new(vec![
24+
// 0x48u8, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21,
25+
// ]));
2226
Ok(resp)
2327
}
2428
})

0 commit comments

Comments
 (0)