Failed to open a certain url

I opened debug info for `requests` and request an URL:

    import logging
    import requests
    
    from http.client import HTTPConnection
    HTTPConnection.debuglevel = 1
    logging.basicConfig()
    logging.getLogger().setLevel(logging.DEBUG)
    requests_log = logging.getLogger("requests.packages.urllib3")
    requests_log.setLevel(logging.DEBUG)
    requests_log.propagate = True
    requests.get('http://uae.souq.com/ae-ar/apple-iphone-7-with-facetime-32gb-4g-lte-gold-11526690/i/')

It outputs:

> DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP
> connection (1): uae.souq.com send: b'GET
> /ae-ar/apple-iphone-7-with-facetime-32gb-4g-lte-gold-11526690/i/
> HTTP/1.1\r\nHost: uae.souq.com\r\nAccept: */*\r\nUser-Agent:
> python-requests/2.12.4\r\nConnection: keep-alive\r\nAccept-Encoding:
> gzip, deflate\r\n\r\n' reply: 'HTTP/1.1 301 Moved Permanently\r\n'
> DEBUG:requests.packages.urllib3.connectionpool:http://uae.souq.com:80
> "GET /ae-ar/apple-iphone-7-with-facetime-32gb-4g-lte-gold-11526690/i/
> HTTP/1.1" 301 None
> WARNING:requests.packages.urllib3.connectionpool:Failed to parse
> headers
> (url=http://uae.souq.com:80/ae-ar/apple-iphone-7-with-facetime-32gb-4g-lte-gold-11526690/i/):
> [MissingHeaderBodySeparatorDefect()], unparsed data:
> 'Ø¹-Ù\x81Ù\x8aØ³-ØªØ§Ù\x8aÙ\x85-32-Ø¬Ù\x8aØ¬Ø§-Ø§Ù\x84Ø¬Ù\x8aÙ\x84-Ø§Ù\x84Ø±Ø§Ø¨Ø¹-Ø§Ù\x84-ØªÙ\x8a-Ø§Ù\x8a-Ø°Ù\x87Ø¨Ù\x8a-11526690/i/\r\nPragma:
> no-cache\r\nServer: Apache\r\nStrict-Transport-Security:
> max-age=0\r\nVary: Accept-Encoding\r\nX-Content-Type-Options:
> nosniff\r\nX-Frame-Options: SAMEORIGIN\r\nContent-Length: 20\r\nDate:
> Wed, 08 Mar 2017 16:20:30 GMT\r\nConnection: keep-alive\r\nSet-Cookie:
> PLATEFORMC=ae; expires=Thu, 08-Mar-2018 16:20:30 GMT; path=/;
> domain=.souq.com\r\nSet-Cookie:
> PHPSESSID=gdbudqf2d734i499du12qac0bofbjjvo; path=/; domain=.souq.com;
> HttpOnly\r\nSet-Cookie: PLATEFORML=ar; expires=Thu, 08-Mar-2018
> 16:20:30 GMT; path=/; domain=.souq.com\r\nSet-Cookie:
> c_Ident=14889900303248; expires=Sat, 06-Mar-2027 16:20:30 GMT; path=/;
> domain=.souq.com\r\nSet-Cookie: registration_source=deleted;
> expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;
> domain=.souq.com\r\nSet-Cookie: registration_failed=deleted;
> expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;
> domain=.souq.com\r\nSet-Cookie: login_source=deleted; expires=Thu,
> 01-Jan-1970 00:00:01 GMT; path=/; domain=.souq.com\r\nSet-Cookie:
> login_failed=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;
> domain=.souq.com\r\nSet-Cookie: BUYER_CITY_SELECTED=89; expires=Fri,
> 07-Apr-2017 16:20:30 GMT; path=/\r\nSet-Cookie: UserViews=11526690;
> expires=Fri, 07-Apr-2017 16:20:30 GMT; path=/\r\nSet-Cookie:
> NSC_tpvr-72.52.8.197-80=ffffffff2d81ae8345525d5f4f58455e445a4a423660;path=/;httponly\r\n\r\n' Traceback (most recent call last):   File
> "/Users/Sona/work/projects/1688Crawler/myenv/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py",
> line 403, in _make_request
>     assert_header_parsing(httplib_response.msg)   File "/Users/Sona/work/projects/1688Crawler/myenv/lib/python3.5/site-packages/requests/packages/urllib3/util/response.py",
> line 66, in assert_header_parsing
>     raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
> requests.packages.urllib3.exceptions.HeaderParsingError:
> [MissingHeaderBodySeparatorDefect()], unparsed data:
> 'Ø¹-Ù\x81Ù\x8aØ³-ØªØ§Ù\x8aÙ\x85-32-Ø¬Ù\x8aØ¬Ø§-Ø§Ù\x84Ø¬Ù\x8aÙ\x84-Ø§Ù\x84Ø±Ø§Ø¨Ø¹-Ø§Ù\x84-ØªÙ\x8a-Ø§Ù\x8a-Ø°Ù\x87Ø¨Ù\x8a-11526690/i/\r\nPragma:
> no-cache\r\nServer: Apache\r\nStrict-Transport-Security:
> max-age=0\r\nVary: Accept-Encoding\r\nX-Content-Type-Options:
> nosniff\r\nX-Frame-Options: SAMEORIGIN\r\nContent-Length: 20\r\nDate:
> Wed, 08 Mar 2017 16:20:30 GMT\r\nConnection: keep-alive\r\nSet-Cookie:
> PLATEFORMC=ae; expires=Thu, 08-Mar-2018 16:20:30 GMT; path=/;
> domain=.souq.com\r\nSet-Cookie:
> PHPSESSID=gdbudqf2d734i499du12qac0bofbjjvo; path=/; domain=.souq.com;
> HttpOnly\r\nSet-Cookie: PLATEFORML=ar; expires=Thu, 08-Mar-2018
> 16:20:30 GMT; path=/; domain=.souq.com\r\nSet-Cookie:
> c_Ident=14889900303248; expires=Sat, 06-Mar-2027 16:20:30 GMT; path=/;
> domain=.souq.com\r\nSet-Cookie: registration_source=deleted;
> expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;
> domain=.souq.com\r\nSet-Cookie: registration_failed=deleted;
> expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;
> domain=.souq.com\r\nSet-Cookie: login_source=deleted; expires=Thu,
> 01-Jan-1970 00:00:01 GMT; path=/; domain=.souq.com\r\nSet-Cookie:
> login_failed=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;
> domain=.souq.com\r\nSet-Cookie: BUYER_CITY_SELECTED=89; expires=Fri,
> 07-Apr-2017 16:20:30 GMT; path=/\r\nSet-Cookie: UserViews=11526690;
> expires=Fri, 07-Apr-2017 16:20:30 GMT; path=/\r\nSet-Cookie:
> NSC_tpvr-72.52.8.197-80=ffffffff2d81ae8345525d5f4f58455e445a4a423660;path=/;httponly\r\n\r\n'

You can see it output a warning `Failed to parse headers` then it just hangs here. 

ENV:

    Python 3.5.2 (default, Aug 16 2016, 05:35:40) 
    [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin

    requests (2.12.4) Failed
    requests (2.13.0) Failed


This is an error in the standard library caused by a misbehaviour in their header parsing logic. The problem is gone in Python 3.6: I recommend you upgrade. :smile:

@Lukasa, are you sure this is fixed in 3.6? The redirect URL being passed back is encoded as utf-8 but we're decoding it as ISO-8859-1 which is what's causing the issues. I'm getting a `TooManyRedirect` exception when trying to use Python3.6 but the request works if I pass the properly decoded Location header: `http://uae.souq.com/ae-ar/ابل-ايفون-7-مع-فيس-تايم-32-جيجا-الجيل-الرابع-ال-تي-اي-ذهبي-11526690/i/`.

It depends on what you want to call "the issue". If the issue is the header parsing error, that's fixed in 3.6. If the issue is the redirect loop, this is a dupe of #3888.