尝试了关闭当前的 HTTPConnection ,新开一个,也还是 GET 不到。抓包 GET 发不出去。初始化成功了的。没思路了
status,response = 1,''
try:
start = time.time()
if connDefault is None:
conn = HTTPConnection(self.host,timeout=60)
else:
conn = connDefault
self.headers["Content-Length"] = len(PostStr)
conn.request('POST',url,PostStr,headers=self.headers)
response = conn.getresponse()
end = time.time()
print "http_post info:",end - start,response.status
#重定向
if response.status == 302:
Location=response.getheader('Location','')
#print "http_post 302 body:",response.read()
#print 'cd_chose.aspx enter the redirect',response
print conn.request('GET',Location,headers=self.headers)
response = conn.getresponse()
status,response = 302,Location
elif response.status == 200:
status,response = 200,''
else:
status,response = response.status,'does not support'
except Exception,ex:
print 'http_post -> error:',ex
status,response = 1,ex
finally:
if connDefault is None:
conn.close()
return status,response