Skip to content

Commit

Permalink
use version in subprotocol examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 23, 2013
1 parent f6e43bd commit 6163118
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,6 +1,6 @@

4.04 2013-05-23
- Added WebSocket protocol support to Mojo::UserAgent::Transactor.
- Added WebSocket subprotocol support to Mojo::UserAgent::Transactor.

4.03 2013-05-21
- Fixed redirect support in get command.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/UserAgent.pm
Expand Up @@ -972,7 +972,7 @@ non-blocking.
$ua->websocket('ws://localhost:3000' => sub {...});
$ua->websocket(
'ws://localhost:3000' => {DNT => 1} => ['proto'] => sub {...});
'ws://localhost:3000' => {DNT => 1} => ['v1.proto'] => sub {...});
Open a non-blocking WebSocket connection with transparent handshake, takes the
same arguments as L<Mojo::UserAgent::Transactor/"websocket">. The callback
Expand Down
6 changes: 3 additions & 3 deletions lib/Mojo/UserAgent/Transactor.pm
Expand Up @@ -134,10 +134,10 @@ sub websocket {
my $self = shift;

# New WebSocket transaction
my $protos = ref $_[-1] eq 'ARRAY' ? pop : [];
my $sub = ref $_[-1] eq 'ARRAY' ? pop : [];
my $tx = $self->tx(GET => @_);
my $req = $tx->req;
$req->headers->sec_websocket_protocol(join ', ', @$protos) if @$protos;
$req->headers->sec_websocket_protocol(join ', ', @$sub) if @$sub;
my $url = $req->url;
my $proto = $url->protocol;
$url->scheme($proto eq 'wss' ? 'https' : 'http') if $proto;
Expand Down Expand Up @@ -413,7 +413,7 @@ handshake if possible.
=head2 websocket
my $tx = $t->websocket('ws://localhost:3000');
my $tx = $t->websocket('ws://localhost:3000' => {DNT => 1} => ['proto']);
my $tx = $t->websocket('ws://localhost:3000' => {DNT => 1} => ['v1.proto']);
Versatile L<Mojo::Transaction::HTTP> transaction builder for WebSocket
handshake requests.
Expand Down
2 changes: 1 addition & 1 deletion lib/Test/Mojo.pm
Expand Up @@ -876,7 +876,7 @@ Opposite of C<text_like>.
=head2 websocket_ok
$t = $t->websocket_ok('/echo');
$t = $t->websocket_ok('/echo' => {DNT => 1} => ['proto']);
$t = $t->websocket_ok('/echo' => {DNT => 1} => ['v1.proto']);
Open a WebSocket connection with transparent handshake, takes the same
arguments as L<Mojo::UserAgent/"websocket">, except for the callback.
Expand Down

0 comments on commit 6163118

Please sign in to comment.