1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-05-19 07:23:17 +02:00

fix: improve logger header values printing

This commit is contained in:
Rob Ede 2025-05-10 02:56:41 +01:00
parent 89b5b04653
commit 55268b6898
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
3 changed files with 7 additions and 5 deletions

View File

@ -4,5 +4,6 @@ words:
- addrs
- httparse
- msrv
- realip
- rustup
- zstd

View File

@ -3,6 +3,7 @@
## Unreleased
- Add `Logger::log_level()` method.
- Improve handling of non-UTF-8 header values in `Logger` middleware.
- Add `HttpServer::shutdown_signal()` method.
- Mark `HttpServer` as `#[must_use]`.
- Re-export `mime` dependency.

View File

@ -649,9 +649,9 @@ impl FormatText {
FormatText::ResponseHeader(ref name) => {
let s = if let Some(val) = res.headers().get(name) {
val.to_str().unwrap_or("-")
String::from_utf8_lossy(val.as_bytes()).into_owned()
} else {
"-"
"-".to_owned()
};
*self = FormatText::Str(s.to_string())
}
@ -693,11 +693,11 @@ impl FormatText {
FormatText::RequestTime => *self = FormatText::Str(now.format(&Rfc3339).unwrap()),
FormatText::RequestHeader(ref name) => {
let s = if let Some(val) = req.headers().get(name) {
val.to_str().unwrap_or("-")
String::from_utf8_lossy(val.as_bytes()).into_owned()
} else {
"-"
"-".to_owned()
};
*self = FormatText::Str(s.to_string());
*self = FormatText::Str(s);
}
FormatText::RemoteAddr => {
let s = if let Some(peer) = req.connection_info().peer_addr() {