4

我已经使用 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})
4

1 回答 1

4

https://some.url.com不是主机名或 IP 地址,而是 URL。因此,您将错误的信息提供给HTTPSConnectionPool.

此外,PoolManagerHTTPSConnectionPool不在同一个抽象级别。PoolManager为您管理ConnectionPool实例。

于 2014-06-11T10:16:34.483 回答