diff -Nru libmojolicious-perl-7.57+dfsg/Changes libmojolicious-perl-7.59+dfsg/Changes --- libmojolicious-perl-7.57+dfsg/Changes 2017-11-18 16:05:36.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/Changes 2017-12-16 00:48:47.000000000 +0000 @@ -1,4 +1,15 @@ +7.59 2017-12-15 + - Moved home and ua attributes from Mojo to Mojolicious. + - Changed Mojo::IOLoop::Client to only start a thread pool with + Net::DNS::Native on demand. (Grinnz) + - Improved subprocess method in Mojo::IOLoop to allow for easier role + composition. + - Fixed RFC 7230 compliance bug in Mojo::Message::Response. (jberger) + +7.58 2017-12-02 + - Added websocket_p method to Mojo::UserAgent. + 7.57 2017-11-18 - Fixed installation problems with some versions of Perl on Windows. diff -Nru libmojolicious-perl-7.57+dfsg/debian/changelog libmojolicious-perl-7.59+dfsg/debian/changelog --- libmojolicious-perl-7.57+dfsg/debian/changelog 2017-12-06 14:25:56.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/debian/changelog 2017-12-30 14:55:00.000000000 +0000 @@ -1,3 +1,24 @@ +libmojolicious-perl (7.59+dfsg-1ubuntu1) bionic; urgency=medium + + * Merge from Debian unstable. Remaining changes: + - Depend on libio-socket-ssl-perl and libev-perl for + runtime-deps-and-recommends autopkgtest; these are also covered by + needs-recommends, but an explicit dependency forces autopkgtest not to + drop them during Perl transitions due to pinning only necessary packages + from -proposed. + + -- Bhavani Shankar Sat, 30 Dec 2017 20:23:44 +0530 + +libmojolicious-perl (7.59+dfsg-1) unstable; urgency=medium + + [ Damyan Ivanov ] + * declare conformance with Policy 4.1.2 (no changes needed) + + [ Nick Morrott ] + * New upstream version 7.59 + + -- Nick Morrott Thu, 21 Dec 2017 20:39:19 +0000 + libmojolicious-perl (7.57+dfsg-1ubuntu1) bionic; urgency=medium * Merge from Debian unstable. Remaining changes: diff -Nru libmojolicious-perl-7.57+dfsg/debian/control libmojolicious-perl-7.59+dfsg/debian/control --- libmojolicious-perl-7.57+dfsg/debian/control 2017-12-03 04:12:22.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/debian/control 2017-12-22 04:37:58.000000000 +0000 @@ -13,7 +13,7 @@ Build-Depends-Indep: perl, libjs-jquery, libjs-prettify -Standards-Version: 4.1.1 +Standards-Version: 4.1.2 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-perl/packages/libmojolicious-perl.git Vcs-Git: https://anonscm.debian.org/git/pkg-perl/packages/libmojolicious-perl.git Homepage: https://metacpan.org/release/Mojolicious diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/Content.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/Content.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/Content.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/Content.pm 2017-12-14 18:39:41.000000000 +0000 @@ -104,7 +104,7 @@ # Relaxed parsing my $headers = $self->headers; - my $len = $headers->content_length // ''; + my $len = $headers->content_length // ''; if ($self->auto_relax && !length $len) { my $connection = lc($headers->connection // ''); $self->relaxed(1) @@ -342,7 +342,7 @@ Emitted when a new chunk of content arrives. - $content->unsubscribe('read')->on(read => sub { + $content->on(read => sub { my ($content, $bytes) = @_; say "Streaming: $bytes"; }); diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/IOLoop/Client.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/IOLoop/Client.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/IOLoop/Client.pm 2017-11-07 20:49:28.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/IOLoop/Client.pm 2017-12-14 18:39:44.000000000 +0000 @@ -13,7 +13,7 @@ use constant NNR => $ENV{MOJO_NO_NNR} ? 0 : eval { require Net::DNS::Native; Net::DNS::Native->VERSION('0.15'); 1 }; -my $NDN = NNR ? Net::DNS::Native->new(pool => 5, extra_thread => 1) : undef; +my $NDN; # SOCKS support requires IO::Socket::Socks use constant SOCKS => $ENV{MOJO_NO_SOCKS} @@ -45,6 +45,7 @@ if !NNR || $args->{handle} || $args->{path}; # Non-blocking name resolution + $NDN //= Net::DNS::Native->new(pool => 5, extra_thread => 1); my $handle = $self->{dns} = $NDN->getaddrinfo($address, _port($args), {protocol => IPPROTO_TCP, socktype => SOCK_STREAM}); $reactor->io( @@ -63,7 +64,7 @@ sub _cleanup { my $self = shift; - $NDN->timedout($self->{dns}) if $self->{dns}; + $NDN->timedout($self->{dns}) if $NDN && $self->{dns}; return unless my $reactor = $self->reactor; $self->{$_} && $reactor->remove(delete $self->{$_}) for qw(dns timer handle); return $self; diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/IOLoop.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/IOLoop.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/IOLoop.pm 2017-11-16 12:43:44.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/IOLoop.pm 2017-12-14 21:53:18.000000000 +0000 @@ -153,7 +153,7 @@ sub subprocess { my $subprocess = Mojo::IOLoop::Subprocess->new; weaken $subprocess->ioloop(_instance(shift))->{ioloop}; - return $subprocess->run(@_); + return @_ ? $subprocess->run(@_) : $subprocess; } sub timer { shift->_timer(timer => @_) } @@ -608,6 +608,7 @@ =head2 subprocess my $subprocess = Mojo::IOLoop->subprocess(sub {...}, sub {...}); + my $subprocess = $loop->subprocess; my $subprocess = $loop->subprocess(sub {...}, sub {...}); Build L object to perform computationally expensive diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/JSON.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/JSON.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/JSON.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/JSON.pm 2017-12-15 16:49:34.000000000 +0000 @@ -293,7 +293,7 @@ =head1 DESCRIPTION L is a minimalistic and possibly the fastest pure-Perl -implementation of L. +implementation of L. It supports normal Perl data types like scalar, array reference, hash reference and will try to call the C method on blessed references, or stringify diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/Log.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/Log.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/Log.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/Log.pm 2017-12-15 23:31:07.000000000 +0000 @@ -112,7 +112,7 @@ Emitted when a new message gets logged. - $log->unsubscribe('message')->on(message => sub { + $log->on(message => sub { my ($log, $level, @lines) = @_; say "$level: ", @lines; }); @@ -235,6 +235,8 @@ =head2 new my $log = Mojo::Log->new; + my $log = Mojo::Log->new(level => 'warn'); + my $log = Mojo::Log->new({level => 'warn'}); Construct a new L object and subscribe to L event with default logger. diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/Message/Response.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/Message/Response.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/Message/Response.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/Message/Response.pm 2017-12-14 18:39:38.000000000 +0000 @@ -112,6 +112,9 @@ my $headers = $self->headers; $headers->date(Mojo::Date->new->to_string) unless $headers->date; + # RFC 7230 3.3.2 + $headers->remove('Content-Length') if $self->is_empty; + return $self; } diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/Message.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/Message.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/Message.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/Message.pm 2017-12-14 18:39:40.000000000 +0000 @@ -12,10 +12,10 @@ use Mojo::Util 'decode'; has content => sub { Mojo::Content::Single->new }; -has default_charset => 'UTF-8'; -has max_line_size => sub { $ENV{MOJO_MAX_LINE_SIZE} || 8192 }; +has default_charset => 'UTF-8'; +has max_line_size => sub { $ENV{MOJO_MAX_LINE_SIZE} || 8192 }; has max_message_size => sub { $ENV{MOJO_MAX_MESSAGE_SIZE} // 16777216 }; -has version => '1.1'; +has version => '1.1'; sub body { my $self = shift; @@ -274,7 +274,7 @@ $part = $part->asset->slurp unless $upload; if ($charset) { - $name = decode($charset, $name) // $name if $name; + $name = decode($charset, $name) // $name if $name; $filename = decode($charset, $filename) // $filename if $filename; $part = decode($charset, $part) // $part unless $upload; } diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/Path.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/Path.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/Path.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/Path.pm 2017-12-14 18:39:46.000000000 +0000 @@ -109,7 +109,7 @@ my ($self, $name) = (shift, shift); unless ($self->{parts}) { - my $path = url_unescape delete($self->{path}) // ''; + my $path = url_unescape delete($self->{path}) // ''; my $charset = $self->charset; $path = decode($charset, $path) // $path if $charset; $self->{leading_slash} = $path =~ s!^/!!; diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/Promise.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/Promise.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/Promise.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/Promise.pm 2017-12-14 18:39:34.000000000 +0000 @@ -142,6 +142,19 @@ return $promise; } + # Perform non-blocking operations sequentially + get('http://mojolicious.org')->then(sub { + my $mojo = shift; + say $mojo->res->code; + return get('http://metacpan.org'); + })->then(sub { + my $cpan = shift; + say $cpan->res->code; + })->catch(sub { + my $err = shift; + warn "Something went wrong: $err"; + })->wait; + # Synchronize non-blocking operations (all) my $mojo = get('http://mojolicious.org'); my $cpan = get('http://metacpan.org'); @@ -268,26 +281,30 @@ L object resolving to the return value of the called handler. # Pass along the fulfillment value or rejection reason - $promise->then(sub { - my @value = @_; - say "The result is $value[0]"; - return @value; - }, - sub { - my @reason = @_; - warn "Something went wrong: $reason[0]"; - return @reason; - }); + $promise->then( + sub { + my @value = @_; + say "The result is $value[0]"; + return @value; + }, + sub { + my @reason = @_; + warn "Something went wrong: $reason[0]"; + return @reason; + } + ); # Change the fulfillment value or rejection reason - $promise->then(sub { - my @value = @_; - return "This is good: $value[0]"; - }, - sub { - my @reason = @_; - return "This is bad: $reason[0]"; - }); + $promise->then( + sub { + my @value = @_; + return "This is good: $value[0]"; + }, + sub { + my @reason = @_; + return "This is bad: $reason[0]"; + } + ); =head2 wait diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/Server/Daemon.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/Server/Daemon.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/Server/Daemon.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/Server/Daemon.pm 2017-12-16 15:45:06.000000000 +0000 @@ -14,7 +14,7 @@ has acceptors => sub { [] }; has [qw(backlog max_clients silent)]; has inactivity_timeout => sub { $ENV{MOJO_INACTIVITY_TIMEOUT} // 15 }; -has ioloop => sub { Mojo::IOLoop->singleton }; +has ioloop => sub { Mojo::IOLoop->singleton }; has listen => sub { [split ',', $ENV{MOJO_LISTEN} || 'http://*:3000'] }; has max_requests => 100; diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/Server.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/Server.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/Server.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/Server.pm 2017-12-14 18:39:34.000000000 +0000 @@ -115,7 +115,7 @@ Emitted when a request is ready and needs to be handled. - $server->unsubscribe('request')->on(request => sub { + $server->on(request => sub { my ($server, $tx) = @_; $tx->res->code(200); $tx->res->headers->content_type('text/plain'); diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/UserAgent/CookieJar.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/UserAgent/CookieJar.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/UserAgent/CookieJar.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/UserAgent/CookieJar.pm 2017-12-14 18:39:35.000000000 +0000 @@ -24,7 +24,7 @@ # Replace cookie my $origin = $cookie->origin // ''; next unless my $domain = lc($cookie->domain // $origin); - next unless my $path = $cookie->path; + next unless my $path = $cookie->path; next unless length(my $name = $cookie->name // ''); my $jar = $self->{jar}{$domain} ||= []; @$jar = (grep({ _compare($_, $path, $name, $origin) } @$jar), $cookie); @@ -45,7 +45,7 @@ for my $cookie (@{$tx->res->cookies}) { # Validate domain - my $host = lc $url->ihost; + my $host = lc $url->ihost; my $domain = lc($cookie->domain // $cookie->origin($host)->origin); if (my $cb = $self->ignore) { next if $cb->($cookie) } next if $host ne $domain && ($host !~ /\Q.$domain\E$/ || $host =~ /\.\d+$/); diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/UserAgent/Transactor.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/UserAgent/Transactor.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/UserAgent/Transactor.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/UserAgent/Transactor.pm 2017-12-14 18:39:35.000000000 +0000 @@ -68,7 +68,7 @@ my ($self, $old) = @_; # Commonly used codes - my $res = $old->res; + my $res = $old->res; my $code = $res->code // 0; return undef unless grep { $_ == $code } 301, 302, 303, 307, 308; @@ -146,7 +146,7 @@ $req->headers->sec_websocket_protocol(join ', ', @$sub) if @$sub; # Handshake protocol - my $url = $req->url; + my $url = $req->url; my $proto = $url->protocol // ''; if ($proto eq 'ws') { $url->scheme('http') } elsif ($proto eq 'wss') { $url->scheme('https') } diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo/UserAgent.pm libmojolicious-perl-7.59+dfsg/lib/Mojo/UserAgent.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo/UserAgent.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo/UserAgent.pm 2017-12-14 18:39:37.000000000 +0000 @@ -26,7 +26,7 @@ has max_redirects => sub { $ENV{MOJO_MAX_REDIRECTS} || 0 }; has proxy => sub { Mojo::UserAgent::Proxy->new }; has request_timeout => sub { $ENV{MOJO_REQUEST_TIMEOUT} // 0 }; -has server => sub { Mojo::UserAgent::Server->new(ioloop => shift->ioloop) }; +has server => sub { Mojo::UserAgent::Server->new(ioloop => shift->ioloop) }; has transactor => sub { Mojo::UserAgent::Transactor->new }; # Common HTTP methods @@ -74,8 +74,10 @@ $tx => sub { my ($self, $tx) = @_; my $err = $tx->error; - $promise->resolve($tx) if !$err || $err->{code}; - $promise->reject($err->{message}); + return $promise->reject($err->{message}) if $err && !$err->{code}; + return $promise->reject('WebSocket handshake failed') + if $tx->req->is_handshake && !$tx->is_websocket; + $promise->resolve($tx); } ); @@ -87,6 +89,11 @@ $self->start($self->build_websocket_tx(@_), $cb); } +sub websocket_p { + my $self = shift; + return $self->start_p($self->build_websocket_tx(@_)); +} + sub _cleanup { my $self = shift; delete $self->{pid}; @@ -450,8 +457,8 @@ L is a full featured non-blocking I/O HTTP and WebSocket user agent, with IPv6, TLS, SNI, IDNA, HTTP/SOCKS5 proxy, UNIX domain socket, Comet -(long polling), keep-alive, connection pooling, timeout, cookie, multipart, gzip -compression and multiple event loop support. +(long polling), Promises/A+, keep-alive, connection pooling, timeout, cookie, +multipart, gzip compression and multiple event loop support. All connections will be reset automatically if a new process has been forked, this allows multiple processes to share the same L object @@ -1054,6 +1061,29 @@ 'Sec-WebSocket-Extensions' => 'permessage-deflate' } => sub {...}); +=head2 websocket_p + + my $promise = $ua->websocket_p('ws://example.com'); + +Same as L, but returns a L object instead of +accepting a callback. + + $ua->websocket_p('wss://example.com/echo')->then(sub { + my $tx = shift; + my $promise = Mojo::Promise->new; + $tx->on(finish => sub { $promise->resolve }); + $tx->on(message => sub { + my ($tx, $msg) = @_; + say "WebSocket message: $msg"; + $tx->finish; + }); + $tx->send('Hi!'); + return $promise; + })->catch(sub { + my $err = shift; + warn "WebSocket error: $err"; + })->wait; + =head1 DEBUGGING You can set the C environment variable to get some diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Command/cpanify.pm libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Command/cpanify.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Command/cpanify.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Command/cpanify.pm 2017-12-14 18:39:51.000000000 +0000 @@ -28,7 +28,7 @@ unless ($tx->success) { my $code = $tx->res->code // 0; - my $msg = $tx->error->{message}; + my $msg = $tx->error->{message}; if ($code == 401) { $msg = 'Wrong username or password.' } elsif ($code == 409) { $msg = 'File already exists on CPAN.' } die qq{Problem uploading file "$file": $msg\n}; diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Command/daemon.pm libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Command/daemon.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Command/daemon.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Command/daemon.pm 2017-12-14 18:39:53.000000000 +0000 @@ -15,9 +15,9 @@ 'b|backlog=i' => sub { $daemon->backlog($_[1]) }, 'c|clients=i' => sub { $daemon->max_clients($_[1]) }, 'i|inactivity-timeout=i' => sub { $daemon->inactivity_timeout($_[1]) }, - 'l|listen=s' => \my @listen, - 'p|proxy' => sub { $daemon->reverse_proxy(1) }, - 'r|requests=i' => sub { $daemon->max_requests($_[1]) }; + 'l|listen=s' => \my @listen, + 'p|proxy' => sub { $daemon->reverse_proxy(1) }, + 'r|requests=i' => sub { $daemon->max_requests($_[1]) }; $daemon->listen(\@listen) if @listen; $daemon->run; diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Command/get.pm libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Command/get.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Command/get.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Command/get.pm 2017-12-14 18:39:53.000000000 +0000 @@ -16,7 +16,7 @@ my ($self, @args) = @_; # Data from STDIN - vec(my $r, fileno(STDIN), 1) = 1; + vec(my $r = '', fileno(STDIN), 1) = 1; my $in = !-t STDIN && select($r, undef, undef, 0) ? join '', : undef; my $ua = Mojo::UserAgent->new(ioloop => Mojo::IOLoop->singleton); diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Command/prefork.pm libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Command/prefork.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Command/prefork.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Command/prefork.pm 2017-12-14 18:39:52.000000000 +0000 @@ -20,12 +20,12 @@ 'I|heartbeat-interval=i' => sub { $prefork->heartbeat_interval($_[1]) }, 'H|heartbeat-timeout=i' => sub { $prefork->heartbeat_timeout($_[1]) }, 'i|inactivity-timeout=i' => sub { $prefork->inactivity_timeout($_[1]) }, - 'l|listen=s' => \my @listen, - 'P|pid-file=s' => sub { $prefork->pid_file($_[1]) }, - 'p|proxy' => sub { $prefork->reverse_proxy(1) }, - 'r|requests=i' => sub { $prefork->max_requests($_[1]) }, - 's|spare=i' => sub { $prefork->spare($_[1]) }, - 'w|workers=i' => sub { $prefork->workers($_[1]) }; + 'l|listen=s' => \my @listen, + 'P|pid-file=s' => sub { $prefork->pid_file($_[1]) }, + 'p|proxy' => sub { $prefork->reverse_proxy(1) }, + 'r|requests=i' => sub { $prefork->max_requests($_[1]) }, + 's|spare=i' => sub { $prefork->spare($_[1]) }, + 'w|workers=i' => sub { $prefork->workers($_[1]) }; $prefork->listen(\@listen) if @listen; $prefork->run; diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Controller.pm libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Controller.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Controller.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Controller.pm 2017-12-14 18:39:48.000000000 +0000 @@ -904,6 +904,18 @@ Generate a portable L object with base for a path, URL or route. + # Rebuild URL for the current route + $c->url_for; + + # Rebuild URL for the current route, but replace the "name" placeholder value + $c->url_for(name => 'sebastian'); + + # Absolute URL for the current route + $c->url_for->to_abs; + + # Build URL for route "test" with two placeholder values + $c->url_for('test', name => 'sebastian', foo => 'bar'); + # "http://127.0.0.1:3000/index.html" if application was started with Morbo $c->url_for('/index.html')->to_abs; diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Contributing.pod libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Contributing.pod --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Contributing.pod 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Contributing.pod 2017-12-14 23:06:31.000000000 +0000 @@ -180,10 +180,8 @@ L is open source and free to use. However, the amount of effort needed to maintain the project and develop new features for it is not sustainable without proper financial backing. You can support the ongoing -development of L through -L, -L or Bitcoin -(C<1Cid78CmK4hvf78Ry8K2XeDx8pQHNh4hbz>). +development of L through L and +Bitcoin (C<1Cid78CmK4hvf78Ry8K2XeDx8pQHNh4hbz>). If you run a business and use L in a revenue generating product, it makes business sense to support L development. Because it ensures diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Cookbook.pod libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Cookbook.pod --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Cookbook.pod 2017-11-17 19:00:12.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Cookbook.pod 2017-12-03 21:20:43.000000000 +0000 @@ -1336,7 +1336,7 @@ =head2 WebSockets WebSockets are not just for the server-side, you can use -L to open new connections, which are always +L to open new connections, which are always non-blocking. The WebSocket handshake uses HTTP, and is a normal C request with a few additional headers. It can even contain cookies, and is followed by a C<101> response from the server, notifying our user agent that the connection @@ -1344,20 +1344,21 @@ protocol. use Mojo::UserAgent; - use Mojo::IOLoop; + use Mojo::Promise; # Open WebSocket to echo service my $ua = Mojo::UserAgent->new; - $ua->websocket('ws://echo.websocket.org' => sub { - my ($ua, $tx) = @_; + $ua->websocket_p('ws://echo.websocket.org')->then(sub { + my $tx = shift; - # Check if WebSocket handshake was successful - say 'WebSocket handshake failed!' and return unless $tx->is_websocket; + # Prepare a followup promise so we can wait for messages + my $promise = Mojo::Promise->new; # Wait for WebSocket to be closed $tx->on(finish => sub { my ($tx, $code, $reason) = @_; say "WebSocket closed with status $code."; + $promise->resolve; }); # Close WebSocket after receiving one message @@ -1369,10 +1370,15 @@ # Send a message to the server $tx->send('Hi!'); - }); - # Start event loop if necessary - Mojo::IOLoop->start unless Mojo::IOLoop->is_running; + # Insert a new promise into the promise chain + return $promise; + })->catch(sub { + my $err = shift; + + # Handle failed WebSocket handshakes and other exceptions + warn "WebSocket error: $err"; + })->wait; =head2 UNIX domain sockets @@ -1383,7 +1389,7 @@ (C becomes C<%2F>) instead of a hostname. use Mojo::UserAgent; - use Mojo::IOLoop; + use Mojo::Promise; # GET request via UNIX domain socket "/tmp/foo.sock" my $ua = Mojo::UserAgent->new; @@ -1394,20 +1400,24 @@ say $tx->result->body; # WebSocket connection via UNIX domain socket "/tmp/baz.sock" - $ua->websocket('ws+unix://%2Ftmp%2Fbaz.sock/echo' => sub { - my ($ua, $tx) = @_; + $ua->websocket_p('ws+unix://%2Ftmp%2Fbaz.sock/echo')->then(sub { + my $tx = shift; - say 'WebSocket handshake failed!' and return unless $tx->is_websocket; + my $promise = Mojo::Promise->new; + $tx->on(finish => sub { $promise->resolve }); $tx->on(message => sub { my ($tx, $msg) = @_; say "WebSocket message: $msg"; $tx->finish; }); - $tx->send('Hi!'); - }); - Mojo::IOLoop->start unless Mojo::IOLoop->is_running; + + return $promise; + })->catch(sub { + my $err = shift; + warn "WebSocket error: $err"; + })->wait; You can set the C header manually to pass along a hostname. diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Growing.pod libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Growing.pod --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Growing.pod 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Growing.pod 2017-12-03 02:42:30.000000000 +0000 @@ -150,6 +150,7 @@ | +- MyApp # Application namespace | +- Controller # Controller namespace | +- Example.pm # Controller class + |- my_app.conf # Configuration file |- t # Test directory | +- basic.t # Random test |- log # Log directory @@ -356,13 +357,15 @@ # Test login with valid credentials $t->post_ok('/' => form => {user => 'sebastian', pass => 'secr3t'}) - ->status_is(200)->text_like('html body' => qr/Welcome sebastian/); + ->status_is(200) + ->text_like('html body' => qr/Welcome sebastian/); # Test accessing a protected page $t->get_ok('/protected')->status_is(200)->text_like('a' => qr/Logout/); # Test if HTML login form shows up again after logout - $t->get_ok('/logout')->status_is(200) + $t->get_ok('/logout') + ->status_is(200) ->element_exists('form input[name="user"]') ->element_exists('form input[name="pass"]') ->element_exists('form input[type="submit"]'); @@ -778,11 +781,13 @@ ->element_exists('form input[type="submit"]'); $t->post_ok('/' => form => {user => 'sebastian', pass => 'secr3t'}) - ->status_is(200)->text_like('html body' => qr/Welcome sebastian/); + ->status_is(200) + ->text_like('html body' => qr/Welcome sebastian/); $t->get_ok('/protected')->status_is(200)->text_like('a' => qr/Logout/); - $t->get_ok('/logout')->status_is(200) + $t->get_ok('/logout') + ->status_is(200) ->element_exists('form input[name="user"]') ->element_exists('form input[name="pass"]') ->element_exists('form input[type="submit"]'); diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Rendering.pod libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Rendering.pod --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Rendering.pod 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Rendering.pod 2017-12-17 13:30:03.000000000 +0000 @@ -590,13 +590,16 @@ @@ foo/bar.html.ep - %= include 'header', title => 'Howdy' + %= include '_header', title => 'Howdy' Bar - @@ header.html.ep + @@ _header.html.ep <%= $title %> +You can name partial templates however you like, but a leading underscore is a +commonly used naming convention. + =head2 Reusable template blocks It's never fun to repeat yourself, that's why you can build reusable template diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Routing.pod libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Routing.pod --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Routing.pod 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Routing.pod 2017-12-01 22:34:25.000000000 +0000 @@ -1024,6 +1024,11 @@ 1; +The host application will only share very little information with the embedded +application through the stash. So you cannot currently use route placeholders in +routes leading to embedded applications, since that would cause problems with +L. + =head2 Application plugins You can even package applications as self-contained reusable plugins. diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Tutorial.pod libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Tutorial.pod --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Guides/Tutorial.pod 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Guides/Tutorial.pod 2017-12-17 14:02:40.000000000 +0000 @@ -734,6 +734,36 @@ app->start; +=head2 Home + +You can use L to interact with the directory your +application considers its home. This is the directory it will search for +C and C directories, but you can use it to store all sorts of +application specific data. + + $ mkdir cache + $ echo 'Hello World!' > cache/hello.txt + +There are many useful methods L inherits from L, like +L and L, that will help you keep your +application portable across many different operating systems. + + use Mojolicious::Lite; + + # Load message into memory + my $hello = app->home->child('cache', 'hello.txt')->slurp; + + # Display message + get '/' => sub { + my $c = shift; + $c->render(text => $hello); + }; + +You can also introspect your application from the command line with +L. + + $ ./myapp.pl eval -v 'app->home' + =head2 Conditions Conditions such as C and C from diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Plugin/DefaultHelpers.pm libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Plugin/DefaultHelpers.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Plugin/DefaultHelpers.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Plugin/DefaultHelpers.pm 2017-12-16 00:47:19.000000000 +0000 @@ -474,7 +474,7 @@ %= ua->get('mojolicious.org')->result->dom->at('title')->text -Alias for L. +Alias for L. =head2 url_for diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/resources/templates/mojo/menubar.html.ep libmojolicious-perl-7.59+dfsg/lib/Mojolicious/resources/templates/mojo/menubar.html.ep --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/resources/templates/mojo/menubar.html.ep 2017-11-18 16:05:03.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/resources/templates/mojo/menubar.html.ep 2017-11-24 21:34:55.000000000 +0000 @@ -64,7 +64,6 @@ %= link_to GitHub => 'https://github.com/kraih/mojo' %= link_to CPAN => 'https://metacpan.org/release/Mojolicious/' %= link_to MailingList => 'https://groups.google.com/group/mojolicious' - %= link_to Blog => 'http://blog.mojolicious.org' %= link_to Twitter => 'https://twitter.com/kraih' %= form_for 'https://www.google.com/cse' => (target => '_blank') => begin %= hidden_field cx => '014527573091551588235:pwfplkjpgbi' diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Sessions.pm libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Sessions.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious/Sessions.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious/Sessions.pm 2017-12-14 18:39:47.000000000 +0000 @@ -44,7 +44,7 @@ # Generate "expires" value from "expiration" if necessary my $expiration = $session->{expiration} // $self->default_expiration; - my $default = delete $session->{expires}; + my $default = delete $session->{expires}; $session->{expires} = $default || time + $expiration if $expiration || $default; diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojolicious.pm libmojolicious-perl-7.59+dfsg/lib/Mojolicious.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojolicious.pm 2017-11-16 13:33:08.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojolicious.pm 2017-12-16 00:46:36.000000000 +0000 @@ -4,8 +4,10 @@ # "Fry: Shut up and take my money!" use Carp (); use Mojo::Exception; +use Mojo::Home; use Mojo::Log; use Mojo::Util; +use Mojo::UserAgent; use Mojolicious::Commands; use Mojolicious::Controller; use Mojolicious::Plugins; @@ -24,6 +26,7 @@ return $commands; }; has controller_class => 'Mojolicious::Controller'; +has home => sub { Mojo::Home->new->detect(ref shift) }; has log => sub { my $self = shift; @@ -52,13 +55,18 @@ # Default to moniker return [$self->moniker]; }; -has sessions => sub { Mojolicious::Sessions->new }; -has static => sub { Mojolicious::Static->new }; -has types => sub { Mojolicious::Types->new }; +has sessions => sub { Mojolicious::Sessions->new }; +has static => sub { Mojolicious::Static->new }; +has types => sub { Mojolicious::Types->new }; +has ua => sub { + my $ua = Mojo::UserAgent->new; + Scalar::Util::weaken $ua->server->app(shift)->{app}; + return $ua; +}; has validator => sub { Mojolicious::Validator->new }; our $CODENAME = 'Doughnut'; -our $VERSION = '7.57'; +our $VERSION = '7.59'; sub AUTOLOAD { my $self = shift; @@ -405,6 +413,17 @@ L. Note that this class needs to have already been loaded before the first request arrives. +=head2 home + + my $home = $app->home; + $app = $app->home(Mojo::Home->new); + +The home directory of your application, defaults to a L object +which stringifies to the actual path. + + # Portably generate path relative to home directory + my $path = $app->home->child('data', 'important.txt'); + =head2 log my $log = $app->log; @@ -553,6 +572,17 @@ # Add custom MIME type $app->types->type(twt => 'text/tweet'); +=head2 ua + + my $ua = $app->ua; + $app = $app->ua(Mojo::UserAgent->new); + +A full featured HTTP user agent for use in your applications, defaults to a +L object. + + # Perform blocking request + say $app->ua->get('example.com')->result->body; + =head2 validator my $validator = $app->validator; diff -Nru libmojolicious-perl-7.57+dfsg/lib/Mojo.pm libmojolicious-perl-7.59+dfsg/lib/Mojo.pm --- libmojolicious-perl-7.57+dfsg/lib/Mojo.pm 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/lib/Mojo.pm 2017-12-16 00:45:44.000000000 +0000 @@ -4,20 +4,11 @@ # "Professor: These old Doomsday devices are dangerously unstable. I'll rest # easier not knowing where they are." use Carp (); -use Mojo::Home; use Mojo::Log; use Mojo::Transaction::HTTP; -use Mojo::UserAgent; use Mojo::Util; -use Scalar::Util (); -has home => sub { Mojo::Home->new->detect(ref shift) }; -has log => sub { Mojo::Log->new }; -has ua => sub { - my $ua = Mojo::UserAgent->new; - Scalar::Util::weaken $ua->server->app(shift)->{app}; - return $ua; -}; +has log => sub { Mojo::Log->new }; sub build_tx { Mojo::Transaction::HTTP->new } @@ -70,17 +61,6 @@ L implements the following attributes. -=head2 home - - my $home = $app->home; - $app = $app->home(Mojo::Home->new); - -The home directory of your application, defaults to a L object -which stringifies to the actual path. - - # Portably generate path relative to home directory - my $path = $app->home->child('data', 'important.txt'); - =head2 log my $log = $app->log; @@ -91,17 +71,6 @@ # Log debug message $app->log->debug('It works'); -=head2 ua - - my $ua = $app->ua; - $app = $app->ua(Mojo::UserAgent->new); - -A full featured HTTP user agent for use in your applications, defaults to a -L object. - - # Perform blocking request - say $app->ua->get('example.com')->result->body; - =head1 METHODS L inherits all methods from L and implements the following diff -Nru libmojolicious-perl-7.57+dfsg/META.json libmojolicious-perl-7.59+dfsg/META.json --- libmojolicious-perl-7.57+dfsg/META.json 2017-11-18 16:10:05.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/META.json 2017-12-17 17:58:31.000000000 +0000 @@ -58,6 +58,6 @@ }, "x_IRC" : "irc://irc.perl.org/#mojo" }, - "version" : "7.57", - "x_serialization_backend" : "JSON::PP version 2.94" + "version" : "7.59", + "x_serialization_backend" : "JSON::PP version 2.97000" } diff -Nru libmojolicious-perl-7.57+dfsg/META.yml libmojolicious-perl-7.59+dfsg/META.yml --- libmojolicious-perl-7.57+dfsg/META.yml 2017-11-18 16:10:05.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/META.yml 2017-12-17 17:58:30.000000000 +0000 @@ -31,5 +31,5 @@ homepage: http://mojolicious.org license: http://www.opensource.org/licenses/artistic-license-2.0 repository: https://github.com/kraih/mojo.git -version: '7.57' +version: '7.59' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -Nru libmojolicious-perl-7.57+dfsg/README.md libmojolicious-perl-7.59+dfsg/README.md --- libmojolicious-perl-7.57+dfsg/README.md 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/README.md 2017-12-03 02:34:54.000000000 +0000 @@ -22,8 +22,8 @@ applications, independently of the web framework. * Full stack HTTP and WebSocket client/server implementation with IPv6, TLS, SNI, IDNA, HTTP/SOCKS5 proxy, UNIX domain socket, Comet (long polling), - keep-alive, connection pooling, timeout, cookie, multipart, and gzip - compression support. + Promises/A+, keep-alive, connection pooling, timeout, cookie, multipart, + and gzip compression support. * Built-in non-blocking I/O web server, supporting multiple event loops as well as optional pre-forking and hot deployment, perfect for building highly scalable web services. @@ -33,6 +33,10 @@ can be used too, but may require additional CPAN modules to be installed) * Fresh code based upon years of experience developing [Catalyst](http://www.catalystframework.org), free and open source. + * Hundreds of 3rd party + [extensions](https://metacpan.org/requires/distribution/Mojolicious) and + high quality spin-off projects like the + [Minion](https://metacpan.org/pod/Minion) job queue. ## Installation @@ -66,14 +70,17 @@ ## Duct tape for the HTML5 web Use all the latest Perl and HTML features in beautiful single file - prototypes like this one, and grow them easily into well-structured - applications. + prototypes like this one, and + [grow](http://mojolicious.org/perldoc/Mojolicious/Guides/Growing#Differences) + them easily into well-structured **Model-View-Controller** web applications. ```perl use Mojolicious::Lite -signatures; # Render template "index.html.ep" from the DATA section -get '/' => {template => 'index'}; +get '/' => sub ($c) { + $c->render(template => 'index'); +}; # WebSocket service used by the template to extract the title from a website websocket '/title' => sub ($c) { diff -Nru libmojolicious-perl-7.57+dfsg/t/mojo/cgi.t libmojolicious-perl-7.59+dfsg/t/mojo/cgi.t --- libmojolicious-perl-7.57+dfsg/t/mojo/cgi.t 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/t/mojo/cgi.t 2017-12-14 18:38:31.000000000 +0000 @@ -65,7 +65,7 @@ is $res->code, 200, 'right status'; is $res->headers->status, '200 OK', 'right "Status" value'; is $res->headers->content_length, 21, 'right "Content-Length" value'; -is $res->headers->content_type, 'text/html;charset=UTF-8', +is $res->headers->content_type, 'text/html;charset=UTF-8', 'right "Content-Type" value'; is $res->body, 'Your Mojo is working!', 'right content'; @@ -87,7 +87,7 @@ is $res->code, 200, 'right status'; is $res->headers->status, '200 OK', 'right "Status" value'; is $res->headers->content_length, 21, 'right "Content-Length" value'; -is $res->headers->content_type, 'text/html;charset=UTF-8', +is $res->headers->content_type, 'text/html;charset=UTF-8', 'right "Content-Type" value'; is $res->body, '', 'no content'; @@ -110,7 +110,7 @@ is $res->code, 200, 'right status'; is $res->headers->status, undef, 'no "Status" value'; is $res->headers->content_length, 21, 'right "Content-Length" value'; -is $res->headers->content_type, 'text/html;charset=UTF-8', +is $res->headers->content_type, 'text/html;charset=UTF-8', 'right "Content-Type" value'; is $res->body, 'Your Mojo is working!', 'right content'; @@ -184,7 +184,7 @@ is $res->code, 200, 'right status'; is $res->headers->status, '200 OK', 'right "Status" value'; is $res->headers->content_length, 15, 'right "Content-Length" value'; -is $res->headers->content_type, 'text/html;charset=UTF-8', +is $res->headers->content_type, 'text/html;charset=UTF-8', 'right "Content-Type" value'; is $res->body, '192.0.2.1:https', 'right content'; diff -Nru libmojolicious-perl-7.57+dfsg/t/mojo/daemon.t libmojolicious-perl-7.59+dfsg/t/mojo/daemon.t --- libmojolicious-perl-7.57+dfsg/t/mojo/daemon.t 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/t/mojo/daemon.t 2017-12-16 00:46:38.000000000 +0000 @@ -66,12 +66,8 @@ ok !!Mojo::Server::Daemon->new->reverse_proxy, 'reverse proxy'; } -# Optional home detection -my @path = qw(th is mojo dir wil l never-ever exist); -my $app = Mojo->new(home => Mojo::Home->new(@path)); -is $app->home, path(@path), 'right home directory'; - # Config +my $app = Mojo->new; is $app->config('foo'), undef, 'no value'; is_deeply $app->config(foo => 'bar')->config, {foo => 'bar'}, 'right value'; is $app->config('foo'), 'bar', 'right value'; diff -Nru libmojolicious-perl-7.57+dfsg/t/mojo/request_cgi.t libmojolicious-perl-7.59+dfsg/t/mojo/request_cgi.t --- libmojolicious-perl-7.57+dfsg/t/mojo/request_cgi.t 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/t/mojo/request_cgi.t 2017-12-14 18:38:18.000000000 +0000 @@ -229,7 +229,7 @@ is $req->param('ajax'), 'true', 'right value'; is $req->param('login'), 'test', 'right value'; is $req->param('password'), '111', 'right value'; -is $req->param('edition'), 'db6d8b30-16df-4ecd-be2f-c8194f94e1f4', +is $req->param('edition'), 'db6d8b30-16df-4ecd-be2f-c8194f94e1f4', 'right value'; is $req->url->to_abs->to_string, 'http://test1/index.pl/', 'right absolute URL'; @@ -262,7 +262,7 @@ is $req->param('ajax'), 'true', 'right value'; is $req->param('login'), 'test', 'right value'; is $req->param('password'), '111', 'right value'; -is $req->param('edition'), 'db6d8b30-16df-4ecd-be2f-c8194f94e1f4', +is $req->param('edition'), 'db6d8b30-16df-4ecd-be2f-c8194f94e1f4', 'right value'; is $req->url->to_abs->to_string, 'http://test1/index.pl/', 'right absolute URL'; diff -Nru libmojolicious-perl-7.57+dfsg/t/mojo/response.t libmojolicious-perl-7.59+dfsg/t/mojo/response.t --- libmojolicious-perl-7.57+dfsg/t/mojo/response.t 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/t/mojo/response.t 2017-12-14 18:38:16.000000000 +0000 @@ -855,6 +855,7 @@ is $res->headers->sec_websocket_protocol, 'sample', 'right "Sec-WebSocket-Protocol" value'; is $res->body, '', 'no content'; +ok !defined $res->headers->content_length, '"Content-Length" does not exist'; # Parse WebSocket handshake response (with frame) $res = Mojo::Message::Response->new; @@ -879,6 +880,7 @@ is $res->body, '', 'no content'; is $res->content->leftovers, "\x81\x08\x77\x68\x61\x74\x65\x76\x65\x72", 'frame in leftovers'; +ok !defined $res->headers->content_length, '"Content-Length" does not exist'; # Build WebSocket handshake response $res = Mojo::Message::Response->new; @@ -895,13 +897,14 @@ is $res->version, '1.1', 'right version'; is $res->headers->connection, 'Upgrade', 'right "Connection" value'; is $res->headers->date, 'Sun, 17 Aug 2008 16:27:35 GMT', 'right "Date" value'; -is $res->headers->content_length, 0, 'right "Content-Length" value'; -is $res->headers->upgrade, 'websocket', 'right "Upgrade" value'; +ok !defined $res->headers->content_length, '"Content-Length" does not exist'; +is $res->headers->upgrade, 'websocket', 'right "Upgrade" value'; is $res->headers->sec_websocket_accept, 'abcdef=', 'right "Sec-WebSocket-Accept" value'; is $res->headers->sec_websocket_protocol, 'sample', 'right "Sec-WebSocket-Protocol" value'; is $res->body, '', 'no content'; +ok !defined $res->headers->content_length, '"Content-Length" does not exist'; # Build and parse HTTP 1.1 response with 3 cookies $res = Mojo::Message::Response->new; diff -Nru libmojolicious-perl-7.57+dfsg/t/mojo/subprocess.t libmojolicious-perl-7.59+dfsg/t/mojo/subprocess.t --- libmojolicious-perl-7.57+dfsg/t/mojo/subprocess.t 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/t/mojo/subprocess.t 2017-12-14 21:55:12.000000000 +0000 @@ -82,7 +82,7 @@ sub { my $delay = shift; Mojo::IOLoop->subprocess(sub {1}, $delay->begin); - Mojo::IOLoop->subprocess(sub {2}, $delay->begin); + Mojo::IOLoop->subprocess->run(sub {2}, $delay->begin); }, sub { my ($delay, $err1, $result1, $err2, $result2) = @_; diff -Nru libmojolicious-perl-7.57+dfsg/t/mojo/websocket.t libmojolicious-perl-7.59+dfsg/t/mojo/websocket.t --- libmojolicious-perl-7.57+dfsg/t/mojo/websocket.t 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/t/mojo/websocket.t 2017-12-14 18:38:18.000000000 +0000 @@ -5,6 +5,7 @@ use Test::More; use Mojo::ByteStream 'b'; use Mojo::IOLoop; +use Mojo::Promise; use Mojo::Transaction::WebSocket; use Mojo::UserAgent; use Mojolicious::Lite; @@ -333,6 +334,28 @@ Mojo::IOLoop->start; is $result, 'foo bar', 'right result'; +# Promises +$result = undef; +$ua->websocket_p('/trim')->then( + sub { + my $tx = shift; + my $promise = Mojo::Promise->new; + $tx->on(finish => sub { $promise->resolve }); + $tx->on(message => sub { shift->finish; $result = pop }); + $tx->send(' also works! '); + return $promise; + } +)->wait; +is $result, 'also works!', 'right result'; +$result = undef; +$ua->websocket_p('/foo')->then(sub { $result = 'test failed' }) + ->catch(sub { $result = shift })->wait; +is $result, 'WebSocket handshake failed', 'right result'; +$result = undef; +$ua->websocket_p($ua->server->url->to_abs->scheme('wsss')) + ->then(sub { $result = 'test failed' })->catch(sub { $result = shift })->wait; +is $result, 'Unsupported protocol: wsss', 'right result'; + # Dies ($ws, $code, $msg) = (); my $finished; diff -Nru libmojolicious-perl-7.57+dfsg/t/mojolicious/app.t libmojolicious-perl-7.59+dfsg/t/mojolicious/app.t --- libmojolicious-perl-7.57+dfsg/t/mojolicious/app.t 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/t/mojolicious/app.t 2017-12-16 00:46:42.000000000 +0000 @@ -14,6 +14,7 @@ use Mojo::Asset::File; use Mojo::Date; use Mojo::File 'path'; +use Mojo::Home; use Mojo::IOLoop; use Mojolicious; use Mojolicious::Controller; @@ -40,6 +41,11 @@ is(Test::Mojo->new('MojoliciousTest')->app->mode, 'else', 'right mode'); } +# Optional home detection +my @path = qw(th is mojo dir wil l never-ever exist); +my $app = Mojolicious->new(home => Mojo::Home->new(@path)); +is $app->home, path(@path), 'right home directory'; + my $t = Test::Mojo->new('MojoliciousTest'); # Application is already available @@ -239,7 +245,7 @@ ->header_is(Server => 'Mojolicious (Perl)') ->content_like(qr/Missing right curly/); like $log, qr/Rendering template "syntaxerror.html.epl"/, 'right message'; -like $log, qr/Missing right curly/, 'right message'; +like $log, qr/Missing right curly/, 'right message'; like $log, qr/Template "exception.development.html.ep" not found/, 'right message'; like $log, qr/Rendering template "exception.html.epl"/, 'right message'; @@ -460,7 +466,7 @@ is(MojoliciousTest->new({mode => 'test'})->mode, 'test', 'right mode'); # Persistent error -my $app = MojoliciousTest->new; +$app = MojoliciousTest->new; my $tx = $t->ua->build_tx(GET => '/foo'); $app->handler($tx); is $tx->res->code, 200, 'right status'; diff -Nru libmojolicious-perl-7.57+dfsg/t/mojolicious/upload_lite_app.t libmojolicious-perl-7.59+dfsg/t/mojolicious/upload_lite_app.t --- libmojolicious-perl-7.57+dfsg/t/mojolicious/upload_lite_app.t 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/t/mojolicious/upload_lite_app.t 2017-12-14 18:38:33.000000000 +0000 @@ -21,7 +21,7 @@ $c->render(text => $file->filename . $file->asset->slurp . $c->param('test') - . ($headers->content_type // '') + . ($headers->content_type // '') . ($headers->header('X-X') // '')); }; diff -Nru libmojolicious-perl-7.57+dfsg/t/mojolicious/websocket_lite_app.t libmojolicious-perl-7.59+dfsg/t/mojolicious/websocket_lite_app.t --- libmojolicious-perl-7.57+dfsg/t/mojolicious/websocket_lite_app.t 2017-11-06 17:19:39.000000000 +0000 +++ libmojolicious-perl-7.59+dfsg/t/mojolicious/websocket_lite_app.t 2017-12-14 18:38:40.000000000 +0000 @@ -100,7 +100,7 @@ under '/nested'; websocket sub { - my $c = shift; + my $c = shift; my $echo = $c->cookie('echo') // ''; $c->cookie(echo => 'again'); $c->on(