Thanks again for all your great work! ❤️
It seems like between tide 0.6.0 and 0.8.1 there might have been a regression in encoding behavior for responses. Previously, tide set the content type headers on simple .get() endpoints to content-type: text/plain; charset=utf-8, in a newer version the headers say content-type: text/plain. This can cause non-ascii characters to display incorrectly when writing code based on the hello world example in the readme and examples directory.
Users might want to have the ability to choose their own charsets, but perhaps a default of utf-8 could make sense - it is fairly common, and it is the default encoding Rust expects strings to be in. The two examples below use an emoji to highlight the issue, but this seems to apply to other non-ascii characters too, including some fairly common diacritics in other languages.
Old code:
// tide = "0.6.0"
use std::env;
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
let port = env::var("PORT").unwrap();
app.at("/").get(|_| async move { "Hello from Rust! 🦀\n" });
app.listen(format!("0.0.0.0:{}", port)).await?;
Ok(())
}
Result:

curl
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< content-type: text/plain; charset=utf-8
< transfer-encoding: chunked
< date: Sun, 17 May 2020 19:00:20 GMT
<
Hello from Rust! 🦀
* Connection #0 to host localhost left intact
* Closing connection 0
New code
// tide = "0.8.1"
use std::env;
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
let port = env::var("PORT").unwrap();
app.at("/").get(|_| async { Ok("Hello from Rust! 🦀\n") });
app.listen(format!("0.0.0.0:{}", port)).await?;
Ok(())
}
Result

curl
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< content-length: 22
< date: Sun, 17 May 2020 19:03:50 GMT
< content-type: text/plain
<
Hello from Rust! 🦀
* Connection #0 to host localhost left intact
* Closing connection 0
(Note that in the latter example, my terminal shows the emoji correctly. Perhaps it assumes utf-8, whereas browser defaults to something else?)
Thanks again for all your great work! ❤️
It seems like between
tide0.6.0 and 0.8.1 there might have been a regression in encoding behavior for responses. Previously,tideset the content type headers on simple.get()endpoints tocontent-type: text/plain; charset=utf-8, in a newer version the headers saycontent-type: text/plain. This can cause non-ascii characters to display incorrectly when writing code based on the hello world example in the readme and examples directory.Users might want to have the ability to choose their own charsets, but perhaps a default of utf-8 could make sense - it is fairly common, and it is the default encoding Rust expects strings to be in. The two examples below use an emoji to highlight the issue, but this seems to apply to other non-ascii characters too, including some fairly common diacritics in other languages.
Old code:
Result:
curlNew code
Result
curl(Note that in the latter example, my terminal shows the emoji correctly. Perhaps it assumes utf-8, whereas browser defaults to something else?)