Unexpected redirect behavior

requests is getting (incorrectly) stuck in a redirect loop for an image.
If I turn off redirects and manually step through the requests, each time pointing the new url to the value in the Location header, it works as expected (below is the response.headers + the response.status_code):

```
{'Content-Length': '178', 'Server': 'nginx', 'Connection': 'keep-alive', 'Location': 'https://wiki.wildberries.ru/img/2016/03/dffgfgdf-150x150.jpg', 'Date': 'Sun, 01 May 2016 01:27:25 GMT', 'Content-Type': 'text/html'} 301
{'Content-Length': '178', 'Set-Cookie': '__utmp=1', 'Server': 'nginx', 'Connection': 'close', 'Location': 'http://abenz.ru/wt', 'Date': 'Sun, 01 May 2016 01:27:26 GMT', 'Content-Type': 'text/html'} 301
{'Content-Length': '0', 'Expires': 'Thu, 21 Jul 1977 07:30:00 GMT', 'Keep-Alive': 'timeout=5, max=100', 'Server': 'Apache/2.4.10 (Debian)', 'Last-Modified': 'Sun, 01 May 2016 01:27:26 GMT', 'Connection': 'Keep-Alive', 'LOCATION': 'https://wiki.wildberries.ru/img/2016/03/dffgfgdf-150x150.jpg', 'Pragma': 'no-cache', 'Cache-Control': 'max-age=0', 'Date': 'Sun, 01 May 2016 01:27:26 GMT', 'Content-Type': 'text/html; charset=utf-8'} 302
{'Test-Head': '1', 'Accept-Ranges': 'bytes', 'Content-Length': '9753', 'Server': 'nginx', 'Last-Modified': 'Thu, 17 Mar 2016 15:14:49 GMT', 'Connection': 'close', 'ETag': '"56eac9e9-2619"', 'Date': 'Sun, 01 May 2016 01:27:27 GMT', 'Content-Type': 'image/jpeg'} 200
```

If I turn on logging while redirects is enabled, I see this.  Notice that once it hits the abenz[.]ru domain, the location is never updated.

```
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): wiki.wildberries.ru
send: 'GET /img/2016/03/dffgfgdf-150x150.jpg HTTP/1.1\r\nHost: wiki.wildberries.ru\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nuser-agent: Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0)\r\n\r\n'
reply: 'HTTP/1.1 301 Moved Permanently\r\n'
header: Server: nginx
header: Date: Sun, 01 May 2016 01:50:21 GMT
header: Content-Type: text/html
header: Content-Length: 178
header: Connection: keep-alive
header: Location: https://wiki.wildberries.ru/img/2016/03/dffgfgdf-150x150.jpg
DEBUG:requests.packages.urllib3.connectionpool:"GET /img/2016/03/dffgfgdf-150x150.jpg HTTP/1.1" 301 178
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): wiki.wildberries.ru
send: 'GET /img/2016/03/dffgfgdf-150x150.jpg HTTP/1.1\r\nHost: wiki.wildberries.ru\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nuser-agent: Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0)\r\n\r\n'
reply: 'HTTP/1.1 301 Moved Permanently\r\n'
header: Server: nginx
header: Date: Sun, 01 May 2016 01:50:22 GMT
header: Content-Type: text/html
header: Content-Length: 178
header: Connection: close
header: Location: http://abenz.ru/wt
header: Set-Cookie: __utmp=1
DEBUG:requests.packages.urllib3.connectionpool:"GET /img/2016/03/dffgfgdf-150x150.jpg HTTP/1.1" 301 178
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): abenz.ru
send: 'GET /wt HTTP/1.1\r\nHost: abenz.ru\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nuser-agent: Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0)\r\n\r\n'
reply: 'HTTP/1.1 302 Found\r\n'
header: Date: Sun, 01 May 2016 01:50:23 GMT
header: Server: Apache/2.4.10 (Debian)
header: Expires: Thu, 21 Jul 1977 07:30:00 GMT
header: Last-Modified: Sun, 01 May 2016 01:50:23 GMT
header: Cache-Control: max-age=0
header: Pragma: no-cache
header: LOCATION: https://wiki.wildberries.ru/img/2016/03/dffgfgdf-150x150.jpg
header: Content-Length: 0
header: Keep-Alive: timeout=5, max=100
header: Connection: Keep-Alive
header: Content-Type: text/html; charset=utf-8
DEBUG:requests.packages.urllib3.connectionpool:"GET /wt HTTP/1.1" 302 0
send: 'GET /wt HTTP/1.1\r\nHost: abenz.ru\r\nConnection: keep-alive\r\nCookie: __utmp=1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nuser-agent: Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0)\r\n\r\n'
reply: 'HTTP/1.1 302 Found\r\n'
header: Date: Sun, 01 May 2016 01:50:24 GMT
header: Server: Apache/2.4.10 (Debian)
header: Expires: Thu, 21 Jul 1977 07:30:00 GMT
header: Last-Modified: Sun, 01 May 2016 01:50:24 GMT
header: Cache-Control: max-age=0
header: Pragma: no-cache
header: LOCATION: https://wiki.wildberries.ru/img/2016/03/dffgfgdf-150x150.jpg
header: Content-Length: 0
header: Keep-Alive: timeout=5, max=99
header: Connection: Keep-Alive
header: Content-Type: text/html; charset=utf-8
DEBUG:requests.packages.urllib3.connectionpool:"GET /wt HTTP/1.1" 302 0
send: 'GET /wt HTTP/1.1\r\nHost: abenz.ru\r\nConnection: keep-alive\r\nCookie: __utmp=1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nuser-agent: Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0)\r\n\r\n'
...
```

