prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Issues with proxies
  I've started Conan server in my organization's local network. For external sites (like github) proxy must be used, but not for computers in local network.
  So, I have there env variables:
  ```
  HTTP_PROXY=http://proxy.domain:3128
  HTTP_PROXY=https://proxy.domain:3128
  NO_PROXY=localhost,127.0.0.1,*.domain,192.168.*
  ```
  With these variables I can create packages with recipes in my local cache (and this recipes can download external sources), but cannot download recipes and prebuilt packages from organization's Conan server.
  
  I've tried to set same settings in conan.conf, but had no luck. Also I've tried to use Conan server domain name and/or IP address in NO_PROXY with same result:
  ```
  > conan search -r <remotename> "OpenCV*"
  ERROR: Permission denied for user: '<username>'. [Remote: <remotename>]
  ```
  
  But if I disable all proxies (comment in conan.conf and unset env variables), it works just fine:
  ```
  Existing package recipes:
  
  OpenCV/3.3.1@lukyanets/testing
  ```
  
  Conan v. 1.0.1, OS: Arch Linux, CentOS 6, Windows 10.
  
  </issue>
  <code>
  [start of conans/client/rest/conan_requester.py]
  1 import fnmatch
  2 import os
  3 
  4 from conans.util.files import save
  5 
  6 
  7 class ConanRequester(object):
  8 
  9     def __init__(self, requester, client_cache, timeout):
  10         self.proxies = client_cache.conan_config.proxies or {}
  11         self._no_proxy_match = [el.strip() for el in
  12                                 self.proxies.pop("no_proxy_match", "").split(",")]
  13         self._timeout_seconds = timeout
  14 
  15         # Retrocompatibility with deprecated no_proxy
  16         # Account for the requests NO_PROXY env variable, not defined as a proxy like http=
  17         no_proxy = self.proxies.pop("no_proxy", None)
  18         if no_proxy:
  19             os.environ["NO_PROXY"] = no_proxy
  20 
  21         self._requester = requester
  22         self._client_cache = client_cache
  23 
  24         if not os.path.exists(self._client_cache.cacert_path):
  25             from conans.client.rest.cacert import cacert
  26             save(self._client_cache.cacert_path, cacert)
  27 
  28         if not os.path.exists(client_cache.client_cert_path):
  29             self._client_certificates = None
  30         else:
  31             if os.path.exists(client_cache.client_cert_key_path):
  32                 # Requests can accept a tuple with cert and key, or just an string with a
  33                 # file having both
  34                 self._client_certificates = (client_cache.client_cert_path,
  35                                              client_cache.client_cert_key_path)
  36             else:
  37                 self._client_certificates = client_cache.client_cert_path
  38 
  39     def _should_skip_proxy(self, url):
  40 
  41         for entry in self._no_proxy_match:
  42             if fnmatch.fnmatch(url, entry):
  43                 return True
  44 
  45         return False
  46 
  47     def _add_kwargs(self, url, kwargs):
  48         if kwargs.get("verify", None) is True:
  49             kwargs["verify"] = self._client_cache.cacert_path
  50         else:
  51             kwargs["verify"] = False
  52         kwargs["cert"] = self._client_certificates
  53         if self.proxies:
  54             if not self._should_skip_proxy(url):
  55                 kwargs["proxies"] = self.proxies
  56         if self._timeout_seconds:
  57             kwargs["timeout"] = self._timeout_seconds
  58         return kwargs
  59 
  60     def get(self, url, **kwargs):
  61         return self._requester.get(url, **self._add_kwargs(url, kwargs))
  62 
  63     def put(self, url, **kwargs):
  64         return self._requester.put(url, **self._add_kwargs(url, kwargs))
  65 
  66     def delete(self, url, **kwargs):
  67         return self._requester.delete(url, **self._add_kwargs(url, kwargs))
  68 
  69     def post(self, url, **kwargs):
  70         return self._requester.post(url, **self._add_kwargs(url, kwargs))
  71 
  72
  [end of conans/client/rest/conan_requester.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/conans/client/rest/conan_requester.py b/conans/client/rest/conan_requester.py
  --- a/conans/client/rest/conan_requester.py
  +++ b/conans/client/rest/conan_requester.py
  @@ -9,7 +9,7 @@
       def __init__(self, requester, client_cache, timeout):
           self.proxies = client_cache.conan_config.proxies or {}
           self._no_proxy_match = [el.strip() for el in
  -                                self.proxies.pop("no_proxy_match", "").split(",")]
  +                                self.proxies.pop("no_proxy_match", "").split(",") if el]
           self._timeout_seconds = timeout
   
           # Retrocompatibility with deprecated no_proxy
  @@ -58,14 +58,28 @@
           return kwargs
   
       def get(self, url, **kwargs):
  -        return self._requester.get(url, **self._add_kwargs(url, kwargs))
  +        return self._call_method("get", url, **kwargs)
   
       def put(self, url, **kwargs):
  -        return self._requester.put(url, **self._add_kwargs(url, kwargs))
  +        return self._call_method("put", url, **kwargs)
   
       def delete(self, url, **kwargs):
  -        return self._requester.delete(url, **self._add_kwargs(url, kwargs))
  +        return self._call_method("delete", url, **kwargs)
   
       def post(self, url, **kwargs):
  -        return self._requester.post(url, **self._add_kwargs(url, kwargs))
  -
  +        return self._call_method("post", url, **kwargs)
  +
  +    def _call_method(self, method, url, **kwargs):
  +        popped = False
  +        if self.proxies or self._no_proxy_match:
  +            old_env = dict(os.environ)
  +            # Clean the proxies from the environ and use the conan specified proxies
  +            for var_name in ("http_proxy", "https_proxy", "no_proxy"):
  +                popped = popped or os.environ.pop(var_name, None)
  +                popped = popped or os.environ.pop(var_name.upper(), None)
  +        try:
  +            return getattr(self._requester, method)(url, **self._add_kwargs(url, kwargs))
  +        finally:
  +            if popped:
  +                os.environ.clear()
  +                os.environ.update(old_env)
  
