use content text/plain
This commit is contained in:
19
src/main.rs
19
src/main.rs
@@ -7,21 +7,24 @@ fn main() {
|
||||
let server = Server::new(|request, mut response| {
|
||||
|
||||
let mut buff = String::with_capacity(1024);
|
||||
buff.push_str(&format!("Method: {}<br>\n", request.method()));
|
||||
buff.push_str(&format!("URI: {}<br>\n", request.uri()));
|
||||
buff.push_str(&format!("Version: {:?}<br>\n", &request.version()));
|
||||
// buff.push_str(&format!("Headers: {:?}<br>\n", request.headers()));
|
||||
buff.push_str(&format!("Method: {}\n", request.method()));
|
||||
buff.push_str(&format!("URI: {}\n", request.uri()));
|
||||
buff.push_str(&format!("Version: {:?}\n", &request.version()));
|
||||
// buff.push_str(&format!("Headers: {:?}\n", request.headers()));
|
||||
for header in request.headers() {
|
||||
if let Ok(val) = header.1.to_str() {
|
||||
buff.push_str(&format!("{}:{}<br>\n", header.0, val));
|
||||
buff.push_str(&format!("{}:{}\n", header.0, val));
|
||||
} else {
|
||||
// TODO, INGORE ?
|
||||
}
|
||||
}
|
||||
buff.push_str("<br>\n");
|
||||
buff.push_str(&format!("Body: {:?}<br>\n", request.body()));
|
||||
buff.push_str("\n");
|
||||
buff.push_str(&format!("Body: {:?}\n", request.body()));
|
||||
|
||||
Ok(response.status(200).body(buff.as_bytes().to_vec())?)
|
||||
Ok(response
|
||||
.status(200)
|
||||
.header("content-type", "text/plain; charset=UTF-8")
|
||||
.body(buff.as_bytes().to_vec())?)
|
||||
});
|
||||
|
||||
server.listen(host, port);
|
||||
|
||||
Reference in New Issue
Block a user