MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / parse_multipart

Function parse_multipart

tools/python-3.11.9-amd64/Lib/cgi.py:199–224  ·  view source on GitHub ↗

Parse multipart input. Arguments: fp : input file pdict: dictionary containing other parameters of content-type header encoding, errors: request encoding and error handler, passed to FieldStorage Returns a dictionary just like parse_qs(): keys are the field na

(fp, pdict, encoding="utf-8", errors="replace", separator='&')

Source from the content-addressed store, hash-verified

197
198
199def parse_multipart(fp, pdict, encoding="utf-8", errors="replace", separator='&'):
200 """Parse multipart input.
201
202 Arguments:
203 fp : input file
204 pdict: dictionary containing other parameters of content-type header
205 encoding, errors: request encoding and error handler, passed to
206 FieldStorage
207
208 Returns a dictionary just like parse_qs(): keys are the field names, each
209 value is a list of values for that field. For non-file fields, the value
210 is a list of strings.
211 """
212 # RFC 2046, Section 5.1 : The "multipart" boundary delimiters are always
213 # represented as 7bit US-ASCII.
214 boundary = pdict['boundary'].decode('ascii')
215 ctype = "multipart/form-data; boundary={}".format(boundary)
216 headers = Message()
217 headers.set_type(ctype)
218 try:
219 headers['Content-Length'] = pdict['CONTENT-LENGTH']
220 except KeyError:
221 pass
222 fs = FieldStorage(fp, headers=headers, encoding=encoding, errors=errors,
223 environ={'REQUEST_METHOD': 'POST'}, separator=separator)
224 return {k: fs.getlist(k) for k in fs}
225
226def _parseparam(s):
227 while s[:1] == ';':

Callers 1

parseFunction · 0.85

Calls 6

set_typeMethod · 0.95
getlistMethod · 0.95
MessageClass · 0.90
FieldStorageClass · 0.85
decodeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected