-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Allow guzzle to read environment NO_PROXY variable #1197
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
Conversation
ee086d3
to
0f7a462
Compare
@@ -172,6 +172,11 @@ private function configureDefaults(array $config) | |||
$defaults['proxy']['https'] = $proxy; | |||
} | |||
|
|||
if ($noProxy = getenv('NO_PROXY')) { | |||
$cleanedNoProxy = preg_replace('/\s/', '', $noProxy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use 4 spaces?
We should match what other clients are doing with NO_PROXY. For example: https://github.com/kennethreitz/requests/pull/945/files
So adding support for
This makes me think we should make it match if the host ends with any value in the CSV list of NO_PROXY servers to match wget and Requests. |
I add support to subdomains and wilcards @mtdowling |
@@ -172,6 +172,11 @@ private function configureDefaults(array $config) | |||
$defaults['proxy']['https'] = $proxy; | |||
} | |||
|
|||
if ($noProxy = getenv('NO_PROXY')) { | |||
$cleanedNoProxy = preg_replace('/\s/', '', $noProxy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should just be str_replace(' ', '', $noProxy);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too, but it was just to avoid tab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be better to use trim function?
php > var_dump(trim(" \t "));
string(0) ""
If no why only spaces will be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sure, but I don't know if it is the best solution. On these lines, I remove all spaces / tabs of a list of coma separated string. So my first solution allow to remove all spaces on the string. Your just remove spaces on the begining and at the end, not all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry did not see
$defaults['proxy']['no'] = explode(',', $cleanedNoProxy);
Then preg_replace isn't so bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too, but it was just to avoid tab
I get removing spaces, but I don't think it's necessary to remove tabs here.
$areaToMatch = "*$area"; | ||
} | ||
// Use wilcards | ||
$delimiter = '#'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any advantages of using this delimeter instead of the standard?
cb7186d
to
b8e2108
Compare
I've cleaned this up a bit and merged it. I removed all of the regex stuff and made sure that proxy rules are applied for both curl and the PHP stream wrapper. In order to achieve this, I moved the no_proxy matching code into |
Love this bit. Any chance of backporting to 5.3 for those stuck with php 5.4? |
Avoid to use proxy if NO_PROXY is configured