diff options
Diffstat (limited to 'tools/http_server.py')
-rwxr-xr-x | tools/http_server.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/http_server.py b/tools/http_server.py index f9820ff19..6cf997b86 100755 --- a/tools/http_server.py +++ b/tools/http_server.py @@ -15,6 +15,30 @@ REDIRECT_PORT = 4546 class ContentTypeHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): + def do_GET(self): + if "multipart_form_data.txt" 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() + self.wfile.write( + bytes('Preamble\r\n' + '--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="field_2"; ' + 'filename="file.js"\r\n' + 'Content-Type: text/javascript\r\n' + '\r\n' + 'console.log("Hi")' + '\r\n--boundary--\r\n' + 'Epilogue')) + return + return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) + def guess_type(self, path): if ".t1." in path: return "text/typescript" @@ -32,6 +56,8 @@ class ContentTypeHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): return "text/ecmascript" if ".j4." in path: return "application/x-javascript" + if "form_urlencoded" in path: + return "application/x-www-form-urlencoded" return SimpleHTTPServer.SimpleHTTPRequestHandler.guess_type(self, path) |