title: curl --noproxy "*" equivalent in Python's request module
body: <p>I'm trying to access an API on a server within my network using Python's <code>request</code> module, but am getting a 502 Bad Gateway error. When I try to do something equivalent using <code>curl</code>, I get the same error and it's because the request is trying to run through the proxy server. Here is the output from <code>curl</code>:</p>
  
  <pre><code>$ curl -v -k -u username:password https://hostname:port/some/api/endpoint              * Uses proxy env variable no_proxy == 'hostname'
  * Uses proxy env variable https_proxy == 'http://10.3.0.40:10256'
  *   Trying 10.3.0.40...
  * TCP_NODELAY set
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to 10.3.0.40 (10.3.0.40) port 10256 (#0)
  * allocate connect buffer!
  * Establish HTTP proxy tunnel to hostname:port
  * Server auth using Basic with user 'user'
  &gt; CONNECT hostname:port HTTP/1.1
  &gt; Host: hostname:port
  &gt; User-Agent: curl/7.61.1
  &gt; Proxy-Connection: Keep-Alive
  &gt;
  &lt; HTTP/1.0 502 Bad Gateway
  &lt; Server: Zscaler/5.6
  &lt; Content-Type: text/html
  &lt; Connection: close
  &lt;
  * Received HTTP code 502 from proxy after CONNECT
  * CONNECT phase completed!
  * Closing connection 0
  curl: (56) Received HTTP code 502 from proxy after CONNECT
  </code></pre>
  
  <p>As the output states at the top, <code>curl</code> is automatically implementing the <code>HTTP_PROXY</code> variable I have in my environment variables, which is needed for other Python tasks. In order to avoid this, I can pass <code>--noproxy "*"</code> to <code>curl</code> and the request no longer tries to run through the proxy. </p>
  
  <p>I'd like to try to get the equivalent working with Python's <code>request</code> module. I know that <code>requests</code> will automatically read from the environment variables as well, so I tried to bypass that specifying <code>proxies=None</code> in the code:</p>
  
  <pre><code>response = requests.get('https://hostname:port/some/api/endpoint', proxies=None, auth=(USER, PASS))
  </code></pre>
  
  <p>But I still get the 502 Bad Gateway. In looking at some questions on SO, it looks as if you can specify the <code>NO_PROXY</code> environment variable and provide URLs that should not use the proxy. I tried populating that variable with <code>https://hostname</code>, <code>https://hostname:port</code>, <code>https://hostname/*</code>, <code>https://hostname:port/*</code>, and <code>hostname</code>. None of which seemed to work. (Are those even the right formats?)</p>
  
  <p>How do I get <code>requests</code> to use the equivalent of curl's <code>--noproxy</code>?</p>