This is just a convenient way to view the entire request or response as the server sees it, and allow easier copy & paste to other applications. I have a rough implementation that I use, which does not include extensions:
// This is a wrapper over Response<axum::body::Boxy>
impl fmt::Display for TestResponse {
/// Print as a raw HTTP response
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "{:?} {}", self.parts.version, self.parts.status)?;
for (name, value) in &self.parts.headers {
writeln!(f, "{name}: {}", String::from_utf8_lossy(value.as_bytes()))?;
}
writeln!(f, "\n{}", String::from_utf8_lossy(&self.body))
}
}
This is just a convenient way to view the entire request or response as the server sees it, and allow easier copy & paste to other applications. I have a rough implementation that I use, which does not include extensions:
The result is alright:
This could be a standalone trait or method as well, to better handle the generic body that might not want to implement
Display
.