MCPcopy
hub / github.com/pallets/werkzeug / get_part_charset

Method get_part_charset

src/werkzeug/formparser.py:318–331  ·  view source on GitHub ↗
(self, headers: Headers)

Source from the content-addressed store, hash-verified

316 raise ValueError(message)
317
318 def get_part_charset(self, headers: Headers) -> str:
319 # Figure out input charset for current part
320 content_type = headers.get("content-type")
321
322 if content_type:
323 parameters = parse_options_header(content_type)[1]
324 ct_charset = parameters.get("charset", "").lower()
325
326 # A safe list of encodings. Modern clients should only send ASCII or UTF-8.
327 # This list will not be extended further.
328 if ct_charset in {"ascii", "us-ascii", "utf-8", "iso-8859-1"}:
329 return ct_charset
330
331 return "utf-8"
332
333 def start_file_streaming(
334 self, event: File, total_content_length: int | None

Callers 1

parseMethod · 0.95

Calls 2

parse_options_headerFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected