Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/async_impl/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,18 @@ impl Response {
self.res.headers_mut()
}

/// Get the content-length of this response, if known.
/// Get the content length of the response, if it is known.
///
/// This value does not directly represents the value of the `Content-Length`
/// header, but rather the size of the response's body. To read the header's
/// value, please use the [`Response::headers`] method instead.
///
/// Reasons it may not be known:
///
/// - The server didn't send a `content-length` header.
/// - The response is compressed and automatically decoded (thus changing
/// the actual decoded length).
/// - The response does not include a body (e.g. it responds to a `HEAD`
/// request).
/// - The response is gzipped and automatically decoded (thus changing the
/// actual decoded length).
pub fn content_length(&self) -> Option<u64> {
use hyper::body::Body;

Expand Down
14 changes: 10 additions & 4 deletions src/blocking/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,19 @@ impl Response {
self.inner.extensions_mut()
}

/// Get the content-length of the response, if it is known.
/// Get the content length of the response, if it is known.
///
///
/// This value does not directly represents the value of the `Content-Length`
/// header, but rather the size of the response's body. To read the header's
/// value, please use the [`Response::headers`] method instead.
///
/// Reasons it may not be known:
///
/// - The server didn't send a `content-length` header.
/// - The response is gzipped and automatically decoded (thus changing
/// the actual decoded length).
/// - The response does not include a body (e.g. it responds to a `HEAD`
/// request).
/// - The response is gzipped and automatically decoded (thus changing the
/// actual decoded length).
pub fn content_length(&self) -> Option<u64> {
self.inner.content_length()
}
Expand Down
Loading