NAME
Protocol::WebSocket::Fast::ConnectRequest - Client-initiated HTTP request for establishing websocket connection
SYNOPSIS
use Protocol::WebSocket::Fast;
# client creates connect requests
my $request = Protocol::WebSocket::Fast::ConnectRequest->new({
uri => "ws://example.com/",
headers => {'Origin' => 'http://www.crazypanda.ru'},
ws_version => 13,
ws_protocol => "chat",
ws_extensions => [["ext1"], ["ext2", {arg1 => 1}]],
# ... other params that Protocol::HTTP::Request supports
});
# server parses connect requests
$request = $server_parser->accept($data);
$request->ws_key;
$request->ws_version;
$request->ws_protocol;
$request->ws_extensions;
$request->error;
DESCRIPTION
A request for connecting to websocket server. This class extends Protocol::HTTP::Request with websocket-related details, so all methods of Protocol::HTTP::Request also apply.
METHODS
new([\%params])
Creates new connect request object from params (or empty, if no params specified).
Parameters are everything that Protocol::HTTP::Request's new()
supports plus the following:
- ws_key
-
See rfc6455 (look for
Sec-WebSocket-Key
) - ws_version
-
See rfc6455 (look for
Sec-WebSocket-Version
).Version must be at least
13
because previous versions were buggy. - ws_protocol
-
Identifies application specific communication protocol.
See rfc6455 (look for
Sec-WebSocket-Protocol
). - ws_extensions => \@extensions
-
Additional extensions, which client would like to use. The extensions, which are provided by the module and enabled by user (default), will be added automatically by Protocol::WebSocket::Fast::ClientParser.
ws_key([$key])
Get/set websocket key.
ws_version([$version])
Get/set websocket version.
ws_protocol([$protocol])
Get/set application specific communication protocol
ws_extensions([\@extensions])
Get/set websocket additional extensions
ws_version_supported()
Returns true if websocket version is supported by the package
error
XS::ErrorCode object which represents Perl API for convenient C++ std::error_code
subsystem. Possible errors are described in Protocol::WebSocket::Fast::Error, Protocol::HTTP::Error.
SEE ALSO
Protocol::WebSocket::Fast::ClientParser
Protocol::WebSocket::Fast::ConnectResponse