Rationale:
- In Rust, one can omit a semicolon after a function's final expression to make
its value the function's return value. It's common for people to include a
semicolon after the last expression by mistake - common enough that the Rust
compiler suggests removing the semicolon when there's a type mismatch between
the function's signature and body. By implementing Responder for (), Actix makes
this common mistake a silent error in handler functions.
- Functions returning an empty body should return HTTP status 204 ("No Content"),
so the current Responder impl for (), which returns status 200 ("OK"), is not
really what one wants anyway.
- It's not much of a burden to ask handlers to explicitly return
`HttpResponse::Ok()` if that is what they want; all the examples in the
documentation do this already.
* Fix filename encoding in Content-Disposition of acitx_files::NamedFile
* Add more comments on how to use Content-Disposition header properly & Fix some trivial problems
* Improve Content-Disposition filename(*) parameters of actix_files::NamedFile
* Tweak Content-Disposition parse to accept empty param value in quoted-string
* Fix typos in comments in .../content_disposition.rs (pointed out by @JohnTitor)
* Update CHANGES.md
* Update CHANGES.md again
When accessing to a folder without a final slash, the index file will be loaded ok, but if it has
references (like a css or an image in an html file) these resources won't be loaded correctly if
they are using relative paths. In order to solve this, this PR adds the possibility to detect
folders without a final slash and make a 302 redirect to mitigate this issue. The behavior is off by
default. We're adding a new method called `redirect_to_slash_directory` which can be used to enable
this behavior.
* Let ResponseError render w/ 'text/plain; charset=utf-8' header (#1118)
Trait ResponseError originally render Error messages with header
`text/plain` , which causes browsers (i.e. Firefox 70.0) with
Non-English locale unable to render UTF-8 responses with non-English
characters correctly. i.e. emoji.
This fix solved this problem by specifying the charset of `text/plain`
as utf-8, which is the default charset in rust.
Before actix-web consider to support other charsets, this hotfix is
enough.
Test case:
fn test() -> Result<String, actix_web::Error> {
Err(actix_web::error::ErrorForbidden("ðtest"))
}
* Update actix-http/CHANGES.md for #1118