Skip to content

Commit 09720bc

Browse files
authored
Fix calculation of response body size in metrics (#39)
1 parent 42632e6 commit 09720bc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/service.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ where
6262
let body_size = result
6363
.as_ref()
6464
.ok()
65-
.and_then(|res| res.body().bytes())
66-
.map(|bytes| bytes.len())
67-
.unwrap_or(0) as u64;
65+
.and_then(|res| res.headers().get(hyper::header::CONTENT_LENGTH))
66+
.and_then(|v| v.to_str().ok())
67+
.and_then(|s| s.parse::<u64>().ok())
68+
.unwrap_or(0);
6869

6970
let response_body_size = ResponseBodySize {
7071
version: "1.1",

0 commit comments

Comments
 (0)