Skip to content

Commit 9037941

Browse files
committed
Fix #183 disable raw websocket url when websocket option is false
1 parent c68583f commit 9037941

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/sockjs.coffee

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ generate_dispatcher = (options) ->
7575
t = (s) => [p('/([^/.]+)/([^/.]+)' + s), 'server', 'session']
7676
opts_filters = (options_filter='xhr_options') ->
7777
return ['h_sid', 'xhr_cors', 'cache_for', options_filter, 'expose']
78-
dispatcher = [
78+
prefix_dispatcher = [
7979
['GET', p(''), ['welcome_screen']],
8080
['GET', p('/iframe[0-9-.a-z_]*.html'), ['iframe', 'cache_for', 'expose']],
8181
['OPTIONS', p('/info'), opts_filters('info_options')],
8282
['GET', p('/info'), ['xhr_cors', 'h_no_cache', 'info', 'expose']],
8383
['OPTIONS', p('/chunking_test'), opts_filters()],
84-
['POST', p('/chunking_test'), ['xhr_cors', 'expect_xhr', 'chunking_test']],
85-
['GET', p('/websocket'), ['raw_websocket']],
84+
['POST', p('/chunking_test'), ['xhr_cors', 'expect_xhr', 'chunking_test']]
85+
]
86+
transport_dispatcher = [
8687
['GET', t('/jsonp'), ['h_sid', 'h_no_cache', 'jsonp']],
8788
['POST', t('/jsonp_send'), ['h_sid', 'h_no_cache', 'expect_form', 'jsonp_send']],
8889
['POST', t('/xhr'), ['h_sid', 'h_no_cache', 'xhr_cors', 'xhr_poll']],
@@ -97,13 +98,17 @@ generate_dispatcher = (options) ->
9798

9899
# TODO: remove this code on next major release
99100
if options.websocket
100-
dispatcher.push(
101+
prefix_dispatcher.push(
102+
['GET', p('/websocket'), ['raw_websocket']])
103+
transport_dispatcher.push(
101104
['GET', t('/websocket'), ['sockjs_websocket']])
102105
else
103106
# modify urls to return 404
104-
dispatcher.push(
107+
prefix_dispatcher.push(
108+
['GET', p('/websocket'), ['cache_for', 'disabled_transport']])
109+
transport_dispatcher.push(
105110
['GET', t('/websocket'), ['cache_for', 'disabled_transport']])
106-
return dispatcher
111+
return prefix_dispatcher.concat(transport_dispatcher)
107112

108113
class Listener
109114
constructor: (@options, emit) ->

0 commit comments

Comments
 (0)