Python urllib3.exceptions 模块,ProtocolError() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用urllib3.exceptions.ProtocolError()

项目:rets-django    作者:bgirer    | 项目源码 | 文件源码
def fetch_listing_images(client, listing):
    """
    Makes use of some built-in rets-python methods to get image URLs for a listing. Note:
    this function (and get_listing_image()) were only necessary because rets-python failed
    to return anything useful with its Record.get_object() method when the location
    parameter was set to True.
    """
    headers = {'Accept': '*/*'}
    payload = {'Resource': 'Property', 'Type': 'Photo',
               'ID': _build_entity_object_ids(
                       listing.resource_key), 'Location': 1}
    encoding = 'utf-8'
    try:
        response = client.http._http_post(client.http._url_for('GetObject'),
                                          headers=headers, payload=payload)
    except (ProtocolError, ConnectionError, ConnectionResetError):
        client.http.login()
        response = client.http._http_post(client.http._url_for('GetObject'),
                                          headers=headers, payload=payload)
    multipart = MultipartDecoder.from_response(response, encoding)
    return multipart.parts