HTML文件上传POST请求中没有Content-Disposition标头

时间:2018-09-28 17:28:02

标签: html python-3.x basehttprequesthandler

我正在使用BaseHTTPRequestHandler的简单Python服务器上工作。我使用HTML表单将文件上传到服务器:

<form action="http://my-server-ip:port/" method="POST" enctype="multipart/form-data">
    <div class="btn-group">
        <label class="btn btn-primary">Upload J1<input type="file" name="j1" id="j1" accept=".rkt" style="display: none"></label>
        <label class="btn btn-danger">Submit<button type="submit" style="display: none"></button></label>
    </div>
</form>

但是,当我收到POST请求时,它似乎没有包含Content-Disposition标头。

我的POST请求处理程序:

content_len = int(self.headers.get('content-length', 0))
print(self.headers)
post_body = self.rfile.read(content_len)
self.send_response(200)
self.end_headers()

输出print(self.headers):

Host: 10.20.185.148:8080
Connection: keep-alive
Content-Length: 1155
Cache-Control: max-age=0
Origin: http://localhost:8000
Upgrade-Insecure-Requests: 1
Content-Type: multipart/form-data; boundary=----            
WebKitFormBoundary3PzXqAW76rKBOCfF
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http://localhost:8000/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9

0 个答案:

没有答案