Return the length of the multipart encoded content, or `None` if any of the files have a length that cannot be determined upfront.
(self)
| 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 |