我试图使用REST、GET和旋风一起发送一个文件,但是每次返回的文件的校验和是不同的。这背后的原因是什么?这些块是否按不正确的顺序返回?
我正在使用curl下载文件。
谢谢你的建议!
async def get(self, filename):
chunkSize = 1024 * 1024 * 1 # 1 Mib
with open(filename, 'rb') as f:
while True:
chunk = f.read(chunkSize)
if not chunk:
break
try:
self.write(chunk) # write the chunk to the response
await self.flush()# send the chunk to the client
except iostream.StreamClosedError:
break
finally:
del chunk
await gen.sleep(0.000000001)
self.finish()编辑:我尝试下载一个本地文件,发现curl状态被添加到文件的开头。
curl --用户测试-i -X GET http://localhost:8085/download/testfile.dat -output testfile.dat
在不添加连接的wget中工作得更好。
wget --http-user=test -http-passwd=test http://localhost:8085/download/testfile.dat
发布于 2021-06-14 00:23:09
编辑:我尝试下载一个本地文件,发现curl状态被添加到文件的开头。curl --用户测试-i -X GET http://localhost:8085/download/testfile.dat --输出testfile.dat
这就是curl -i所做的。从手册页:
-i, --include
Include the HTTP response headers in the output. The HTTP
response headers can include things like server name,
cookies, date of the document, HTTP version and more...
To view the request headers, consider the -v, --verbose
option.从curl命令行中删除-i,它应该像wget命令行一样工作。
发布于 2021-06-07 14:54:31
代码中的问题是,我为REST客户端编写了一些额外的数据,这些数据最终出现在下载的文件中。我还发现curl在下载的文件中添加了一些额外的头,而wget不这样做。试着和-s下面的数据被添加到文件的开头。
HTTP/1.1 200 OK
Server: TornadoServer/4.4.2
Content-Type: text/html; charset=UTF-8
Date: Mon, 07 Jun 2021 14:41:53 GMT
Transfer-Encoding: chunkedhttps://stackoverflow.com/questions/67871304
复制相似问题