NAME
Net::WebSocket::Handshake::Client
SYNOPSIS
my $hsk = Net::WebSocket::Handshake::Client->new(
#required
uri => 'ws://haha.test',
#optional
subprotocols => [ 'echo', 'haha' ],
#optional, to imitate a web client
origin => ..,
#optional, base 64 .. auto-created if not given
key => '..',
#optional, instances of Net::WebSocket::Handshake::Extension
extensions => \@extension_objects,
);
#Note the need to conclude the header text manually.
#This is by design, so you can add additional headers.
my $hdr = $hsk->create_header_text() . "\x0d\x0a";
my $b64 = $hsk->get_key();
#Validates the value of the “Sec-WebSocket-Accept” header;
#throws Net::WebSocket::X::BadAccept if not.
$hsk->validate_accept_or_die($accent_value);
DESCRIPTION
This class implements WebSocket handshake logic for a client.
Because Net::WebSocket tries to be agnostic about how you parse your HTTP headers, this class doesn’t do a whole lot for you: it’ll create a base64 key for you and create “starter” headers for you. It also can validate the Sec-WebSocket-Accept
header value from the server.
NOTE: create_header_text()
does NOT provide the extra trailing CRLF to conclude the HTTP headers. This allows you to add additional headers beyond what this class gives you.