Closed pracon-cmd closed 2 months ago
Environment: uname -a Linux 6.1.0-25-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.106-3 (2024-08-26) x86_64 GNU/Linux pip list Package Version
certifi 2024.8.30 charset-normalizer 3.3.2 idna 3.8 pip 23.0.1 requests 2.32.3 setuptools 66.1.1 urllib3 2.2.2
Is that normal that the Environment variables: HTTP_PROXY and HTTPS_PROXY would override the proxies argument passed to session.get()?
test code: `import requests import os
print(os.environ)
test_url = 'http://httpbin.org/ip'
my_proxies = None
session = requests.Session()
print("=== Session GET with my_proxies ===") response = session.get(url=test_url, proxies=my_proxies)
print(f'Your IP (using my_proxies): {response.json().get("origin")}')`
Run it and you will notice that the session uses the proxy server instead of None (specified by my_proxies = None)
As described in the template, we won't be able to answer questions on this issue tracker. Please use Stack Overflow
Environment: uname -a Linux 6.1.0-25-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.106-3 (2024-08-26) x86_64 GNU/Linux pip list Package Version
certifi 2024.8.30 charset-normalizer 3.3.2 idna 3.8 pip 23.0.1 requests 2.32.3 setuptools 66.1.1 urllib3 2.2.2
Is that normal that the Environment variables: HTTP_PROXY and HTTPS_PROXY would override the proxies argument passed to session.get()?
test code: `import requests import os
Disable environment proxies temporarily
os.environ.pop('https_proxy', None)
os.environ.pop('http_proxy', None)
get all environs
print(os.environ)
Define a test URL (you can replace this with a URL of your choice)
test_url = 'http://httpbin.org/ip'
Define your custom proxies
my_proxies = None
Create a session
session = requests.Session()
Test session.get with explicitly defined proxies
print("=== Session GET with my_proxies ===") response = session.get(url=test_url, proxies=my_proxies)
Print the result (should reflect the proxy being used)
print(f'Your IP (using my_proxies): {response.json().get("origin")}')`
Run it and you will notice that the session uses the proxy server instead of None (specified by my_proxies = None)