Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add http proxy support for Omnibus::NetFetcher #77

Merged
merged 2 commits into from
Oct 22, 2013

Conversation

databus23
Copy link
Contributor

This is a simple stab add adding http proxy support when fetching tarballs

@seth
Copy link

seth commented Oct 16, 2013

This looks off to a good start. We're following the same contribution process for this project as for Chef. Would you be willing to sign a CLA so we can merge your code?

Thank you for taking the time to help make Chef better! We require a Contributor License Agreement (CLA) from contributors to help protect all Chef users. It is easy to complete one online. Instructions to do so are on our wiki, which is linked below. Once your account is updated, you will have access to 'resolve' tickets that indicates to the code review team that your contribution is ready for review.

http://wiki.opscode.com/display/chef/How+to+Contribute
http://wiki.opscode.com/display/chef/Code+Review

@@ -88,7 +88,14 @@ def get_with_redirect(url, headers, limit = 10)
end

req = Net::HTTP::Get.new(url.request_uri, headers)
http_client = Net::HTTP.new(url.host, url.port)

no_proxy = (ENV['NO_PROXY'] || ENV['no_proxy'] || "").split(/\s*,\s*/)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small helper function for retrieving ENV vars in a case insensitive way might help clean this up. Something along the lines of:

get_env(name)
  ENV[name.downcase] || ENV[name.upcase] || nil
end

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit would also benefit from a brief comment explaining how the proxy stuff is intended to work.

@databus23
Copy link
Contributor Author

I signed a CLA from Opscode some time ago already . My Opscode JIRA username is databus23.

I added another commit where I tried to clean up the code according to your feedback.

@@ -104,6 +109,31 @@ def get_with_redirect(url, headers, limit = 10)
end
end

#search environment variable as given, all lowercase and all upper case
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of #get_env? It looks like you're passing environment variables in uppercase, looking for them, looking for them again downcased, and then again upcased. I've never used environment variables that were anything other than uppercase. I think we're risking some confusion if someone sets a variable with different case by accident.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proxy related environment variables are not required to by all uppercase in my experience. At least all the common cli tools (wget, git, curl) support proxy related variables in lowercase.
The systems I'm working with have proxy environment variables names in lowercase and it never caused any problems.
So the intended benefit of get_env is to read environment variables regardless if the are written uppercase or lowercase. Looking them up as is (ENV[name]) is not strictly necessary, I just wanted the method to be able to read variables in mixed case provided you pass in the exact string.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matching behavior of curl is a good argument. I don't think this is overly complicated or confusing.

@seth seth merged commit d932a01 into chef:master Oct 22, 2013
@seth
Copy link

seth commented Oct 22, 2013

Thanks again for the patch. I've added a bit of test coverage and merged this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants