websocket: store sub protocol value for later use in encode_and_send_ws_frame()

- the ws connection pointer can be set null if the browser closes the
  connection
- patch by Vitaliy Aleksandrov, FS#364

(cherry picked from commit 438eafc92ecf9d3b52f95c9952bc26b147fdf328)