MCPcopy Create free account
hub / github.com/pallets/quart / get_part_charset

Method get_part_charset

src/quart/formparser.py:156–168  ·  view source on GitHub ↗
(self, headers: Headers)

Source from the content-addressed store, hash-verified

154 raise ValueError(message)
155
156 def get_part_charset(self, headers: Headers) -> str:
157 content_type = headers.get("content-type")
158
159 if content_type:
160 parameters = parse_options_header(content_type)[1]
161 ct_charset = parameters.get("charset", "").lower()
162
163 # A safe list of encodings. Modern clients should only send ASCII or UTF-8.
164 # This list will not be extended further.
165 if ct_charset in {"ascii", "us-ascii", "utf-8", "iso-8859-1"}:
166 return ct_charset
167
168 return "utf-8"
169
170 def start_file_streaming(self, event: File, total_content_length: int) -> IO[bytes]:
171 content_type = event.headers.get("content-type")

Callers 1

parseMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected