我已经使用 PoolManager 和 HTTPSConnectionPool 测试了一个“POST”请求。第一个有效,另一个给我一个:
urllib3.exceptions.MaxRetryError:
HTTPSConnectionPool(host='https://some.url.com', port=443):
Max retries exceeded with url: /some-api (Caused by <class 'socket.gaierror'>:
[Errno -2] Name or service not known)
这是我的 PoolManager 代码:
import urllib3
HOST = 'https://some.url.com'
PORT = 443
PATH = '/some-api'
xml_request = '<some xml tree/>'
manager = urllib3.PoolManager()
res = manager.request('POST', HOST+PATH, {'req':xml_request})
对于 HTTPSConnectonPool:
manager = urllib3.HTTPSConnectionPool(HOST, port=PORT)
res = manager.request('POST', PATH, {'req':xml_request})