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
2 changes: 1 addition & 1 deletion python/rnet/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ class Response:
Get the cookies of the response.
"""

content_length: int
content_length: Optional[int]
r"""
Get the content length of the response.
"""
Expand Down
2 changes: 1 addition & 1 deletion python/rnet/blocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Response:
Get the cookies of the response.
"""

content_length: int
content_length: Optional[int]
r"""
Get the content length of the response.
"""
Expand Down
6 changes: 3 additions & 3 deletions src/client/resp/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Response {

/// Get the content length of the response.
#[pyo3(get)]
content_length: u64,
content_length: Option<u64>,

/// Get the headers of the response.
#[pyo3(get)]
Expand Down Expand Up @@ -69,9 +69,9 @@ impl Response {
/// Create a new [`Response`] instance.
pub fn new(response: wreq::Response) -> Self {
let uri = response.uri().clone();
let content_length = response.content_length();
let local_addr = response.local_addr().map(SocketAddr);
let remote_addr = response.remote_addr().map(SocketAddr);
let content_length = response.content_length().unwrap_or_default();
let response = HttpResponse::from(response);
let (parts, body) = response.into_parts();

Expand Down Expand Up @@ -294,7 +294,7 @@ impl BlockingResponse {

/// Get the content length of the response.
#[getter]
pub fn content_length(&self) -> u64 {
pub fn content_length(&self) -> Option<u64> {
self.0.content_length
}

Expand Down
Loading