python httplib

1
2
3
4
5
6
7
8
import httplib
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain","Connection":"Keep-Alive"}
conn = httplib.HTTPConnection("192.168.54.138",6040)
for i in range(self.times):
conn.request("POST", "/index.html", self.data, headers)
response = conn.getresponse()
response.read()
conn.close()

主要在于 headers 声明 Connection:Keep-Alive
每次请求 不用再连续创建 HTTPConnection

#