Skip to content

Commit 1d022a9

Browse files
authored
Merge pull request #8 from jgiannuzzi/http-proxy-support
HTTP proxy support
2 parents de2fc06 + 3117293 commit 1d022a9

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

pypi_server/handlers/pypi/package.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def write_file(pkg_file, data):
4646
@route(r"/package/(?P<package>\S+)/(?P<version>\S+)/(?P<filename>\S+)")
4747
class FileHandler(BaseHandler):
4848
CHUNK_SIZE = 2 ** 16
49-
HTTP_CLIENT = AsyncHTTPClient()
5049

5150
@asynchronous
5251
@HTTPCache(MONTH, use_expires=True, expire_timeout=MONTH)
@@ -112,7 +111,7 @@ def find_file(self, package, version, filename):
112111
@classmethod
113112
@coroutine
114113
def fetch_remote_file(cls, pkg_file):
115-
response = yield cls.HTTP_CLIENT.fetch(pkg_file.url)
114+
response = yield AsyncHTTPClient().fetch(pkg_file.url)
116115
yield write_file(pkg_file, response.body)
117116

118117

pypi_server/server.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,19 @@ def handle_pdb(sig, frame):
163163

164164
AsyncHTTPClient.configure(None, max_clients=options.max_http_clients)
165165

166+
proxy_url = URL(os.getenv('{0}_proxy'.format(options.pypi_server.scheme)))
167+
if proxy_url:
168+
log.debug("Configuring for proxy: %s", proxy_url)
169+
AsyncHTTPClient.configure(
170+
'tornado.curl_httpclient.CurlAsyncHTTPClient',
171+
defaults={
172+
'proxy_host': proxy_url.host,
173+
'proxy_port': proxy_url.port,
174+
'proxy_username': proxy_url.user,
175+
'proxy_password': proxy_url.password,
176+
}
177+
)
178+
166179
PYPIClient.configure(
167180
options.pypi_server,
168181
handlers.base.BaseHandler.THREAD_POOL

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,6 @@ def walker(base, *paths):
8989
extras_require={
9090
'mysql': ['mysql-python'],
9191
'postgres': ['psycopg2'],
92+
'proxy': ['pycurl'],
9293
}
9394
)

0 commit comments

Comments
 (0)