lipp / lua-websockets

Websockets for Lua.

Home Page:http://lipp.github.com/lua-websockets/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request for functionality: get response with selected subprotocol

KSDaemon opened this issue · comments

Hi!
Another one problem: if websocket client send multiple ws subprotocols, then server can choose one, and answer with corresponding header. On client side we should have a possibility to know that answer. Cause application logic may rely on that.

agree. we can add a second return value to connect

local ok,protocol = ws:connect('ws://foo.bar', {'proto1','proto2'})
if ok then
  print('server has chosen', protocol)
end

May be client/server also can get all headers from handshake?

ok, so you suggest:

local ok,headers = ws:connect(...)

or

local ok,protocol,headers = ws:connect(...)

i am ok with both options

I suggest ok,protocol,headers.
Also may be allows client/server add some headers manually. But I do not know for what it may be needed.

ok, great.

regarding specifying header when connecting: i dont like to add functionality without somebody nedding it, though. every feature has to be tested and maintained, espacially if they are seldom or rather never used.

Hi guys! I vote for local ok,protocol,headers = ws:connect(...)
That would be enough.

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.

there is a new PR #73