MCPcopy
hub / github.com/pallets/werkzeug / calculate_content_length

Method calculate_content_length

src/werkzeug/wrappers/response.py:308–314  ·  view source on GitHub ↗

Returns the content length if available or `None` otherwise.

(self)

Source from the content-addressed store, hash-verified

306 )
307
308 def calculate_content_length(self) -> int | None:
309 """Returns the content length if available or `None` otherwise."""
310 try:
311 self._ensure_sequence()
312 except RuntimeError:
313 return None
314 return sum(len(x) for x in self.iter_encoded())
315
316 def _ensure_sequence(self, mutable: bool = False) -> None:
317 """This method can be called by methods that need a sequence. If

Callers 2

make_conditionalMethod · 0.95

Calls 2

_ensure_sequenceMethod · 0.95
iter_encodedMethod · 0.95

Tested by 1