AnyEvent-WebSocket-Client

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    Provide your own CA certificates file instead of using the system
    default for SSL/TLS verification.

 protocol_version

    The protocol version. See Protocol::WebSocket for the list of supported
    WebSocket protocol versions.

 subprotocol

    List of subprotocols to request from the server. This class will throw
    an exception if none of the protocols are supported by the server.

 http_headers

    Extra headers to include in the initial request. May be either
    specified as a hash reference, or an array reference. For example:

     AnyEvent::WebSocket::Client->new(
       http_headers => {
         'X-Foo' => 'bar',

lib/AnyEvent/WebSocket/Client.pm  view on Meta::CPAN

Provide your own CA certificates file instead of using the system default for
SSL/TLS verification.

=head2 protocol_version

The protocol version.  See L<Protocol::WebSocket> for the list of supported
WebSocket protocol versions.

=head2 subprotocol

List of subprotocols to request from the server.  This class will throw an
exception if none of the protocols are supported by the server.

=head2 http_headers

Extra headers to include in the initial request.  May be either specified
as a hash reference, or an array reference.  For example:

 AnyEvent::WebSocket::Client->new(
   http_headers => {
     'X-Foo' => 'bar',

t/anyevent_websocket_client.t  view on Meta::CPAN

      AnyEvent::WebSocket::Client->new( subprotocol => 'foo' )->subprotocol,
      ['foo'],
    );

    my $connection = AnyEvent::WebSocket::Client->new(subprotocol => ['foo','bar','baz'])->connect($uri)->recv;
    is($last_handshake->res->subprotocol, 'bar', 'server agreed to bar');
    is($connection->subprotocol, 'bar', 'connection also has bar');

    eval { AnyEvent::WebSocket::Client->new(subprotocol => ['foo','baz'])->connect($uri)->recv };
    my $error = $@;
    like $error, qr{no subprotocol in response}, 'bad protocol throws an exception';

    eval { AnyEvent::WebSocket::Client->new(subprotocol => ['klingon','cardasian'])->connect($uri)->recv };
    $error = $@;
    like $error, qr{subprotocol mismatch, requested: klingon, cardasian, got: romulan}, 'bad protocol throws an exception';

  };

  subtest http_headers => sub {

    is(
      AnyEvent::WebSocket::Client->new( http_headers => { 'X-Foo' => 'bar', 'X-Baz' => [ 'abc', 'def' ] } )->http_headers,
      [ 'X-Baz' => 'abc',
        'X-Baz' => 'def',
        'X-Foo' => 'bar', ]



( run in 0.361 second using v1.01-cache-2.11-cpan-496ff517765 )