关闭保持活动状态

时间:2018-12-20 14:38:33

标签: python python-requests keep-alive urllib3

在旧版本的“请求”中,可以选择关闭保持活动状态。像这样:

s = requests.session()
s.config['keep_alive'] = False

在其他问题中,我也发现可以使用标题Connection:close

HTTP/1.1 defines the "close" connection option for the sender to signal 
that the connection will be closed after completion of the response. 
For example,
   Connection: close
in either the request or the response header fields indicates that the 
connection SHOULD NOT be considered `persistent' (section 8.1) after the 
current request/response is complete.
HTTP/1.1 applications that do not support persistent connections MUST 
include the "close" connection option in every message. 

如果我理解正确,那并不意味着连接将被关闭。仅仅是信息,不应将其视为永久信息。

在最新版本中该怎么做?

0 个答案:

没有答案