OSDN Git Service

Add bandwidth limit option.
[osdn-codes/osdn-cli.git] / lib / osdn / cli / overrides.rb
index 6bb7b42..25fea5c 100644 (file)
@@ -5,6 +5,7 @@ module Typhoeus
     alias_method :get_orig, :get
     def get(*args)
       easy = get_orig(*args)
     alias_method :get_orig, :get
     def get(*args)
       easy = get_orig(*args)
+
       if ENV['CURL_CA_BUNDLE']
         Ethon::Curl.set_option(:cainfo, ENV['CURL_CA_BUNDLE'], easy.handle)
       else
       if ENV['CURL_CA_BUNDLE']
         Ethon::Curl.set_option(:cainfo, ENV['CURL_CA_BUNDLE'], easy.handle)
       else
@@ -21,12 +22,18 @@ module Typhoeus
           Ethon::Curl.set_option(:cainfo, ca, easy.handle)
         end
       end
           Ethon::Curl.set_option(:cainfo, ca, easy.handle)
         end
       end
+
       if OSDN::CLI._show_progress
         Ethon::Curl.set_option(:noprogress, false, easy.handle)
       if OSDN::CLI._show_progress
         Ethon::Curl.set_option(:noprogress, false, easy.handle)
-        
       else
         Ethon::Curl.set_option(:noprogress, true, easy.handle)
       end
       else
         Ethon::Curl.set_option(:noprogress, true, easy.handle)
       end
+
+      if OSDN::CLI._rate_limit
+        Ethon::Curl.set_option(:max_send_speed_large, OSDN::CLI._rate_limit, easy.handle)
+        Ethon::Curl.set_option(:max_recv_speed_large, OSDN::CLI._rate_limit, easy.handle)
+      end
+
       easy
     end
   end
       easy
     end
   end