Closed oucsaw closed 8 years ago
Curious. It worked for me with requests==2.10.0, where response.raw._connection.sock
is a ssl.SSLSocket
. Did it not work at all for you?
File "/srv/silver/local/lib/python2.7/site-packages/requests_negotiate/init.py", line 28, in get_hostname return socket.gethostbyaddr(response.raw._connection.sock.getpeername()[0])[0] AttributeError: 'WrappedSocket' object has no attribute 'getpeername'
.. and requests seems to be 2.10.0 (using python 2.7)
Are you using it over SSL? (silly question, but best to check)
answers his own question (yes)
Yes:
auth_token = requests_negotiate.HTTPNegotiateAuth()
url = 'https://server.ox.ac.uk/'
api = slumber.API(url,auth=auth_token)
api.person.get(q='%s:%s' % (lookup_query, lookup_key), format='json')
Will try to reproduce without the slumber module ...
I think that if you've got pyopenssl support available (i.e. requests.packages.urllib3.contrib.pyopenssl
doesn't raise an ImportError) it'll use that for preference over the builtin ssl
module, and that monkey-patches to use WrappedSocket.
I'm going to merge this and then tweak again to handle both cases.
minor tweak to use underlying socket class, not WrappedSocket (which has no getpeername)