headers['Transfer-Encoding'] = 'chunked'

时间:2021-08-19
本文章向大家介绍headers['Transfer-Encoding'] = 'chunked',主要包括headers['Transfer-Encoding'] = 'chunked'使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

This is not explained in user documentation. By going through the source code of requests, I found out that if we set stream=True in requests.get(...) then headers['Transfer-Encoding'] = 'chunked' is set in the HTTP headers. Thus specifying the Chunked transfer encoding. In chunked transfer encoding, the data stream is divided into a series of non-overlapping "chunks". The chunks are sent out independently of one another by the server. Hope this answers the question.

Chunked encoding is useful when larger amounts of data are sent to the client and the total size of the response may not be known until the request has been fully processed. For example, when generating a large HTML table resulting from a database query or when transmitting large images.
当向客户端发送大量数据时,分块编码非常有用,并且在请求完全处理之前,可能无法知道响应的总大小。例如,在生成由数据库查询生成的大型HTML表或传输大型图像时。

原文地址:https://www.cnblogs.com/qianxinn/p/15161521.html