Skip to content
Browse files

upgrade sockjs-protocol-0.3.3

  • Loading branch information...
1 parent e407780 commit 76c4bb526892f807a03bae2004268c7f5a888c2e @fafhrd91 committed Nov 15, 2012
View
2 CHANGES.txt
@@ -5,6 +5,8 @@ CHANGES
0.3.8 (Unreleased)
==================
+- Update sockjs-protocol-0.3.3
+
- Fix TypeError in Session.__str__ method
- Fix eventsource transport for gevent 1.0b3 version
View
2 README.rst
@@ -29,7 +29,7 @@ Example of sockjs route::
Client side code::
- <script src="http://cdn.sockjs.org/sockjs-0.3.min.js"></script>
+ <script src="http://cdn.sockjs.org/sockjs-0.3.4.min.js"></script>
<script>
var sock = new SockJS('http://localhost:8080/__sockjs__');
View
2 pyramid_sockjs/route.py
@@ -23,7 +23,7 @@
def add_sockjs_route(cfg, name='', prefix='/__sockjs__',
session=None, session_manager=None,
disable_transports=(),
- sockjs_cdn='http://cdn.sockjs.org/sockjs-0.3.2.min.js',
+ sockjs_cdn='http://cdn.sockjs.org/sockjs-0.3.4.min.js',
permission=None, decorator=None, cookie_needed=True,
per_user=True):
# set session manager
View
4 pyramid_sockjs/transports/xhrpolling.py
@@ -51,6 +51,8 @@ def process(self, session, request):
response = request.response
response.content_type = 'application/javascript; charset=UTF-8'
response.headerlist.extend(cors_headers(request))
+ response.headerlist.append(
+ ('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0'))
def finish(request):
session.release()
@@ -86,6 +88,8 @@ def process(self, session, request):
response = request.response
response.content_type = 'text/plain; charset=UTF-8'
response.headerlist.extend(cors_headers(request))
+ response.headerlist.append(
+ ('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0'))
data = request.body_file.read()
if not data:
View
3 pyramid_sockjs/transports/xhrstreaming.py
@@ -30,7 +30,8 @@ def __init__(self, session, request):
meth = request.method
self.headers = (
('Content-Type', 'application/javascript; charset=UTF-8'),
- ("Connection", "close"),
+ ('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0'),
+ ('Connection', 'close'),
session_cookie(request),
) + cors_headers(request)
View
4 setup.py
@@ -4,11 +4,11 @@
import multiprocessing # atexit exception
from setuptools import setup, find_packages
-version='0.3.7'
+version='0.3.8'
install_requires = ['setuptools',
'pyramid >= 1.3',
- 'gevent >= 1.0b2',
+ 'gevent >= 1.0rc1',
'gevent-websocket >= 0.3.6',
]
View
16 tests/sockjs-protocol-0.3.py → tests/sockjs-protocol-0.3.3.py
@@ -4,7 +4,7 @@
effort to define a protocol between in-browser
[SockJS-client](https://github.com/sockjs/sockjs-client) and its
server-side counterparts, like
-[SockJS-node](https://github.com/sockjs/sockjs-client). This should
+[SockJS-node](https://github.com/sockjs/sockjs-node). This should
help others to write alternative server implementations.
@@ -18,9 +18,9 @@
import json
import re
import unittest2 as unittest
-from utils import GET, GET_async, POST, POST_async, OPTIONS, old_POST_async
-from utils import WebSocket8Client
-from utils import RawHttpConnection
+from utils_03 import GET, GET_async, POST, POST_async, OPTIONS, old_POST_async
+from utils_03 import WebSocket8Client
+from utils_03 import RawHttpConnection
import uuid
@@ -732,6 +732,8 @@ def test_transport(self):
self.assertEqual(r['content-type'],
'application/javascript; charset=UTF-8')
self.verify_cors(r)
+ # iOS 6 caches POSTs. Make sure we send no-cache header.
+ self.verify_not_cached(r)
# Xhr transports receive json-encoded array of messages.
r = POST(url + '/xhr_send', body='["x"]')
@@ -743,6 +745,8 @@ def test_transport(self):
# is xml and shouts about it.
self.assertEqual(r['content-type'], 'text/plain; charset=UTF-8')
self.verify_cors(r)
+ # iOS 6 caches POSTs. Make sure we send no-cache header.
+ self.verify_not_cached(r)
r = POST(url + '/xhr')
self.assertEqual(r.status, 200)
@@ -839,6 +843,8 @@ def test_transport(self):
self.assertEqual(r['Content-Type'],
'application/javascript; charset=UTF-8')
self.verify_cors(r)
+ # iOS 6 caches POSTs. Make sure we send no-cache header.
+ self.verify_not_cached(r)
# The transport must first send 2KiB of `h` bytes as prelude.
self.assertEqual(r.read(), 'h' * 2048 + '\n')
@@ -1046,6 +1052,8 @@ def test_transport(self):
self.assertEqual(r.body, 'ok')
self.assertEqual(r.status, 200)
self.assertEqual(r['Content-Type'], 'text/plain; charset=UTF-8')
+ # iOS 6 caches POSTs. Make sure we send no-cache header.
+ self.verify_not_cached(r)
r = GET(url + '/jsonp?c=%63allback')
self.assertEqual(r.status, 200)
View
13 tests/utils.py → tests/utils_03.py
@@ -5,7 +5,6 @@
import socket
import re
-
class HttpResponse:
def __init__(self, method, url,
headers={}, body=None, async=False, load=True):
@@ -89,8 +88,10 @@ def received_message(self, m):
queue.put(unicode(str(m), 'utf-8'))
def read_from_connection(self, amount):
r = super(IntWebSocketClient, self).read_from_connection(amount)
- if not r:
- queue.put(Ellipsis)
+ if self.stream.closing:
+ queue.put((self.stream.closing.code, self.stream.closing.reason[2:]))
+ elif not r:
+ queue.put((1000, ""))
return r
self.client = IntWebSocketClient(url)
self.client.connect()
@@ -109,8 +110,10 @@ def send(self, data):
def recv(self):
try:
r = self.queue.get(timeout=1.0)
- if r is Ellipsis:
- raise self.ConnectionClosedException()
+ if isinstance(r, tuple):
+ ce = self.ConnectionClosedException()
+ (ce.code, ce.reason) = r
+ raise ce
return r
except:
self.close()

0 comments on commit 76c4bb5

Please sign in to comment.
Something went wrong with that request. Please try again.