Skip to content

Commit

Permalink
no need for a next attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 11, 2016
1 parent 78d62c0 commit 6e729ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
1 change: 0 additions & 1 deletion Changes
Expand Up @@ -10,7 +10,6 @@
attribute.
- Added SNI support to all built-in web servers. (bpmedley, sri)
- Added module Mojo::WebSocket. (batman)
- Added next attribute to Mojo::Transaction::HTTP.
- Updated jQuery to version 2.2.0.
- Improve mtime attribute in Mojo::Asset::Memory to default to the value of
$^T.
Expand Down
8 changes: 4 additions & 4 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -85,9 +85,9 @@ sub _build_tx {

# WebSocket
if ($tx->req->is_handshake) {
my $ws = Mojo::Transaction::WebSocket->new(handshake => $tx);
my $ws = $self->{connections}{$id}{next}
= Mojo::Transaction::WebSocket->new(handshake => $tx);
$self->emit(request => server_handshake $ws);
$tx->next($ws->handshake(undef));
}

# HTTP
Expand Down Expand Up @@ -122,10 +122,10 @@ sub _finish {
delete($c->{tx})->server_close;

# Upgrade connection to WebSocket
if (my $ws = $tx->next) {
if (my $ws = delete $c->{next}) {

# Successful upgrade
if ($ws->handshake($tx->next(undef))->res->code == 101) {
if ($ws->handshake->res->code == 101) {
$c->{tx} = $ws;
weaken $self;
$ws->on(resume => sub { $self->_write($id) });
Expand Down
10 changes: 1 addition & 9 deletions lib/Mojo/Transaction/HTTP.pm
@@ -1,7 +1,7 @@
package Mojo::Transaction::HTTP;
use Mojo::Base 'Mojo::Transaction';

has [qw(next previous)];
has 'previous';

sub client_close {
my ($self, $close) = @_;
Expand Down Expand Up @@ -244,14 +244,6 @@ Emitted for unexpected C<1xx> responses that will be ignored.
L<Mojo::Transaction::HTTP> inherits all attributes from L<Mojo::Transaction>
and implements the following new ones.
=head2 next
my $next = $tx->next;
$tx = $tx->next(Mojo::Transaction::WebSocket->new);
Follow-up transaction for connections that get upgraded to a different protocol,
usually a L<Mojo::Transaction::WebSocket> object.
=head2 previous
my $previous = $tx->previous;
Expand Down

0 comments on commit 6e729ea

Please sign in to comment.