The calls above are done via:

```
h = {'user-agent': 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0)'}
with requests.Session() as s:
    r = s.get(url, headers = h, timeout = HTTP_TIMEOUT_SECONDS) #, allow_redirects = False)
```


Was running older versions of urllib3 and requests.  Upgrading fixed it.


I am still getting the following error: _ssl.c:2580 or _ssl.c:2825

but when I am trying to post through SOAP UI on the same URL with basic Auth and SSL certificate , connection is going through and getting response.

Need your expert help , I am so stuck ...

attaching the basic auth 2 options which I am trying so far and the error message:


these are errors which I am encountering 
Option # 1

> > > import requests
> > > from requests.auth import HTTPBasicAuth
> > > auth = HTTPBasicAuth('auth_user', 'auth_pass')
> > > requests.post('https://my-site.com/rest_service', cert=('/Users/my_user/Desktop/auth_user.pfx', '/path/key'),  auth=auth)
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in <module>
> > >   File "/Users/my_user/anaconda/lib/python2.7/site-packages/requests/api.py", line 88, in post
> > >     return request('post', url, data=data, *_kwargs)
> > >   File "/Users/my_user/anaconda/lib/python2.7/site-packages/requests/api.py", line 44, in request
> > >     return session.request(method=method, url=url, *_kwargs)
> > >   File "/Users/my_user/anaconda/lib/python2.7/site-packages/requests/sessions.py", line 456, in request
> > >     resp = self.send(prep, *_send_kwargs)
> > >   File "/Users/my_user/anaconda/lib/python2.7/site-packages/requests/sessions.py", line 559, in send
> > >     r = adapter.send(request, *_kwargs)
> > >   File "/Users/my_user/anaconda/lib/python2.7/site-packages/requests/adapters.py", line 382, in send
> > >     raise SSLError(e, request=request)
> > > requests.exceptions.SSLError: [SSL] PEM lib (_ssl.c:2580)

Option # 2

> > > r = requests.post("https://my-site.com/rest_service", verify='/Users/my_user/Desktop/auth_user.pfx', data={}, auth=('auth_user', 'auth_pass'))
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in <module>
> > >   File "/Users/my_user/anaconda/lib/python2.7/site-packages/requests/api.py", line 88, in post
> > >     return request('post', url, data=data, *_kwargs)
> > >   File "/Users/my_user/anaconda/lib/python2.7/site-packages/requests/api.py", line 44, in request
> > >     return session.request(method=method, url=url, *_kwargs)
> > >   File "/Users/my_user/anaconda/lib/python2.7/site-packages/requests/sessions.py", line 456, in request
> > >     resp = self.send(prep, *_send_kwargs)
> > >   File "/Users/my_user/anaconda/lib/python2.7/site-packages/requests/sessions.py", line 559, in send
> > >     r = adapter.send(request, *_kwargs)
> > >   File "/Users/my_user/anaconda/lib/python2.7/site-packages/requests/adapters.py", line 382, in send
> > >     raise SSLError(e, request=request)
> > > requests.exceptions.SSLError: unknown error (_ssl.c:2825)


@nahonnyate Please don't piggyback on unrelated issues. This is particularly problematic as you _already_ have an open issue (#3137) that has us asking questions of you that you have not yet answered.


@Lukasa Sorry to miss my original thread, Let me respond the questions in my thread. Thanks for your help