aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/server.rs1
-rw-r--r--src/lib.rs7
2 files changed, 8 insertions, 0 deletions
diff --git a/examples/server.rs b/examples/server.rs
index 864c105..464e564 100644
--- a/examples/server.rs
+++ b/examples/server.rs
@@ -19,6 +19,7 @@ fn main() {
fn handler(req: &mut dyn RequestExt) -> io::Result<Response<Body>> {
Ok(
Response::builder()
+ .status(202)
.header(header::CONTENT_TYPE, "text/html")
.body(Body::from_static(b"<h1>Test</h1>"))
.unwrap()
diff --git a/src/lib.rs b/src/lib.rs
index 5d26a98..558460f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -253,6 +253,13 @@ impl Server {
let (head, body) = response.unwrap().into_parts();
+ write!(
+ &mut stdout,
+ "HTTP/1.1 {} {}\r\n",
+ head.status.as_str(),
+ head.status.canonical_reason().unwrap_or("UNKNOWN"),
+ );
+
for (name, value) in head.headers.iter() {
write!(&mut stdout, "{}: ", name).unwrap();
stdout.write(value.as_bytes()).unwrap();