Skip to content

Commit

Permalink
more tests for transactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 21, 2013
1 parent b53e075 commit 29815df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -406,8 +406,7 @@ sub _start {
my ($self, $tx, $cb) = @_;

# Embedded server (update application if necessary)
my $req = $tx->req;
my $url = $req->url;
my $url = $tx->req->url;
if ($self->{port} || !$url->is_abs) {
if (my $app = $self->app) { $self->_server->app($app) }
my $base = $self->app_url;
Expand Down
8 changes: 7 additions & 1 deletion t/mojo/transactor.t
Expand Up @@ -23,6 +23,9 @@ $t->add_generator(
my $tx = $t->tx(GET => 'mojolicio.us/foo.html?bar=baz');
is $tx->req->url->to_abs, 'http://mojolicio.us/foo.html?bar=baz', 'right URL';
is $tx->req->method, 'GET', 'right method';
is $tx->req->headers->accept_encoding, 'gzip', 'right "Accept-Encoding" value';
is $tx->req->headers->user_agent, 'Mojolicious (Perl)',
'right "User-Agent" value';

# GET with escaped slash
my $url = Mojo::URL->new('http://mojolicio.us');
Expand All @@ -34,10 +37,13 @@ is $tx->req->url->path->to_string, 'foo%2Fbar', 'right path';
is $tx->req->method, 'GET', 'right method';

# POST with header
$t->name('MyUA 1.0');
$tx = $t->tx(POST => 'https://mojolicio.us' => {DNT => 1});
is $tx->req->url->to_abs, 'https://mojolicio.us', 'right URL';
is $tx->req->method, 'POST', 'right method';
is $tx->req->headers->dnt, 1, 'right "DNT" value';
is $tx->req->headers->dnt, 1, 'right "DNT" value';
is $tx->req->headers->accept_encoding, 'gzip', 'right "Accept-Encoding" value';
is $tx->req->headers->user_agent, 'MyUA 1.0', 'right "User-Agent" value';

# POST with header and content
$tx = $t->tx(POST => 'https://mojolicio.us' => {DNT => 1} => 'test');
Expand Down

0 comments on commit 29815df

Please sign in to comment.