lipp / lua-websockets

Websockets for Lua.
http://lipp.github.com/lua-websockets/
MIT License
396 stars 113 forks source link

Fixed #59: get response with selected subprotocol and ws headers #65

Closed KSDaemon closed 9 years ago

KSDaemon commented 9 years ago

Hi, guys! On this weekend i decided to implement this feature. But i was a bit confused: in client_ev we can not simply return headers, 'cause things are async. So i extended response form on_open function — now it returns websocket object, server selected protocol and all response headers. For sync client — all return points in connect function are extended appropriately.

lipp commented 9 years ago

@KSDaemon Great! Could you please also add a unit test to make this PR :100: ?

KSDaemon commented 9 years ago

@lipp Yeah. Can you point me where tests are and how to run them? I've found some related things in spec/* Is it there?

KSDaemon commented 9 years ago

Ups. Sorry, read the docs to the end :) Will try to run and create tests

KSDaemon commented 9 years ago

I've run the tests. There were: 41 successes / 1 failure / 5 errors / 0 pending : 15.716355 seconds Is it ok? Or all tests should pass?

KSDaemon commented 9 years ago

Here are all errors. May be i've been missing something...

Failure → ./spec/tools_spec.lua @ 51 The tools module URL parser works ./spec/tools_spec.lua:57: Expected objects to be the same. Passed in: (number) 80 Expected: (string) '80'

Error → ./spec/client_ev_spec.lua @ 10 ./spec/client_ev_spec.lua ./spec/client_ev_spec.lua:10: attempt to call global 'setloop' (a nil value)

Error → ./spec/ev_common_spec.lua @ 6 ./spec/ev_common_spec.lua ./spec/ev_common_spec.lua:6: attempt to call global 'setloop' (a nil value)

Error → ./spec/server_copas_spec.lua @ 10 ./spec/server_copas_spec.lua ./spec/server_copas_spec.lua:10: attempt to call global 'setloop' (a nil value)

Error → ./spec/server_ev_spec.lua @ 9 ./spec/server_ev_spec.lua ./spec/server_ev_spec.lua:9: attempt to call global 'setloop' (a nil value)

Error → ./spec/tools_spec.lua @ 92 The tools module URL parser works with IPv6 and WSS ./spec/tools_spec.lua:118: attempt to call global 'parse_url' (a nil value)

KSDaemon commented 9 years ago

Well... Interesting situation: Adding additional asserts to connect test in client_spec.lua results in failure, but  specially failing same tests in client_ev_spec.lua results in success. May be you can help... See diff for my last commit

lipp commented 9 years ago

ill look into it...

KSDaemon commented 9 years ago

Hi @lipp! How is it going?

lipp commented 9 years ago

sorry, ... pretty busy ... i didn't forget ...

lipp commented 9 years ago

i make a new PR, tests are working again on recent master