Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[httpClient] NO_PROXY option is ignored in NativeHttpClient::request() method #33832

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

Closed
Harry-Dunne opened this issue Oct 3, 2019 · 2 comments

Comments

@Harry-Dunne
Copy link
Contributor

Symfony version(s) affected: 4.3.4

Description
Overriding HTTP Proxy settings in $options argument passed to NativeHttpClient::request() method works for "proxy" option but doesn't work for "no_proxy" option.

How to reproduce

Call the NativeHttpClient::request() method with options overriding your proxy settings in environment variables:

$client = HttpClient::create();
$client->request('GET', 'http://my-host.com/', [
    'no_proxy' => 'my-host',
]);

Possible Solution

I think that the bug lies in this line:

https://github.com/symfony/http-client/blob/92ceb25f8c850d4ec8bce9234c8001c5b32d8387/NativeHttpClient.php#L224

Possible fix:

$noProxy = $options['no_proxy'] ?? $_SERVER['no_proxy'] ?? $_SERVER['NO_PROXY'] ?? '';
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Oct 4, 2019

Your fix looks good to me, would you like to submit it as a PR against branch 4.3?

@Harry-Dunne
Copy link
Contributor Author

No problem, I will submit it in the next few days.

Harry-Dunne added a commit to Harry-Dunne/symfony that referenced this issue Oct 4, 2019
nicolas-grekas added a commit that referenced this issue Oct 4, 2019
…ient (Harry-Dunne)

This PR was merged into the 4.3 branch.

Discussion
----------

[HttpClient] fix "no_proxy" option ignored in NativeHttpClient

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #33832
| License       | MIT
| Doc PR        |

Allow overriding of no_proxy environment variable by passing no_proxy option in NativeHttpClient::request() method.

Commits
-------

e4fb58d [HttpClient] Fixed #33832 NO_PROXY option ignored in NativeHttpClient::request() method
nicolas-grekas added a commit that referenced this issue Oct 4, 2019
* 4.3:
  [Intl] Update the ICU data to 65.1 (4.3 branch)
  Replace deprecated calls in tests
  [Intl] Update the ICU data to 65.1
  Delete 5_Security_issue.md
  [DI] Whitelist validator.auto_mapper in UnusedTagsPass
  [HttpClient] Fixed #33832 NO_PROXY option ignored in NativeHttpClient::request() method
  [Cache] give 100ms before starting the expiration countdown
  [Cache] fix logger usage in CacheTrait::doGet()
  [VarDumper] fix dumping uninitialized SplFileInfo
  Added missing translations.
  Fixed invalid changelog 4.0.0 for VarDumper
  Fixed invalid VarDumper upgrade doc.
  [HttpFoundation] Check if data passed to SessionBagProxy::initialize is an array
  Don't let falsey usernames slip through
nicolas-grekas added a commit that referenced this issue Oct 7, 2019
* 4.4: (27 commits)
  [Validator] add notice in UPGRADE file for new Range constraint option
  [CssSelector] Support *:only-of-type pseudo class selector
  [Intl] Update the ICU data to 65.1 (4.4 branch)
  [Intl] Update the ICU data to 65.1 (4.3 branch)
  Replace deprecated calls in tests
  [Intl] Update the ICU data to 65.1
  Delete 5_Security_issue.md
  [DI] Whitelist error_renderer.renderer tag  in UnusedTagsPass
  [DI] Whitelist validator.auto_mapper in UnusedTagsPass
  Update CHANGELOG.md
  [HttpClient] Fixed #33832 NO_PROXY option ignored in NativeHttpClient::request() method
  [EventDispatcher] A compiler pass for aliased userland events.
  [Cache] give 100ms before starting the expiration countdown
  [Cache] fix logger usage in CacheTrait::doGet()
  [VarDumper] fix dumping uninitialized SplFileInfo
  Added missing translations.
  [Form] Added CountryType option for using alpha3 country codes
  Fixed invalid changelog 4.0.0 for VarDumper
  [Workflow] Fixed BC break on WorkflowInterface
  Fix wrong expression language value
  ...
hultberg pushed a commit to hultberg/symfony that referenced this issue Sep 17, 2021
* 4.4: (27 commits)
  [Validator] add notice in UPGRADE file for new Range constraint option
  [CssSelector] Support *:only-of-type pseudo class selector
  [Intl] Update the ICU data to 65.1 (4.4 branch)
  [Intl] Update the ICU data to 65.1 (4.3 branch)
  Replace deprecated calls in tests
  [Intl] Update the ICU data to 65.1
  Delete 5_Security_issue.md
  [DI] Whitelist error_renderer.renderer tag  in UnusedTagsPass
  [DI] Whitelist validator.auto_mapper in UnusedTagsPass
  Update CHANGELOG.md
  [HttpClient] Fixed symfony#33832 NO_PROXY option ignored in NativeHttpClient::request() method
  [EventDispatcher] A compiler pass for aliased userland events.
  [Cache] give 100ms before starting the expiration countdown
  [Cache] fix logger usage in CacheTrait::doGet()
  [VarDumper] fix dumping uninitialized SplFileInfo
  Added missing translations.
  [Form] Added CountryType option for using alpha3 country codes
  Fixed invalid changelog 4.0.0 for VarDumper
  [Workflow] Fixed BC break on WorkflowInterface
  Fix wrong expression language value
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants