backport of subprotocol support
Merged bug25828 into default