MCPcopy Index your code
hub / github.com/python/cpython / parse_content_disposition_header

Function parse_content_disposition_header

Lib/email/_header_value_parser.py:2752–2780  ·  view source on GitHub ↗

disposition-type *( ";" parameter )

(value)

Source from the content-addressed store, hash-verified

2750 return ctype
2751
2752def parse_content_disposition_header(value):
2753 """ disposition-type *( ";" parameter )
2754
2755 """
2756 disp_header = ContentDisposition()
2757 if not value:
2758 disp_header.defects.append(errors.HeaderMissingRequiredValue(
2759 "Missing content disposition"))
2760 return disp_header
2761 try:
2762 token, value = get_token(value)
2763 except errors.HeaderParseError:
2764 disp_header.defects.append(errors.InvalidHeaderDefect(
2765 "Expected content disposition but found {!r}".format(value)))
2766 _find_mime_parameters(disp_header, value)
2767 return disp_header
2768 disp_header.append(token)
2769 disp_header.content_disposition = token.value.strip().lower()
2770 if not value:
2771 return disp_header
2772 if value[0] != ';':
2773 disp_header.defects.append(errors.InvalidHeaderDefect(
2774 "Only parameters are valid after content disposition, but "
2775 "found {!r}".format(value)))
2776 _find_mime_parameters(disp_header, value)
2777 return disp_header
2778 disp_header.append(ValueTerminal(';', 'parameter-separator'))
2779 disp_header.append(parse_mime_parameters(value[1:]))
2780 return disp_header
2781
2782def parse_content_transfer_encoding_header(value):
2783 """ mechanism

Callers

nothing calls this directly

Calls 9

ContentDispositionClass · 0.85
get_tokenFunction · 0.85
_find_mime_parametersFunction · 0.85
ValueTerminalClass · 0.85
parse_mime_parametersFunction · 0.85
appendMethod · 0.45
formatMethod · 0.45
lowerMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…