[Bps-public-commit] plient branch, master, updated. 782936166373c84fe94c239052be4c0a6bd4f3e9

? sunnavy sunnavy at bestpractical.com
Tue Sep 28 08:49:10 EDT 2010


The branch, master has been updated
       via  782936166373c84fe94c239052be4c0a6bd4f3e9 (commit)
       via  0bdf402ed5d289268b5fc59442116782ad28dcba (commit)
      from  f18285a2608ad9019849a3e93b256fd3b39ec978 (commit)

Summary of changes:
 lib/Plient/Handler/curl.pm |   16 +++++++++++-----
 lib/Plient/Util.pm         |   25 ++++++++++---------------
 2 files changed, 21 insertions(+), 20 deletions(-)

- Log -----------------------------------------------------------------
commit 0bdf402ed5d289268b5fc59442116782ad28dcba
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Sep 28 20:50:32 2010 +0800

    curl-config may be absent

diff --git a/lib/Plient/Handler/curl.pm b/lib/Plient/Handler/curl.pm
index da3ca1d..af303f9 100644
--- a/lib/Plient/Handler/curl.pm
+++ b/lib/Plient/Handler/curl.pm
@@ -22,13 +22,19 @@ sub init {
     $inited = 1;
     $curl        = $ENV{PLIENT_CURL}        || which('curl');
     $curl_config = $ENV{PLIENT_CURL_CONFIG} || which('curl-config');
-    return unless $curl && $curl_config;
-    if ( my $out = `$curl_config --protocols` ) {
-        @protocol{ map { lc } split /\r?\n/, $out } = ();
+    return unless $curl;
+    if ($curl_config) {
+        if ( my $out = `$curl_config --protocols` ) {
+            @protocol{ map { lc } split /\r?\n/, $out } = ();
+        }
+        else {
+            warn $!;
+            return;
+        }
     }
     else {
-        warn $!;
-        return;
+        # by default, curl should support http
+        %protocol = ( http => undef );
     }
 
     if ( exists $protocol{http} ) {

commit 782936166373c84fe94c239052be4c0a6bd4f3e9
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Sep 28 20:52:04 2010 +0800

    avoid system call

diff --git a/lib/Plient/Util.pm b/lib/Plient/Util.pm
index c4fa7df..0fb10aa 100644
--- a/lib/Plient/Util.pm
+++ b/lib/Plient/Util.pm
@@ -18,21 +18,16 @@ sub which {
     return $cache{$name} if $cache{$name};
 
     my $path;
-    eval '$path = `which $name`';
-    chomp $path;
-    if ( !$path ) {
-
-        # fallback to our way
-LINE:
-        for my $dir ( path() ) {
-            my $path = catfile( $dir, $name );
-
-            # XXX  any other names need to try?
-            my @try = grep { -x } ( $path, $path .= $bin_ext );
-            for my $try (@try) {
-                $path = $try;
-                last LINE;
-            }
+
+  LINE:
+    for my $dir ( path() ) {
+        my $p = catfile( $dir, $name );
+
+        # XXX  any other names need to try?
+        my @try = grep { -x } ( $p, $p . $bin_ext );
+        for my $try (@try) {
+            $path = $try;
+            last LINE;
         }
     }
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list