浏览器通过post表单上传文件,python如何解析?
http请求:
------xxx
Content-Disposition: form-data; name="imgFile"; filename="xxx"
Content-Type: application/octet-stream
<data in here>
------WebKitFormBoundary7MA4YWxkTrZu0gW--
...(处理请求头content-disposition和content-type)
boundary = '------xxxxx' #分割线
cachefile = cachefile() #缓存,看作一个文件吧
#cachefile.endwith(bytes) 文件结尾是否存在该字节
while not cachefile.endwith(boundary.encode()+b"\r\n"):
cachefile.write(conn.recv(1)) #从socket读取数据
...
现在问题就是一个一个读取字节是真的太慢了,有没有什么方法更快速的解析?(一下全部读取完不现实,表单有多个文件,而且文件过大内存溢出)