-
-
Save anonymous/3f2310d7743c9f531596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/Server/Daemon.pm b/lib/Mojo/Server/Daemon.pm | |
index c1d6241..35e5463 100644 | |
--- a/lib/Mojo/Server/Daemon.pm | |
+++ b/lib/Mojo/Server/Daemon.pm | |
@@ -3,6 +3,7 @@ use Mojo::Base 'Mojo::Server'; | |
use Mojo::IOLoop; | |
use Mojo::URL; | |
+use Mojo::Util 'dumper'; | |
use Scalar::Util 'weaken'; | |
use constant DEBUG => $ENV{MOJO_DAEMON_DEBUG} || 0; | |
@@ -182,7 +183,8 @@ sub _read { | |
# Make sure we have a transaction and parse chunk | |
return unless my $c = $self->{connections}{$id}; | |
my $tx = $c->{tx} ||= $self->_build_tx($id, $c); | |
- warn "-- Server <<< Client (@{[$tx->req->url->to_abs]})\n$chunk\n" if DEBUG; | |
+ warn "-- Server <<< Client (@{[$tx->req->url->to_abs]})\n@{[dumper $chunk]}" | |
+ if DEBUG; | |
$tx->server_read($chunk); | |
# Last keep-alive request or corrupted connection | |
@@ -209,7 +211,8 @@ sub _write { | |
return if !$tx->is_writing || $c->{writing}++; | |
my $chunk = $tx->server_write; | |
delete $c->{writing}; | |
- warn "-- Server >>> Client (@{[$tx->req->url->to_abs]})\n$chunk\n" if DEBUG; | |
+ warn "-- Server >>> Client (@{[$tx->req->url->to_abs]})\n@{[dumper $chunk]}" | |
+ if DEBUG; | |
my $stream = $self->ioloop->stream($id)->write($chunk); | |
# Finish or continue writing | |
diff --git a/lib/Mojo/UserAgent.pm b/lib/Mojo/UserAgent.pm | |
index 3182521..dd8c1eb 100644 | |
--- a/lib/Mojo/UserAgent.pm | |
+++ b/lib/Mojo/UserAgent.pm | |
@@ -4,7 +4,7 @@ use Mojo::Base 'Mojo::EventEmitter'; | |
# "Fry: Since when is the Internet about robbing people of their privacy? | |
# Bender: August 6, 1991." | |
use Mojo::IOLoop; | |
-use Mojo::Util 'monkey_patch'; | |
+use Mojo::Util qw(dumper monkey_patch); | |
use Mojo::UserAgent::CookieJar; | |
use Mojo::UserAgent::Proxy; | |
use Mojo::UserAgent::Server; | |
@@ -279,7 +279,8 @@ sub _read { | |
return $self->_remove($id) unless my $tx = $c->{tx}; | |
# Process incoming data | |
- warn "-- Client <<< Server (@{[$tx->req->url->to_abs]})\n$chunk\n" if DEBUG; | |
+ warn "-- Client <<< Server (@{[$tx->req->url->to_abs]})\n@{[dumper $chunk]}" | |
+ if DEBUG; | |
$tx->client_read($chunk); | |
if ($tx->is_finished) { $self->_finish($id) } | |
elsif ($tx->is_writing) { $self->_write($id) } | |
@@ -338,7 +339,8 @@ sub _write { | |
return if !$tx->is_writing || $c->{writing}++; | |
my $chunk = $tx->client_write; | |
delete $c->{writing}; | |
- warn "-- Client >>> Server (@{[$tx->req->url->to_abs]})\n$chunk\n" if DEBUG; | |
+ warn "-- Client >>> Server (@{[$tx->req->url->to_abs]})\n@{[dumper $chunk]}" | |
+ if DEBUG; | |
my $stream = $self->_loop($c->{nb})->stream($id)->write($chunk); | |
$self->_finish($id) if $tx->is_finished; | |
diff --git a/lib/Mojo/Util.pm b/lib/Mojo/Util.pm | |
index fa4723b..6da1ce4 100644 | |
--- a/lib/Mojo/Util.pm | |
+++ b/lib/Mojo/Util.pm | |
@@ -105,7 +105,11 @@ sub deprecated { | |
} | |
sub dumper { | |
- Data::Dumper->new([@_])->Indent(1)->Sortkeys(1)->Terse(1)->Useqq(1)->Dump; | |
+ my $data | |
+ = Data::Dumper->new([@_])->Indent(1)->Sortkeys(1)->Terse(1)->Useqq(1) | |
+ ->Dump; | |
+ $data =~ s/\\n/\n/g; | |
+ return $data; | |
} | |
sub encode { _encoding($_[0])->encode("$_[1]") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment