这是一个奇怪的活动,cURL和Python对requests
模块的响应不同。另外,Python非常慢:cURL大约需要6秒,但是Python需要2分钟。你知道吗
我的命令是:
curl -L -s -k --request GET \
--url "https://$1/api/maintenance/maintenance/dual_image_config" \
--header 'Cache-Control: no-cache' \
--header 'Accept-Encoding: gzip, deflate, sdch' \
--header 'Content-Type: application/json' \
--header 'Connection: keep-alive'
旋度响应为:
{ "state_1": "Active", "state_2": "stand-by", "current_active_image": "Image-1", "id": 1}
我的Python代码是:
import requests, sys
DEFAULT_HEADER = {"Accept-Encoding": "gzip, deflate, br",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"}
url = "https://{0}/api/maintenance/maintenance/dual_image_config".format(sys.argv[1])
response = requests.get(url="", data=None, headers=DEFAULT_HEADER , verify=False)
Python响应response.text
是:
'0121\r\n{ "state_1": "Active", "state_2": "stand-by", "current_active_image": "Image-1", "id": 1}\r\n0\r\n\r\n'
它将有0121\r\n&;\r\n0\r\n\r\n在start和begin中,我试图更改请求头和编码,但它不起作用,为什么它得到不同的响应,而且如此缓慢?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