Backport to support requests 0.8.2; fixes #79
This commit is contained in:
parent
24ce2dc6c0
commit
b288d89c15
7 changed files with 19 additions and 13 deletions
|
|
@ -1,3 +1,7 @@
|
|||
0.5.6
|
||||
-----
|
||||
- Backported to support requests 0.8.2
|
||||
|
||||
0.5.5
|
||||
-----
|
||||
- Fixed reconnection in the event of server restart
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ socketIO-client
|
|||
===============
|
||||
Here is a `socket.io <http://socket.io>`_ client library for Python. You can use it to write test code for your socket.io server.
|
||||
|
||||
Please note that this version implements `socket.io protocol 0.9 <https://github.com/learnboost/socket.io-spec>`_, which is compatible with `gevent-socketio <https://github.com/abourget/gevent-socketio>`_. If you want to communicate using `socket.io protocol 1.x <https://github.com/automattic/socket.io-protocol>`_, please use `socketIO-client 0.6.3 <https://pypi.python.org/pypi/socketIO-client/0.6.3>`_ or higher.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
|
@ -32,6 +34,7 @@ Activate isolated environment. ::
|
|||
|
||||
Launch your socket.io server. ::
|
||||
|
||||
npm install -g socket.io@0.9
|
||||
node serve-tests.js
|
||||
|
||||
For debugging information, run these commands first. ::
|
||||
|
|
@ -156,5 +159,5 @@ Credits
|
|||
- `Alexandre Bourget <https://github.com/abourget>`_ wrote `gevent-socketio <https://github.com/abourget/gevent-socketio>`_, which is a socket.io server written in Python.
|
||||
- `Paul Kienzle <https://github.com/pkienzle>`_, `Zac Lee <https://github.com/zratic>`_, `Josh VanderLinden <https://github.com/codekoala>`_, `Ian Fitzpatrick <https://github.com/ifitzpatrick>`_, `Lucas Klein <https://github.com/lukasklein>`_, `Rui Chicoria <https://github.com/rchicoria>`_, `Travis Odom <https://github.com/burstaholic>`_, `Patrick Huber <https://github.com/stackmagic>`_, `Brad Campbell <https://github.com/bradjc>`_, `Daniel <https://github.com/dabidan>`_, `Sean Arietta <https://github.com/sarietta>`_ submitted code to expand support of the socket.io protocol.
|
||||
- `Bernard Pratz <https://github.com/guyzmo>`_, `Francis Bull <https://github.com/franbull>`_ wrote prototypes to support xhr-polling and jsonp-polling.
|
||||
- `Eric Chen <https://github.com/taiyangc>`_, `Denis Zinevich <https://github.com/dzinevich>`_, `Thiago Hersan <https://github.com/thiagohersan>`_, `Nayef Copty <https://github.com/nayefc>`_, `Jörgen Karlsson <https://github.com/jorgen-k>`_, `Branden Ghena <https://github.com/brghena>`_ suggested ways to make the connection more robust.
|
||||
- `Eric Chen <https://github.com/taiyangc>`_, `Denis Zinevich <https://github.com/dzinevich>`_, `Thiago Hersan <https://github.com/thiagohersan>`_, `Nayef Copty <https://github.com/nayefc>`_, `Jörgen Karlsson <https://github.com/jorgen-k>`_, `Branden Ghena <https://github.com/brghena>`_, `Tim Landscheidt <https://github.com/scfc>_` suggested ways to make the connection more robust.
|
||||
- `Merlijn van Deen <https://github.com/valhallasw>`_, `Frederic Sureau <https://github.com/fredericsureau>`_, `Marcus Cobden <https://github.com/leth>`_, `Drew Hutchison <https://github.com/drewhutchison>`_, `wuurrd <https://github.com/wuurrd>`_, `Adam Kecer <https://github.com/amfg>`_, `Alex Monk <https://github.com/Krenair>`_, `Vishal P R <https://github.com/vishalwy>`_, `John Vandenberg <https://github.com/jayvdb>`_, `Thomas Grainger <https://github.com/graingert>`_ proposed changes that make the library more friendly and practical for you!
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
Release 0.6.1 #41 #52
|
||||
+ Update serve-tests.js
|
||||
+ Integrate serve-tests.js changes from sarietta
|
||||
= Put tests in index.html
|
||||
Update tests
|
||||
Merge sarietta's pull request
|
||||
Revive heartbeat as separate process
|
||||
Implement rooms #65
|
||||
2
setup.py
2
setup.py
|
|
@ -9,7 +9,7 @@ CHANGES = open(os.path.join(here, 'CHANGES.rst')).read()
|
|||
|
||||
setup(
|
||||
name='socketIO-client',
|
||||
version='0.5.5',
|
||||
version='0.5.6',
|
||||
description='A socket.io client library',
|
||||
long_description=README + '\n\n' + CHANGES,
|
||||
license='MIT',
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ except ImportError:
|
|||
|
||||
from .exceptions import (
|
||||
SocketIOError, ConnectionError, TimeoutError, PacketError)
|
||||
from .symmetries import _get_text
|
||||
from .transports import (
|
||||
_get_response, TRANSPORTS,
|
||||
_WebsocketTransport, _XHR_PollingTransport, _JSONP_PollingTransport)
|
||||
|
|
@ -515,7 +516,7 @@ def _get_socketIO_session(is_secure, base_url, **kw):
|
|||
response = _get_response(requests.get, server_url, **kw)
|
||||
except TimeoutError as e:
|
||||
raise ConnectionError(e)
|
||||
response_parts = response.text.split(':')
|
||||
response_parts = _get_text(response).split(':')
|
||||
return _SocketIOSession(
|
||||
id=response_parts[0],
|
||||
heartbeat_timeout=int(response_parts[1]),
|
||||
|
|
|
|||
5
socketIO_client/symmetries.py
Normal file
5
socketIO_client/symmetries.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
def _get_text(response):
|
||||
try:
|
||||
return response.text # requests 2.7.0
|
||||
except AttributeError:
|
||||
return response.content # requests 0.8.2
|
||||
|
|
@ -10,6 +10,7 @@ import time
|
|||
import websocket
|
||||
|
||||
from .exceptions import ConnectionError, TimeoutError
|
||||
from .symmetries import _get_text
|
||||
|
||||
|
||||
if not hasattr(websocket, 'create_connection'):
|
||||
|
|
@ -223,7 +224,7 @@ class _XHR_PollingTransport(_AbstractTransport):
|
|||
params=self._params,
|
||||
timeout=timeout or TIMEOUT_IN_SECONDS,
|
||||
stream=True)
|
||||
response_text = response.text
|
||||
response_text = _get_text(response)
|
||||
if not response_text.startswith(BOUNDARY):
|
||||
yield response_text
|
||||
return
|
||||
|
|
@ -279,7 +280,7 @@ class _JSONP_PollingTransport(_AbstractTransport):
|
|||
params=self._params,
|
||||
headers={'content-type': 'text/javascript; charset=UTF-8'},
|
||||
timeout=timeout or TIMEOUT_IN_SECONDS)
|
||||
response_text = response.text
|
||||
response_text = _get_text(response)
|
||||
try:
|
||||
self._id, response_text = self.RESPONSE_PATTERN.match(
|
||||
response_text).groups()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue