Skip to content

Commit

Permalink
fix bug in Mojo::Transaction::WebSocket where an unsupported protocol…
Browse files Browse the repository at this point in the history
… could be selected automatically
  • Loading branch information
kraih committed Oct 5, 2015
1 parent 2c0a855 commit 4c13e33
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 3 additions & 1 deletion Changes
@@ -1,6 +1,8 @@

6.23 2015-10-04
6.23 2015-10-05
- Improved documentation browser CSS.
- Fixed bug in Mojo::Transaction::WebSocket where an unsupported protocol
could be selected automatically.
- Fixed small redirect bug in Mojo::UserAgent::Transactor.

6.22 2015-09-26
Expand Down
8 changes: 2 additions & 6 deletions lib/Mojo/Transaction/WebSocket.pm
Expand Up @@ -234,15 +234,11 @@ sub server_close {
}

sub server_handshake {
my $self = shift;

my $self = shift;
my $res_headers = $self->res->headers;
$res_headers->upgrade('websocket')->connection('Upgrade');
my $req_headers = $self->req->headers;
($req_headers->sec_websocket_protocol // '') =~ /^\s*([^,]+)/
and $res_headers->sec_websocket_protocol($1);
$res_headers->sec_websocket_accept(
_challenge($req_headers->sec_websocket_key));
_challenge($self->req->headers->sec_websocket_key));
}

sub server_open { shift->{open}++ }
Expand Down
2 changes: 1 addition & 1 deletion t/mojolicious/websocket_lite_app.t
Expand Up @@ -123,7 +123,7 @@ $t->websocket_ok('/echo')->send_ok('hello again')
my $headers = {DNT => 1, 'Sec-WebSocket-Key' => 'NTA2MDAyMDU1NjMzNjkwMg=='};
$t->websocket_ok('/echo' => $headers => ['foo', 'bar', 'baz'])
->header_is('Sec-WebSocket-Accept' => 'I+x5C3/LJxrmDrWw42nMP4pCSes=')
->header_is('Sec-WebSocket-Protocol' => 'foo')->send_ok('hello')
->header_is('Sec-WebSocket-Protocol' => undef)->send_ok('hello')
->message_ok->message_is('echo: hello')->finish_ok;
is $t->tx->req->headers->dnt, 1, 'right "DNT" value';
is $t->tx->req->headers->sec_websocket_protocol, 'foo, bar, baz',
Expand Down

0 comments on commit 4c13e33

Please sign in to comment.