mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 05:04:48 +00:00
fix(cli/js/web): formData parser for binary files (#6015)
This commit is contained in:
parent
edeeedf401
commit
1d3dce9a68
4 changed files with 163 additions and 87 deletions
|
@ -207,6 +207,25 @@ class ContentTypeHandler(QuietSimpleHTTPRequestHandler):
|
|||
data_string = self.rfile.read(int(self.headers['Content-Length']))
|
||||
self.wfile.write(bytes(data_string))
|
||||
return
|
||||
if "echo_multipart_file" in self.path:
|
||||
self.protocol_version = 'HTTP/1.1'
|
||||
self.send_response(200, 'OK')
|
||||
self.send_header('Content-type',
|
||||
'multipart/form-data;boundary=boundary')
|
||||
self.end_headers()
|
||||
file_content = self.rfile.read(int(self.headers['Content-Length']))
|
||||
self.wfile.write(
|
||||
bytes('--boundary\t \r\n'
|
||||
'Content-Disposition: form-data; name="field_1"\r\n'
|
||||
'\r\n'
|
||||
'value_1 \r\n'
|
||||
'\r\n--boundary\r\n'
|
||||
'Content-Disposition: form-data; name="file"; '
|
||||
'filename="file.bin"\r\n'
|
||||
'Content-Type: application/octet-stream\r\n'
|
||||
'\r\n') + bytes(file_content) +
|
||||
bytes('\r\n--boundary--\r\n'))
|
||||
return
|
||||
self.protocol_version = 'HTTP/1.1'
|
||||
self.send_response(501)
|
||||
self.send_header('content-type', 'text/plain')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue