MCPcopy
hub / github.com/encode/httpx / get_content_length

Method get_content_length

httpx/_multipart.py:265–283  ·  view source on GitHub ↗

Return the length of the multipart encoded content, or `None` if any of the files have a length that cannot be determined upfront.

(self)

Source from the content-addressed store, hash-verified

263 yield b"--%s--\r\n" % self.boundary
264
265 def get_content_length(self) -> int | None:
266 """
267 Return the length of the multipart encoded content, or `None` if
268 any of the files have a length that cannot be determined upfront.
269 """
270 boundary_length = len(self.boundary)
271 length = 0
272
273 for field in self.fields:
274 field_length = field.get_length()
275 if field_length is None:
276 return None
277
278 length += 2 + boundary_length + 2 # b"--{boundary}\r\n"
279 length += field_length
280 length += 2 # b"\r\n"
281
282 length += 2 + boundary_length + 4 # b"--{boundary}--\r\n"
283 return length
284
285 # Content stream interface.
286

Callers 1

get_headersMethod · 0.95

Calls 1

get_lengthMethod · 0.45

Tested by

no test coverage detected