Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
better descriptions for a few methods
  • Loading branch information
kraih committed Jan 10, 2016
1 parent e122bab commit 1d4cb41
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
18 changes: 9 additions & 9 deletions lib/Mojo/Channel/HTTP.pm
Expand Up @@ -3,14 +3,14 @@ use Mojo::Base 'Mojo::Channel';

sub close { shift->{tx}->closed }

sub is_server { 0 }
sub is_server {undef}

sub write {
my $self = shift;
my $server = $self->is_server;
my $tx = $self->{tx};

# Client starts writing right away
my $server = $self->is_server;
my $tx = $self->{tx};
$tx->{state} ||= 'write' unless $server;
return '' unless $tx->{state} eq 'write';

Expand All @@ -35,10 +35,10 @@ sub write {

sub _body {
my ($self, $msg, $finish) = @_;
my $tx = $self->{tx};

# Prepare body chunk
my $buffer = $msg->get_body_chunk($tx->{offset});
my $tx = $self->{tx};
my $buffer = $msg->get_body_chunk($tx->{offset});
my $written = defined $buffer ? length $buffer : 0;
$tx->{write} = $msg->content->is_dynamic ? 1 : ($tx->{write} - $written);
$tx->{offset} += $written;
Expand All @@ -57,10 +57,10 @@ sub _body {

sub _headers {
my ($self, $msg, $head) = @_;
my $tx = $self->{tx};

# Prepare header chunk
my $buffer = $msg->get_header_chunk($tx->{offset});
my $tx = $self->{tx};
my $buffer = $msg->get_header_chunk($tx->{offset});
my $written = defined $buffer ? length $buffer : 0;
$tx->{write} -= $written;
$tx->{offset} += $written;
Expand All @@ -84,10 +84,10 @@ sub _headers {

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

# Prepare start-line chunk
my $buffer = $msg->get_start_line_chunk($tx->{offset});
my $tx = $self->{tx};
my $buffer = $msg->get_start_line_chunk($tx->{offset});
my $written = defined $buffer ? length $buffer : 0;
$tx->{write} -= $written;
$tx->{offset} += $written;
Expand Down
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 close {
my ($self, $close) = @_;
my $tx = $self->{tx};

# Premature connection close
my $tx = $self->{tx};
my $res = $tx->res->finish;
if ($close && !$res->code && !$res->error) {
$res->error({message => 'Premature connection close'});
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Channel/HTTP/Server.pm
@@ -1,7 +1,7 @@
package Mojo::Channel::HTTP::Server;
use Mojo::Base 'Mojo::Channel::HTTP';

sub is_server { 1 }
sub is_server {1}

sub read {
my ($self, $chunk) = @_;
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Channel/WebSocket.pm
Expand Up @@ -21,8 +21,8 @@ sub read {

sub write {
my $self = shift;
my $tx = $self->{tx};

my $tx = $self->{tx};
unless (length($tx->{write} // '')) {
$tx->{state} = $tx->{finished} ? 'finished' : 'read';
$tx->emit('drain');
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Transaction.pm
Expand Up @@ -160,8 +160,8 @@ implements the following new ones.
$tx->closed;
Transaction closed server-side, used to implement web servers such as
L<Mojo::Server::Daemon>.
Low-level signal that the underlying connection is finished with this
transaction.
=head2 connection
Expand Down
7 changes: 3 additions & 4 deletions lib/Mojo/Transaction/WebSocket.pm
Expand Up @@ -365,8 +365,8 @@ Build WebSocket message.
$ws->closed;
Transaction closed server-side, used to implement web servers such as
L<Mojo::Server::Daemon>.
Low-level signal that the underlying connection is finished with this
transaction.
=head2 connection
Expand Down Expand Up @@ -426,8 +426,7 @@ C<CLOSE> frames automatically.
$ws->opened;
WebSocket connection established server-side, used to implement web servers such
as L<Mojo::Server::Daemon>.
Low-level signal that the underlying connection has been established.
=head2 protocol
Expand Down

0 comments on commit 1d4cb41

Please sign in to comment.