@
yakczh HeaderData= <<"Accept-Encoding: gzip, deflate\r\nSec-WebSocket-Key\r\nVpFuKOmlNacJn3CuGOrd9w==">>,
这行错了吧,应该是
HeaderData= <<"Accept-Encoding: gzip, deflate\r\nSec-WebSocket-Key: VpFuKOmlNacJn3CuGOrd9w==">>,
中间那行是
HeaderList1 = [list_to_tuple(binary:split(Header, <<": ">>)) || Header <- HeaderList]
整段如下
HeaderData= <<"Accept-Encoding: gzip, deflate\r\nSec-WebSocket-Key: VpFuKOmlNacJn3CuGOrd9w==">>,
HeaderList = binary:split(HeaderData, <<"\r\n">>, [global]),
HeaderList1 = [list_to_tuple(binary:split(Header, <<": ">>)) || Header <- HeaderList],
{_, SecWebSocketKey} = lists:keyfind(<<"Sec-WebSocket-Key">>, 1, HeaderList1).
输出结果
> SecWebSocketKey.
<<"VpFuKOmlNacJn3CuGOrd9w==">>