MCPcopy Create free account
hub / github.com/tornadoweb/tornado / test_multipart_form

Method test_multipart_form

tornado/test/httpserver_test.py:224–251  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

222 return body
223
224 def test_multipart_form(self):
225 # Encodings here are tricky: Headers are latin1, bodies can be
226 # anything (we use utf8 by default).
227 response = self.raw_fetch(
228 [
229 b"POST /multipart HTTP/1.0",
230 b"Content-Type: multipart/form-data; boundary=1234567890",
231 b"X-Header-encoding-test: \xe9",
232 ],
233 b"\r\n".join(
234 [
235 b"Content-Disposition: form-data; name=argument",
236 b"",
237 "\u00e1".encode(),
238 b"--1234567890",
239 'Content-Disposition: form-data; name="files"; filename="\u00f3"'.encode(),
240 b"",
241 "\u00fa".encode(),
242 b"--1234567890--",
243 b"",
244 ]
245 ),
246 )
247 data = json_decode(response)
248 self.assertEqual("\u00e9", data["header"])
249 self.assertEqual("\u00e1", data["argument"])
250 self.assertEqual("\u00f3", data["filename"])
251 self.assertEqual("\u00fa", data["filebody"])
252
253 def test_newlines(self):
254 # We support both CRLF and bare LF as line separators.

Callers

nothing calls this directly

Calls 3

raw_fetchMethod · 0.95
json_decodeFunction · 0.90
joinMethod · 0.80

Tested by

no test coverage detected