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

Method get_length

httpx/_multipart.py:171–184  ·  httpx/_multipart.py::FileField.get_length
(self)

Source from the content-addressed store, hash-verified

169 self.headers = headers
170
171 def get_length(self) -> int | None:
172 headers = self.render_headers()
173
174 if isinstance(self.file, (str, bytes)):
175 return len(headers) + len(to_bytes(self.file))
176
177 file_length = peek_filelike_length(self.file)
178
179 class="cm"># If we can't determine the filesize without reading it into memory,
180 class="cm"># then return `None` here, to indicate an unknown file length.
181 if file_length is None:
182 return None
183
184 return len(headers) + file_length
185
186 def render_headers(self) -> bytes:
187 if not hasattr(self, class="st">"_headers"):

Callers

nothing calls this directly

Calls 3

render_headersMethod · 0.95
to_bytesFunction · 0.85
peek_filelike_lengthFunction · 0.85

Tested by

no test coverage detected