You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by as...@apache.org on 2008/01/16 03:20:25 UTC

svn commit: r612334 - /incubator/buildr/trunk/lib/core/transports.rb

Author: assaf
Date: Tue Jan 15 18:20:25 2008
New Revision: 612334

URL: http://svn.apache.org/viewvc?rev=612334&view=rev
Log:
BUILDR-20

Modified:
    incubator/buildr/trunk/lib/core/transports.rb

Modified: incubator/buildr/trunk/lib/core/transports.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/transports.rb?rev=612334&r1=612333&r2=612334&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/transports.rb (original)
+++ incubator/buildr/trunk/lib/core/transports.rb Tue Jan 15 18:20:25 2008
@@ -323,36 +323,40 @@
       puts "Requesting #{self}"  if Rake.application.options.trace
       request = Net::HTTP::Get.new(path.blank? ? '/' : path, headers)
       request.basic_auth self.user, self.password if self.user
-      case response = http.request(request)
-      when Net::HTTPNotModified
-        # No modification, nothing to do.
-        puts "Not modified since last download" if Rake.application.options.trace
-        nil
-      when Net::HTTPRedirection
-        # Try to download from the new URI, handle relative redirects.
-        puts "Redirected to #{response['Location']}" if Rake.application.options.trace
-        (self + URI.parse(response["location"])).read(options, &block)
-      when Net::HTTPOK
-        puts "Downloading #{self}" if verbose
-        with_progress_bar options[:progress], path.split("/").last, response.content_length do |progress|
-          if block
-            response.read_body do |chunk|
-              block.call chunk
-              progress << chunk
-            end
-          else
-            result = ""
-            response.read_body do |chunk|
-              result << chunk
-              progress << chunk
+      http.request request do |response|
+        case response
+        #case response = http.request(request)
+        when Net::HTTPNotModified
+          # No modification, nothing to do.
+          puts "Not modified since last download" if Rake.application.options.trace
+          return nil
+        when Net::HTTPRedirection
+          # Try to download from the new URI, handle relative redirects.
+          puts "Redirected to #{response['Location']}" if Rake.application.options.trace
+          return (self + URI.parse(response["location"])).read(options, &block)
+        when Net::HTTPOK
+          puts "Downloading #{self}" if verbose
+          result = nil
+          with_progress_bar options[:progress], path.split("/").last, response.content_length do |progress|
+            if block
+              response.read_body do |chunk|
+                block.call chunk
+                progress << chunk
+              end
+            else
+              result = ""
+              response.read_body do |chunk|
+                result << chunk
+                progress << chunk
+              end
             end
           end
+          return result
+        when Net::HTTPNotFound
+          raise NotFoundError, "Looking for #{self} and all I got was a 404!"
+        else
+          raise RuntimeError, "Failed to download #{self}: #{response.message}"
         end
-        result
-      when Net::HTTPNotFound
-        raise NotFoundError, "Looking for #{self} and all I got was a 404!"
-      else
-        raise RuntimeError, "Failed to download #{self}: #{response.message}"
       end
     end