Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
all client_read methods have been removed
  • Loading branch information
kraih committed Jan 9, 2016
1 parent 270a5f3 commit 419bf40
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Channel/HTTP/Client.pm
Expand Up @@ -3,9 +3,9 @@ use Mojo::Base 'Mojo::Channel::HTTP';

sub read {
my ($self, $chunk) = @_;
my $tx = $self->{tx};

# Skip body for HEAD request
my $tx = $self->{tx};
my $res = $tx->res;
$res->content->skip_body(1) if uc $tx->req->method eq 'HEAD';
return unless $res->parse($chunk)->is_finished;
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Channel/WebSocket.pm
Expand Up @@ -3,8 +3,8 @@ use Mojo::Base 'Mojo::Channel';

sub read {
my ($self, $chunk) = @_;
my $tx = $self->{tx};

my $tx = $self->{tx};
$self->{read} .= $chunk // '';
while (my $frame = $tx->parse_frame(\$self->{read})) {
$tx->finish(1009) and last unless ref $frame;
Expand Down
9 changes: 0 additions & 9 deletions lib/Mojo/Transaction.pm
Expand Up @@ -27,7 +27,6 @@ sub client_close {
$self->server_close;
}

sub client_read { croak 'Method "client_read" not implemented by subclass' }
sub client_write { croak 'Method "client_write" not implemented by subclass' }

sub connection {
Expand Down Expand Up @@ -83,7 +82,6 @@ Mojo::Transaction - Transaction base class
package Mojo::Transaction::MyTransaction;
use Mojo::Base 'Mojo::Transaction';
sub client_read {...}
sub client_write {...}
sub server_read {...}
sub server_write {...}
Expand Down Expand Up @@ -191,13 +189,6 @@ implements the following new ones.
Transaction closed client-side, no actual connection close is assumed by
default, used to implement user agents such as L<Mojo::UserAgent>.
=head2 client_read
$tx->client_read($bytes);
Read data client-side, used to implement user agents such as L<Mojo::UserAgent>.
Meant to be overloaded in a subclass.
=head2 client_write
my $bytes = $tx->client_write;
Expand Down
6 changes: 0 additions & 6 deletions lib/Mojo/Transaction/HTTP.pm
Expand Up @@ -236,12 +236,6 @@ L<Mojo::Transaction::HTTP> object.
L<Mojo::Transaction::HTTP> inherits all methods from L<Mojo::Transaction> and
implements the following new ones.
=head2 client_read
$tx->client_read($bytes);
Read data client-side, used to implement user agents such as L<Mojo::UserAgent>.
=head2 client_write
my $bytes = $tx->client_write;
Expand Down
6 changes: 0 additions & 6 deletions lib/Mojo/Transaction/WebSocket.pm
Expand Up @@ -562,12 +562,6 @@ such as L<Mojo::UserAgent>.
Perform WebSocket handshake client-side, used to implement user agents such as
L<Mojo::UserAgent>.
=head2 client_read
$ws->client_read($data);
Read data client-side, used to implement user agents such as L<Mojo::UserAgent>.
=head2 client_write
my $bytes = $ws->client_write;
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -241,9 +241,9 @@ sub _finish {
if (my $new = $self->transactor->upgrade($old)) {
weaken $self;
$new->on(resume => sub { $self->_write($id) });
my $ws = $self->{connections}{$id}
= Mojo::Channel::WebSocket::Client->new(ioloop => $c->{ioloop},
my $ws = Mojo::Channel::WebSocket::Client->new(ioloop => $c->{ioloop},
tx => $new);
$self->{connections}{$id} = $ws;
$c->{cb}($self, $c->{tx} = $new);
return $ws->read($old->res->content->leftovers);
}
Expand Down
2 changes: 0 additions & 2 deletions t/mojo/transactor.t
Expand Up @@ -921,8 +921,6 @@ is $tx->res->code, undef, 'no status';
is $tx->res->headers->location, undef, 'no "Location" value';

# Abstract methods
eval { Mojo::Transaction->client_read };
like $@, qr/Method "client_read" not implemented by subclass/, 'right error';
eval { Mojo::Transaction->client_write };
like $@, qr/Method "client_write" not implemented by subclass/, 'right error';
eval { Mojo::Transaction->server_read };
Expand Down

0 comments on commit 419bf40

Please sign in to comment.