(self)
| 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"): |
nothing calls this directly
no test coverage detected