Jelajahi Sumber

Merge pull request #4 from troglodyne-bot/koan/fix-bugs-and-cleanup

Fix multipart boundary, HTTP::Body dep, NYTProf overhead, error fallback
George S. Baugh 4 bulan lalu
induk
melakukan
c92f0291e1
3 mengubah file dengan 13 tambahan dan 16 penghapusan
  1. 10 3
      Makefile.PL
  2. 1 10
      bin/tpsgi
  3. 2 3
      lib/TPSGI.pm

+ 10 - 3
Makefile.PL

@@ -21,24 +21,31 @@ WriteMakefile(
         "Config::Simple" => "0",
         "Cwd" => "0",
         "Data::Dumper" => "0",
+        "Date::Format" => "0",
         "DateTime::Format::HTTP" => "0",
+        "Devel::NYTProf" => "0",
+        "File::Basename" => "0",
+        "File::Copy" => "0",
         "File::Find" => "0",
         "File::Path" => "0",
         "File::Touch" => "0",
         "FindBin::libs" => "0",
+        "HTTP::Body" => "0",
+        "HTTP::Parser::XS" => "0",
         "IO::Compress::Gzip" => "0",
+        "Linux::Perl::inotify" => "0",
         "List::Util" => "0",
         "Log::Dispatch" => "0",
         "Log::Dispatch::FileRotate" => "0",
         "Log::Dispatch::Screen" => "0",
         "Mojo::File" => "0",
+        "Plack" => "0",
         "Plack::MIME" => "0",
         "POSIX" => "0",
-        "Sys::Hostname" => "0",
-        "UUID" => "0",
-        "Devel::NYTProf" => "0",
         "Starman" => "0",
+        "Sys::Hostname" => "0",
         "URL::Encode" => "0",
+        "UUID" => "0",
     },
     test => {TESTS => 't/*.t'}
 );

+ 1 - 10
bin/tpsgi

@@ -61,14 +61,5 @@ our $app = sub {
     mkdir "$options{tpsgi_dir}/prof";
 
     my $self = TPSGI->new(%options);
-    return eval { $self->app(@_) } || do {
-		my $env = shift;
-        $env->{'psgi.errors'}->print($@);
-
-		# Redact the stack trace past line 1, it usually has things which should not be shown
-		$self->{cur_query}->{message} = $@;
-		$self->{cur_query}->{message} =~ s/\n.*//g if $self->{cur_query}->{message};
-
-		return $self->error($self->{cur_query});
-    };
+    return $self->app(@_);
 };

+ 2 - 3
lib/TPSGI.pm

@@ -18,6 +18,7 @@ use IO::Compress::Gzip;
 use Time::HiRes qw{usleep gettimeofday tv_interval};
 
 # For CGI features
+use HTTP::Body;
 use HTTP::Parser::XS qw{HEADERS_AS_HASHREF};
 use CGI::Emulate::PSGI;
 
@@ -25,14 +26,12 @@ use Date::Format qw{strftime};
 use List::Util();
 use File::Find;
 use Sys::Hostname();
-use Plack::MIME ();
 use DateTime::Format::HTTP();
 
 use URL::Encode();
 use File::Touch;
 use File::Path;
 use File::Copy;
-use File::Find;
 use Cwd            qw{abs_path};
 
 use File::Basename qw{dirname basename};
@@ -443,7 +442,7 @@ sub _range {
             }
         }
         $fh->close();
-        $writer->write("\n--$CHUNK_SEP\--\n") if $is_multipart;
+        $writer->write("\n--$CHUNK_SEP--\n") if $is_multipart;
         $writer->close;
     };
 }