Skip to content

Commit 23ef024

Browse files
committed
use ProxiedAsyncHTTPClient for retrieving internet resources
calls to JupyterHub are ignored for now; in the unlikely event that somebody needs to call jupyterhub through a proxy we can still change this later
1 parent c763d47 commit 23ef024

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

binderhub/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"""
44
import urllib.parse
55

6-
from tornado.httpclient import AsyncHTTPClient, HTTPRequest
6+
from tornado.httpclient import HTTPRequest
77
from tornado.web import HTTPError, authenticated
88
from tornado.httputil import url_concat
99
from tornado.log import app_log
1010

1111
from .base import BaseHandler
12+
from .utils import ProxiedAsyncHTTPClient
1213

1314
SPEC_NAMES = {
1415
"gh": "GitHub",
@@ -77,7 +78,7 @@ async def get(self, provider_prefix, _unescaped_spec):
7778

7879
# Check if the nbviewer URL is valid and would display something
7980
# useful to the reader, if not we don't show it
80-
client = AsyncHTTPClient()
81+
client = ProxiedAsyncHTTPClient()
8182
# quote any unicode characters in the URL
8283
proto, rest = nbviewer_url.split("://")
8384
rest = urllib.parse.quote(rest)

binderhub/registry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from traitlets.config import LoggingConfigurable
1212
from traitlets import Dict, Unicode, default
1313

14+
from .utils import ProxiedAsyncHTTPClient
15+
1416
DEFAULT_DOCKER_REGISTRY_URL = "https://registry.hub.docker.com"
1517
DEFAULT_DOCKER_AUTH_URL = "https://index.docker.io/v1"
1618

@@ -187,7 +189,7 @@ def _default_password(self):
187189

188190
@gen.coroutine
189191
def get_image_manifest(self, image, tag):
190-
client = httpclient.AsyncHTTPClient()
192+
client = ProxiedAsyncHTTPClient()
191193
url = "{}/v2/{}/manifests/{}".format(self.url, image, tag)
192194
# first, get a token to perform the manifest request
193195
if self.token_url:

binderhub/repoproviders.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
from prometheus_client import Gauge
1919

2020
from tornado import gen
21-
from tornado.httpclient import AsyncHTTPClient, HTTPError, HTTPRequest
21+
from tornado.httpclient import HTTPError, HTTPRequest
2222
from tornado.httputil import url_concat
2323

2424
from traitlets import Dict, Unicode, Bool, default, List, observe
2525
from traitlets.config import LoggingConfigurable
2626

2727
from .utils import Cache
28+
from .utils import ProxiedAsyncHTTPClient
2829

2930
GITHUB_RATE_LIMIT = Gauge('binderhub_github_rate_limit_remaining', 'GitHub rate limit remaining')
3031
SHA1_PATTERN = re.compile(r'[0-9a-f]{40}')
@@ -217,7 +218,7 @@ class ZenodoProvider(RepoProvider):
217218

218219
@gen.coroutine
219220
def get_resolved_ref(self):
220-
client = AsyncHTTPClient()
221+
client = ProxiedAsyncHTTPClient()
221222
req = HTTPRequest("https://doi.org/{}".format(self.spec),
222223
user_agent="BinderHub")
223224
r = yield client.fetch(req)
@@ -257,7 +258,7 @@ class FigshareProvider(RepoProvider):
257258

258259
@gen.coroutine
259260
def get_resolved_ref(self):
260-
client = AsyncHTTPClient()
261+
client = ProxiedAsyncHTTPClient()
261262
req = HTTPRequest("https://doi.org/{}".format(self.spec),
262263
user_agent="BinderHub")
263264
r = yield client.fetch(req)
@@ -439,7 +440,7 @@ def get_resolved_ref(self):
439440
return self.resolved_ref
440441

441442
namespace = urllib.parse.quote(self.namespace, safe='')
442-
client = AsyncHTTPClient()
443+
client = ProxiedAsyncHTTPClient()
443444
api_url = "https://{hostname}/api/v4/projects/{namespace}/repository/commits/{ref}".format(
444445
hostname=self.hostname,
445446
namespace=namespace,
@@ -582,7 +583,7 @@ async def get_resolved_ref_url(self):
582583

583584
@gen.coroutine
584585
def github_api_request(self, api_url, etag=None):
585-
client = AsyncHTTPClient()
586+
client = ProxiedAsyncHTTPClient()
586587
if self.auth:
587588
# Add auth params. After logging!
588589
api_url = url_concat(api_url, self.auth)

0 commit comments

Comments
 (0)