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

Method parse

src/werkzeug/formparser.py:210–247  ·  view source on GitHub ↗

Parses the information from the given stream, mimetype, content length and mimetype parameters. :param stream: an input stream :param mimetype: the mimetype of the data :param content_length: the content length of the incoming data :param options: optional mi

(
        self,
        stream: t.IO[bytes],
        mimetype: str,
        content_length: int | None,
        options: dict[str, str] | None = None,
    )

Source from the content-addressed store, hash-verified

208 )
209
210 def parse(
211 self,
212 stream: t.IO[bytes],
213 mimetype: str,
214 content_length: int | None,
215 options: dict[str, str] | None = None,
216 ) -> t_parse_result:
217 """Parses the information from the given stream, mimetype,
218 content length and mimetype parameters.
219
220 :param stream: an input stream
221 :param mimetype: the mimetype of the data
222 :param content_length: the content length of the incoming data
223 :param options: optional mimetype parameters (used for
224 the multipart boundary for instance)
225 :return: A tuple in the form ``(stream, form, files)``.
226
227 .. versionchanged:: 3.0
228 The invalid ``application/x-url-encoded`` content type is not
229 treated as ``application/x-www-form-urlencoded``.
230 """
231 if mimetype == "multipart/form-data":
232 parse_func = self._parse_multipart
233 elif mimetype == "application/x-www-form-urlencoded":
234 parse_func = self._parse_urlencoded
235 else:
236 return stream, self.cls(), self.cls()
237
238 if options is None:
239 options = {}
240
241 try:
242 return parse_func(stream, mimetype, content_length, options)
243 except ValueError:
244 if not self.silent:
245 raise
246
247 return stream, self.cls(), self.cls()
248
249 def _parse_multipart(
250 self,

Callers 6

parse_from_environMethod · 0.95
_load_form_dataMethod · 0.45
_prefix_namesFunction · 0.45
_compile_builderMethod · 0.45
syncFunction · 0.45

Calls

no outgoing calls

Tested by 1