Skip to content

Commit

Permalink
fixed a few small method handling bugs in Mojo::Transaction::HTTP
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 22, 2013
1 parent 1daaa72 commit ecb0904
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -11,6 +11,7 @@
- Fixed a few small clone bugs.
- Fixed a few small redirect and proxy connect bugs in
Mojo::UserAgent::Transactor.
- Fixed a few small method handling bugs in Mojo::Transaction::HTTP.

3.95 2013-04-12
- Added finished_ok method to Test::Mojo.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Transaction/HTTP.pm
Expand Up @@ -8,7 +8,7 @@ sub client_read {

# Skip body for HEAD request
my $res = $self->res;
$res->content->skip_body(1) if $self->req->method eq 'HEAD';
$res->content->skip_body(1) if uc $self->req->method eq 'HEAD';
return unless $res->parse($chunk)->is_finished;

# Unexpected 1xx reponse
Expand Down Expand Up @@ -91,7 +91,7 @@ sub _headers {
$self->{offset} = 0;

# Response without body
$head = $head && ($self->req->method eq 'HEAD' || $msg->is_empty);
$head = $head && (uc $self->req->method eq 'HEAD' || $msg->is_empty);
if ($head) { $self->{state} = 'finished' }

# Body
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/UserAgent.pm
Expand Up @@ -392,7 +392,7 @@ sub _remove {

# Keep connection alive
$self->_cache(join(':', $self->transactor->endpoint($tx)), $id)
unless $tx->req->method eq 'CONNECT' && ($tx->res->code // '') eq '200';
unless uc $tx->req->method eq 'CONNECT' && ($tx->res->code // '') eq '200';
}

sub _redirect {
Expand Down
6 changes: 6 additions & 0 deletions t/mojolicious/lite_app.t
Expand Up @@ -476,6 +476,12 @@ $t->head_ok('/')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->header_is('Content-Length' => 55)->content_is('');

# HEAD request (lowercase)
my $tx = $t->ua->build_tx(head => '/');
$t->request_ok($tx)->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->header_is('Content-Length' => 55)->content_is('');

# Root with body
$t->get_ok('/', '1234' x 1024)->status_is(200)
->content_is("/root.html\n/root.html\n/root.html\n/root.html\n/root.html\n");
Expand Down

0 comments on commit ecb0904

Please sign in to comment.