Skip to content

Commit e2ffda4

Browse files
Rod JenkinsRod Jenkins
Rod Jenkins
authored and
Rod Jenkins
committed
added proxy abilities to http.rb
1 parent 4165a4a commit e2ffda4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/smugmug/http.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@ def initialize(args)
2525
else
2626
@headers["User-Agent"] = "Ruby-SmugMug v#{SmugMug::VERSION}"
2727
end
28+
29+
args[:http] = args.fetch(:http,{}) #checks for the existance of :http, sets to nill if does not exist.
30+
@http_proxy_host = args[:http].fetch(:proxy_host,nil)
31+
@http_proxy_port = args[:http].fetch(:proxy_port,nil)
32+
@http_proxy_user = args[:http].fetch(:proxy_user,nil)
33+
@http_proxy_pass = args[:http].fetch(:proxy_pass,nil)
2834
end
2935

3036
def request(api, args)
3137
uri = api == :uploading ? UPLOAD_URI : API_URI
3238
args[:method] = "smugmug.#{api}" unless api == :uploading
3339

34-
http = ::Net::HTTP.new(uri.host, uri.port)
40+
http = ::Net::HTTP.new(uri.host, uri.port, @http_proxy_host, @http_proxy_port, @http_proxy_user, @http_proxy_pass)
3541
http.set_debug_output(@config[:debug_output]) if @config[:debug_output]
3642

3743
# Configure HTTPS if needed

0 commit comments

Comments
 (0)