verification_info: {"golden_diff": "diff --git a/conans/client/rest/conan_requester.py b/conans/client/rest/conan_requester.py\n--- a/conans/client/rest/conan_requester.py\n+++ b/conans/client/rest/conan_requester.py\n@@ -9,7 +9,7 @@\n     def __init__(self, requester, client_cache, timeout):\n         self.proxies = client_cache.conan_config.proxies or {}\n         self._no_proxy_match = [el.strip() for el in\n-                                self.proxies.pop(\"no_proxy_match\", \"\").split(\",\")]\n+                                self.proxies.pop(\"no_proxy_match\", \"\").split(\",\") if el]\n         self._timeout_seconds = timeout\n \n         # Retrocompatibility with deprecated no_proxy\n@@ -58,14 +58,28 @@\n         return kwargs\n \n     def get(self, url, **kwargs):\n-        return self._requester.get(url, **self._add_kwargs(url, kwargs))\n+        return self._call_method(\"get\", url, **kwargs)\n \n     def put(self, url, **kwargs):\n-        return self._requester.put(url, **self._add_kwargs(url, kwargs))\n+        return self._call_method(\"put\", url, **kwargs)\n \n     def delete(self, url, **kwargs):\n-        return self._requester.delete(url, **self._add_kwargs(url, kwargs))\n+        return self._call_method(\"delete\", url, **kwargs)\n \n     def post(self, url, **kwargs):\n-        return self._requester.post(url, **self._add_kwargs(url, kwargs))\n-\n+        return self._call_method(\"post\", url, **kwargs)\n+\n+    def _call_method(self, method, url, **kwargs):\n+        popped = False\n+        if self.proxies or self._no_proxy_match:\n+            old_env = dict(os.environ)\n+            # Clean the proxies from the environ and use the conan specified proxies\n+            for var_name in (\"http_proxy\", \"https_proxy\", \"no_proxy\"):\n+                popped = popped or os.environ.pop(var_name, None)\n+                popped = popped or os.environ.pop(var_name.upper(), None)\n+        try:\n+            return getattr(self._requester, method)(url, **self._add_kwargs(url, kwargs))\n+        finally:\n+            if popped:\n+                os.environ.clear()\n+                os.environ.update(old_env)\n", "issue": "Issues with proxies\nI've started Conan server in my organization's local network. For external sites (like github) proxy must be used, but not for computers in local network.\r\nSo, I have there env variables:\r\n```\r\nHTTP_PROXY=http://proxy.domain:3128\r\nHTTP_PROXY=https://proxy.domain:3128\r\nNO_PROXY=localhost,127.0.0.1,*.domain,192.168.*\r\n```\r\nWith these variables I can create packages with recipes in my local cache (and this recipes can download external sources), but cannot download recipes and prebuilt packages from organization's Conan server.\r\n\r\nI've tried to set same settings in conan.conf, but had no luck. Also I've tried to use Conan server domain name and/or IP address in NO_PROXY with same result:\r\n```\r\n> conan search -r <remotename> \"OpenCV*\"\r\nERROR: Permission denied for user: '<username>'. [Remote: <remotename>]\r\n```\r\n\r\nBut if I disable all proxies (comment in conan.conf and unset env variables), it works just fine:\r\n```\r\nExisting package recipes:\r\n\r\nOpenCV/3.3.1@lukyanets/testing\r\n```\r\n\r\nConan v. 1.0.1, OS: Arch Linux, CentOS 6, Windows 10.\n", "before_files": [{"content": "import fnmatch\nimport os\n\nfrom conans.util.files import save\n\n\nclass ConanRequester(object):\n\n    def __init__(self, requester, client_cache, timeout):\n        self.proxies = client_cache.conan_config.proxies or {}\n        self._no_proxy_match = [el.strip() for el in\n                                self.proxies.pop(\"no_proxy_match\", \"\").split(\",\")]\n        self._timeout_seconds = timeout\n\n        # Retrocompatibility with deprecated no_proxy\n        # Account for the requests NO_PROXY env variable, not defined as a proxy like http=\n        no_proxy = self.proxies.pop(\"no_proxy\", None)\n        if no_proxy:\n            os.environ[\"NO_PROXY\"] = no_proxy\n\n        self._requester = requester\n        self._client_cache = client_cache\n\n        if not os.path.exists(self._client_cache.cacert_path):\n            from conans.client.rest.cacert import cacert\n            save(self._client_cache.cacert_path, cacert)\n\n        if not os.path.exists(client_cache.client_cert_path):\n            self._client_certificates = None\n        else:\n            if os.path.exists(client_cache.client_cert_key_path):\n                # Requests can accept a tuple with cert and key, or just an string with a\n                # file having both\n                self._client_certificates = (client_cache.client_cert_path,\n                                             client_cache.client_cert_key_path)\n            else:\n                self._client_certificates = client_cache.client_cert_path\n\n    def _should_skip_proxy(self, url):\n\n        for entry in self._no_proxy_match:\n            if fnmatch.fnmatch(url, entry):\n                return True\n\n        return False\n\n    def _add_kwargs(self, url, kwargs):\n        if kwargs.get(\"verify\", None) is True:\n            kwargs[\"verify\"] = self._client_cache.cacert_path\n        else:\n            kwargs[\"verify\"] = False\n        kwargs[\"cert\"] = self._client_certificates\n        if self.proxies:\n            if not self._should_skip_proxy(url):\n                kwargs[\"proxies\"] = self.proxies\n        if self._timeout_seconds:\n            kwargs[\"timeout\"] = self._timeout_seconds\n        return kwargs\n\n    def get(self, url, **kwargs):\n        return self._requester.get(url, **self._add_kwargs(url, kwargs))\n\n    def put(self, url, **kwargs):\n        return self._requester.put(url, **self._add_kwargs(url, kwargs))\n\n    def delete(self, url, **kwargs):\n        return self._requester.delete(url, **self._add_kwargs(url, kwargs))\n\n    def post(self, url, **kwargs):\n        return self._requester.post(url, **self._add_kwargs(url, kwargs))\n\n", "path": "conans/client/rest/conan_requester.py"}]}